Added URLs to incident pages

This commit is contained in:
Stephen Campbell 2024-05-18 18:19:30 -04:00
parent 87cdbde844
commit 1b9ccce6c7
67 changed files with 434 additions and 8 deletions

View file

@ -158,6 +158,8 @@ class Disarm:
'resources_needed', 'resource', ',')
self.cross_detectionid_actortypeid = self.create_cross_table(self.df_detections[['disarm_id', 'actortypes']],
'actortypes', 'actortype', ',')
self.cross_incidentid_urls = self.create_cross_table(self.df_incidents[['disarm_id', 'urls']],
'urls', 'url', ' ')
def create_incident_technique_crosstable(self, it_metadata):
@ -212,14 +214,14 @@ class Disarm:
def create_incident_urls_string(self, incidentid):
urlsstr = '''
| Reference |
| Reference(s) |
| --------- |
'''
urlsrow = '| [{0}]({0})|\n'
incident = self.df_incidents[self.df_incidents['disarm_id']==incidentid]
urls_series = incident['urls'].series.str.split(' ',expand=True).explode
for u in urls_series:
urlsstr += urlsrow.format(u)
urlsrow = '| [{0}]({0}) |\n'
incidentid_urls = self.cross_incidentid_urls[self.cross_incidentid_urls['disarm_id']==incidentid]
for index, row in incidentid_urls.iterrows():
urlsstr += urlsrow.format(row['url_id'])
return urlsstr
@ -506,7 +508,7 @@ class Disarm:
tocountry=row['found_in_country'],
foundvia=row['found_via'],
dateadded=row['when_added'],
urls=self.create_incident_urls_string(row['disarm_id'])),
urls=self.create_incident_urls_string(row['disarm_id']),
techniques=self.create_incident_techniques_string(row['disarm_id']))
if objecttype == 'actortype':
metatext = template.format(type = 'Actor', id=row['disarm_id'], name=row['name'],