mirror of https://github.com/MISP/PyMISP
fix situational-awareness examples
parent
ed2be78f4e
commit
bc5df41179
|
@ -21,8 +21,11 @@ if __name__ == '__main__':
|
||||||
else:
|
else:
|
||||||
result = misp.download_last(args.argument)
|
result = misp.download_last(args.argument)
|
||||||
|
|
||||||
|
if 'response' in result:
|
||||||
events = tools.eventsListBuildFromArray(result)
|
events = tools.eventsListBuildFromArray(result)
|
||||||
attributes = tools.attributesListBuild(events)
|
attributes = tools.attributesListBuild(events)
|
||||||
temp = tools.getNbAttributePerEventCategoryType(attributes)
|
temp = tools.getNbAttributePerEventCategoryType(attributes)
|
||||||
temp = temp.groupby(level=['category', 'type']).sum()
|
temp = temp.groupby(level=['category', 'type']).sum()
|
||||||
tools.createTreemap(temp, 'Attributes Distribution', 'attribute_treemap.svg', 'attribute_table.html')
|
tools.createTreemap(temp, 'Attributes Distribution', 'attribute_treemap.svg', 'attribute_table.html')
|
||||||
|
else:
|
||||||
|
print ('There is no event answering the research criteria')
|
||||||
|
|
|
@ -41,6 +41,7 @@ if __name__ == '__main__':
|
||||||
else:
|
else:
|
||||||
args.enddate = tools.setEnddate(tools.toDatetime(args.enddate))
|
args.enddate = tools.setEnddate(tools.toDatetime(args.enddate))
|
||||||
|
|
||||||
|
if 'response' in result:
|
||||||
events = tools.selectInRange(tools.eventsListBuildFromArray(result), begin=args.begindate, end=args.enddate)
|
events = tools.selectInRange(tools.eventsListBuildFromArray(result), begin=args.begindate, end=args.enddate)
|
||||||
totalPeriodEvents = tools.getNbitems(events)
|
totalPeriodEvents = tools.getNbitems(events)
|
||||||
tags = tools.tagsListBuild(events)
|
tags = tools.tagsListBuild(events)
|
||||||
|
@ -63,3 +64,6 @@ if __name__ == '__main__':
|
||||||
print('During the studied pediod, ' + str(totalPeriodTags) + ' events out of ' + str(totalPeriodEvents) + ' contains at least one tag with ' + args.tag + '.')
|
print('During the studied pediod, ' + str(totalPeriodTags) + ' events out of ' + str(totalPeriodEvents) + ' contains at least one tag with ' + args.tag + '.')
|
||||||
if totalPeriodEvents != 0:
|
if totalPeriodEvents != 0:
|
||||||
print('It represents {}% of the events in this period.'.format(round(100 * totalPeriodTags / totalPeriodEvents, 3)))
|
print('It represents {}% of the events in this period.'.format(round(100 * totalPeriodTags / totalPeriodEvents, 3)))
|
||||||
|
else:
|
||||||
|
print ('There is no event answering the research criteria')
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,12 @@ if __name__ == '__main__':
|
||||||
else:
|
else:
|
||||||
args.enddate = tools.setEnddate(tools.toDatetime(args.enddate))
|
args.enddate = tools.setEnddate(tools.toDatetime(args.enddate))
|
||||||
|
|
||||||
|
if 'response' in result:
|
||||||
events = tools.selectInRange(tools.eventsListBuildFromArray(result), begin=args.begindate, end=args.enddate)
|
events = tools.selectInRange(tools.eventsListBuildFromArray(result), begin=args.begindate, end=args.enddate)
|
||||||
tags = tools.tagsListBuild(events)
|
tags = tools.tagsListBuild(events)
|
||||||
result = tools.getNbOccurenceTags(tags)
|
result = tools.getNbOccurenceTags(tags)
|
||||||
|
else:
|
||||||
|
result = 'There is no event during the studied period'
|
||||||
|
|
||||||
text = 'Studied pediod: from '
|
text = 'Studied pediod: from '
|
||||||
if args.begindate is None:
|
if args.begindate is None:
|
||||||
|
|
|
@ -50,6 +50,7 @@ if __name__ == '__main__':
|
||||||
title = 'Tags repartition over the last 7 days'
|
title = 'Tags repartition over the last 7 days'
|
||||||
|
|
||||||
result = misp.download_last(last)
|
result = misp.download_last(last)
|
||||||
|
if 'response' in result:
|
||||||
events = tools.eventsListBuildFromArray(result)
|
events = tools.eventsListBuildFromArray(result)
|
||||||
result = []
|
result = []
|
||||||
dates = []
|
dates = []
|
||||||
|
@ -80,7 +81,6 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
taxonomies, emptyOther = tools.getTaxonomies(tools.getCopyDataframe(result))
|
taxonomies, emptyOther = tools.getTaxonomies(tools.getCopyDataframe(result))
|
||||||
|
|
||||||
|
|
||||||
tools.tagsToLineChart(tools.getCopyDataframe(result), title, dates, colourDict)
|
tools.tagsToLineChart(tools.getCopyDataframe(result), title, dates, colourDict)
|
||||||
tools.tagstrendToLineChart(tools.getCopyDataframe(result), title, dates, split, colourDict)
|
tools.tagstrendToLineChart(tools.getCopyDataframe(result), title, dates, split, colourDict)
|
||||||
tools.tagsToTaxoLineChart(tools.getCopyDataframe(result), title, dates, colourDict, taxonomies, emptyOther)
|
tools.tagsToTaxoLineChart(tools.getCopyDataframe(result), title, dates, colourDict, taxonomies, emptyOther)
|
||||||
|
@ -89,3 +89,6 @@ if __name__ == '__main__':
|
||||||
args.order = 3
|
args.order = 3
|
||||||
tools.tagsToPolyChart(tools.getCopyDataframe(result), split, colourDict, taxonomies, emptyOther, args.order)
|
tools.tagsToPolyChart(tools.getCopyDataframe(result), split, colourDict, taxonomies, emptyOther, args.order)
|
||||||
tools.createVisualisation(taxonomies)
|
tools.createVisualisation(taxonomies)
|
||||||
|
|
||||||
|
else:
|
||||||
|
print('There is no event during the studied period')
|
||||||
|
|
|
@ -437,7 +437,7 @@ def tagsToPolyChart(dataframe, split, colourDict, taxonomies, emptyOther, order)
|
||||||
pylab.title('Polynomial Fit with Matplotlib: ' + taxonomy)
|
pylab.title('Polynomial Fit with Matplotlib: ' + taxonomy)
|
||||||
pylab.legend(loc='center left', bbox_to_anchor=(1, 0.5))
|
pylab.legend(loc='center left', bbox_to_anchor=(1, 0.5))
|
||||||
ax = plt.gca()
|
ax = plt.gca()
|
||||||
ax.set_facecolor((0.898, 0.898, 0.898))
|
# ax.set_facecolor((0.898, 0.898, 0.898))
|
||||||
box = ax.get_position()
|
box = ax.get_position()
|
||||||
ax.set_position([box.x0 - 0.01, box.y0, box.width * 0.78, box.height])
|
ax.set_position([box.x0 - 0.01, box.y0, box.width * 0.78, box.height])
|
||||||
fig = plt.gcf()
|
fig = plt.gcf()
|
||||||
|
@ -473,7 +473,7 @@ def tagsToPolyChart(dataframe, split, colourDict, taxonomies, emptyOther, order)
|
||||||
pylab.title('Polynomial Fit with Matplotlib: other')
|
pylab.title('Polynomial Fit with Matplotlib: other')
|
||||||
pylab.legend(loc='center left', bbox_to_anchor=(1, 0.5))
|
pylab.legend(loc='center left', bbox_to_anchor=(1, 0.5))
|
||||||
ax = plt.gca()
|
ax = plt.gca()
|
||||||
ax.set_facecolor((0.898, 0.898, 0.898))
|
#cax.set_facecolor((0.898, 0.898, 0.898))
|
||||||
box = ax.get_position()
|
box = ax.get_position()
|
||||||
ax.set_position([box.x0 - 0.01, box.y0, box.width * 0.78, box.height])
|
ax.set_position([box.x0 - 0.01, box.y0, box.width * 0.78, box.height])
|
||||||
fig = plt.gcf()
|
fig = plt.gcf()
|
||||||
|
|
Loading…
Reference in New Issue