DISARMFoundation / DISARM-STIX2

A STIX2 generator for the DISARM Framework
8 stars 4 forks source link

Issue with STIX object generation as tactic dictionary missing entries #2

Open himynamesdave opened 1 year ago

himynamesdave commented 1 year ago

Have been trying to run the current code;

git clone https://github.com/DISARMFoundation/DISARM-STIX2
cd DISARM-STIX2
python3 -m venv DISARM-STIX2
source DISARM-STIX2/bin/activate
pip3 install -r requirements.txt
curl https://raw.githubusercontent.com/DISARMFoundation/DISARMframeworks/main/DISARM_MASTER_DATA/DISARM_FRAMEWORKS_MASTER.xlsx > DISARM_FRAMEWORKS_MASTER.xlsx
python3 main.py

However gives;

Traceback (most recent call last):
  File "Downloads/DISARM-STIX2/main.py", line 51, in <module>
    generate_disarm_stix()
  File "Downloads/DISARM-STIX2/main.py", line 31, in generate_disarm_stix
    tactics = tactic.make_disarm_tactics(data, identity_id, marking_id)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "Downloads/DISARM-STIX2/objects/tactic.py", line 44, in make_disarm_tactics
    tactic = Tactic(
             ^^^^^^^
  File "Downloads/DISARM-STIX2/DISARM-STIX2/lib/python3.11/site-packages/stix2/custom.py", line 33, in __init__
    _cls_init(cls, self, kwargs)
  File "Downloads/DISARM-STIX2/DISARM-STIX2/lib/python3.11/site-packages/stix2/base.py", line 492, in _cls_init
    cls.__init__(obj, **kwargs)
  File "Downloads/DISARM-STIX2/objects/tactic.py", line 21, in __init__
    raise ValueError("'%s' is not a recognized DISARM Tactic." % x_mitre_shortname)
ValueError: 'maximise-exposure' is not a recognized DISARM Tactic.

The error is thrown here: https://github.com/DISARMFoundation/DISARM-STIX2/blob/main/objects/tactic.py#L18

And is because tactics are hardcoded here: https://github.com/DISARMFoundation/DISARM-STIX2/blob/main/objects/tactic.py#L6

See maximise-exposure is not included.

I suspect the development of the XLSX has advanced ahead of the code, looking at the last commit date.

The addition of maximise-exposure as follows, solves the issue.


valid_tactics = ["plan-strategy", "plan-objectives", "microtarget", "develop-content",
                 "select-channels-and-affordances", "conduct-pump-priming", "deliver-content",
                 "drive-offline-activity", "persist-in-the-information-environment", "assess-effectiveness",
                 "target-audience-analysis", "develop-narratives", "establish-social-assets", "establish-legitimacy",
                 "maximize-exposure", "drive-online-harms", "maximise-exposure"]