Skip to content

Commit

Permalink
Add functionality to get_release_notes method stub
Browse files Browse the repository at this point in the history
  • Loading branch information
chdillard committed Jul 18, 2023
1 parent 95fecfa commit fd17757
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
11 changes: 11 additions & 0 deletions examples/get_release_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from mitreattack.stix20 import get_release_notes
from mitreattack.stix20 import MitreAttackData


def main():
MitreAttackData.print_release_notes("enterprise-attack.json", "mobile-attack.json", "ics-attack.json")
return


if __name__ == "__main__":
main()
44 changes: 42 additions & 2 deletions mitreattack/stix20/MitreAttackData.py
Original file line number Diff line number Diff line change
Expand Up @@ -1624,5 +1624,45 @@ def get_revoking_object(self, revoked_stix_id: str = "") -> object:

return revoked_by[0]

def get_release_notes(self, enterprise_stix, mobile_stix, ics_stix):
return
def get_release_notes(self):
groups = self.remove_revoked_deprecated(self.get_groups())
software = self.remove_revoked_deprecated(self.get_software())
subtechniques = self.remove_revoked_deprecated(self.get_subtechniques())
tactics = self.remove_revoked_deprecated(self.get_tactics())
techniques = self.remove_revoked_deprecated(self.get_techniques())
campaigns = self.remove_revoked_deprecated(self.get_campaigns())

ret = {}
ret["software"] = len(software)
ret["groups"] = len(groups)
ret["campaigns"] = len(campaigns)
ret["tactics"] = len(tactics)
ret["subtechniques"] = len(subtechniques)
ret["techniques"] = len(techniques) - ret["subtechniques"]

return ret

@staticmethod
def print_release_notes(enterprise_stix, mobile_stix, ics_stix):
enterprise = MitreAttackData(enterprise_stix).get_release_notes()
mobile = MitreAttackData(mobile_stix).get_release_notes()
ics = MitreAttackData(ics_stix).get_release_notes()

software = enterprise["software"] + mobile["software"] + ics["software"]
campaigns = enterprise["campaigns"] + mobile["campaigns"] + ics["campaigns"]
groups = enterprise["groups"] + mobile["groups"] + ics["groups"]

dictionary = {}
dictionary["Enterprise"] = enterprise
dictionary["Mobile"] = mobile
dictionary["ICS"] = ics

print(f"This version of ATT&CK contains {software} Pieces of Software, {groups} Groups, and {campaigns} Campaigns")
print("Broken out by domain:\n")
for key, stix in dictionary.items():
print((f"-ATT&CK for {key} contains {stix['tactics']} "
f"Tactics, {stix['techniques']} Techniques, "
f"{stix['subtechniques']} Sub-Techniques, "
f"{stix['groups']} Groups, {stix['campaigns']} "
f"Campaigns, and {stix['software']} Pieces of Software."))

0 comments on commit fd17757

Please sign in to comment.