Skip to content

Commit

Permalink
Merge pull request #5 from grikos/incident_netfor
Browse files Browse the repository at this point in the history
Получение информации по сессиям и алертам для инцидентов, созданных из PT NAD
  • Loading branch information
nikolaiav authored Feb 9, 2023
2 parents 1557b37 + 66ad990 commit ccdee1b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v1.5.0.2
## Incidents
- Для инцидентов, созданных из PT NAD, детальная информация по инциденту дополнена информацией о сетевом трафике
(время, фильтр для PT NAD, информация о сетевых сессиях, информация об алертах)

---

# v1.5.0.1
- Поддержка R25.1
- Создание и удаление задач
Expand Down
54 changes: 54 additions & 0 deletions mpsiemlib/modules/Incidents.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class Incidents(ModuleInterface, LoggingHandler):
__api_incident_events = "/api/incidents/{}/events?limit={}"
__api_incident_events_count = "/api/incidents/{}/events/count"
__api_incident_issue = "/api/incidents/{}/issues"
__api_incident_netfor = "/api/incidents/{}/linkedObjects/netfor"
__api_incident_netfor_sessions = "/api/incidents/{}/linkedObjects/netfor/sessions?offset=0&limit=2000"
__api_incident_netfor_alerts = "/api/incidents/{}/linkedObjects/netfor/alerts?offset=0&limit=2000"

class TimeFilterType:
CREATED = "creation"
Expand Down Expand Up @@ -224,6 +227,10 @@ def get_incident_info(self, incident_id: str) -> dict:
"events": events,
"issues": issues
}

if inc.get("source") == "netFor":
netfor = self.__load_netfor(incident_id)
ret["netfor"] = netfor

self.log.info('status=success, action=get_table_info, msg="Get {} properties for incident {}", '
'hostname="{}"'.format(len(ret), incident_id, self.__core_hostname))
Expand Down Expand Up @@ -304,6 +311,53 @@ def __load_issues(self, incident_id):

return issues

def __load_netfor(self, incident_id):
"""
Загрузить информацию по сетевому трафику (для инцидентов, созданных нажатием кнопки в PT NAD)
:param incident_id:
:return:
"""
api_url = self.__api_incident_netfor.format(incident_id)
url = "https://{}{}".format(self.__core_hostname, api_url)
rq = exec_request(self.__core_session, url, method="GET", timeout=self.settings.connection_timeout)
response = rq.json()

netfor = {}
netfor = response
netfor['sessions'] = self.__load_netfor_sessions(incident_id)
netfor['alerts'] = self.__load_netfor_alerts(incident_id)

return netfor

def __load_netfor_sessions(self, incident_id):
"""
Загрузить информацию по сессиям в сетевом трафике (для инцидентов, созданных нажатием кнопки в PT NAD)
:param incident_id:
:return:
"""
api_url = self.__api_incident_netfor_sessions.format(incident_id)
url = "https://{}{}".format(self.__core_hostname, api_url)
rq = exec_request(self.__core_session, url, method="GET", timeout=self.settings.connection_timeout)
response = rq.json()

return response

def __load_netfor_alerts(self, incident_id):
"""
Загрузить информацию по алертам в сетевом трафике (для инцидентов, созданных нажатием кнопки в PT NAD)
:param incident_id:
:return:
"""
api_url = self.__api_incident_netfor_alerts.format(incident_id)
url = "https://{}{}".format(self.__core_hostname, api_url)
rq = exec_request(self.__core_session, url, method="GET", timeout=self.settings.connection_timeout)
response = rq.json()

return response

def close(self):
if self.__core_session is not None:
self.__core_session.close()

0 comments on commit ccdee1b

Please sign in to comment.