Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release Notes as callable function in library #134

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
43 changes: 43 additions & 0 deletions mitreattack/stix20/MitreAttackData.py
Original file line number Diff line number Diff line change
Expand Up @@ -1623,3 +1623,46 @@ def get_revoking_object(self, revoked_stix_id: str = "") -> object:
return None

return revoked_by[0]

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."))