oasis-open / cti-stix-generator

OASIS Cyber Threat Intelligence (CTI) TC: A tool for generating STIX content for prototyping and testing. https://github.com/oasis-open/cti-stix-generator
https://stix2-generator.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
40 stars 16 forks source link

Cannot generate indicator objects with Python script #5

Closed zrush-mitre closed 3 years ago

zrush-mitre commented 3 years ago

May be related to #4

When using a config with a probability_sighting value of 0, generating an indicator throws an error.

Code:

import stix2generator

con = stix2generator.generation.stix_generator.Config(probability_sighting=0)

g = stix2generator.create_stix_generator(stix_generator_config=con)

g.generate('indicator')

Output: Traceback (most recent call last):

File "<stdin>", line 1, in <module>

File "C:\Users\zrush\stix_venv\lib\site-packages\stix2generator\generation\stix_generator.py", line 694, in generate

  by_id[new_id] = stix2.parse(

File "c:\users\zrush\stix_venv\cti-python-stix2\stix2\parsing.py", line 47, in parse

  obj = dict_to_stix2(obj, allow_custom, version)

File "c:\users\zrush\stix_venv\cti-python-stix2\stix2\parsing.py", line 142, in dict_to_stix2

  return obj_class(allow_custom=allow_custom, **stix_dict)

File "c:\users\zrush\stix_venv\cti-python-stix2\stix2\v21\sdo.py", line 207, in __init__

  super(Indicator, self).__init__(*args, **kwargs)

File "c:\users\zrush\stix_venv\cti-python-stix2\stix2\base.py", line 176, in __init__

  self._check_object_constraints()

File "c:\users\zrush\stix_venv\cti-python-stix2\stix2\v21\sdo.py", line 227, in _check_object_constraints

  raise InvalidValueError(self.__class__, 'pattern', str(errors[0]))

stix2.exceptions.InvalidValueError: Invalid value for Indicator 'pattern': FAIL: Error found at line 1:0. input is missing square brackets
chisholm commented 3 years ago

Does it work when using the stix generator branch from PR#4? If I am on the master branch, I get errors, but not that one. But we know it won't work.

zrush-mitre commented 3 years ago

Does it work when using the stix generator branch from PR#4? If I am on the master branch, I get errors, but not that one. But we know it won't work.

Yup, installing your branch allowed the object to be created.

chisholm commented 3 years ago

Now that PR #4 is merged and we have a new release, this should be fixed.