You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
In my project I have some code that makes use of misp-stix to convert MISP Events to STIX 2.1 Bundles. As part of that I have some unit tests that compare the output of running the test with the output of running misp_stix_converter export --version 2.1 --file misp.event.json on the MISP Event. The trouble is the id's of the relationship objects that are produced change each time the conversion is done, which makes it difficult to run tests against.
Describe the solution you'd like
Generally speaking I would like to be able to run misp_stix_converter export --version 2.1 --file misp.event.json against the same input file multiple times and have the exact same output produced each time.
Describe alternatives you've considered
To work around this in my tests I've used a UUIDv5 to generate a stable UUID based on the relationshiprelationship_type, source_ref, and target_ref. Seems to work fine for my needs currently.
fromuuidimportUUID, uuid5stix_bundle= {} # Assume `stix_bundle` is a Python object representation of valid STIX 2.1 JSONnamespace=UUID(stix_bundle["id"][-36:])
obj=stix_bundle["objects"][0] # Assume the first object is a `relationship`name=f"{obj['relationship_type']}{obj['source_ref']}{obj['target_ref']}"stable_uuid=str(uuid5(namespace, name))
stable_id=f"relationship--{stable_uuid}"
After running misp_stix_converter export --version 2.1 --file misp.event.circl-osint-feed-0b988513-9535-42f0-9ebc-5d6aec2e1c79.json twice I got these two outputs:
Is your feature request related to a problem? Please describe.
In my project I have some code that makes use of
misp-stix
to convert MISP Events to STIX 2.1 Bundles. As part of that I have some unit tests that compare the output of running the test with the output of runningmisp_stix_converter export --version 2.1 --file misp.event.json
on the MISP Event. The trouble is the id's of therelationship
objects that are produced change each time the conversion is done, which makes it difficult to run tests against.Describe the solution you'd like
Generally speaking I would like to be able to run
misp_stix_converter export --version 2.1 --file misp.event.json
against the same input file multiple times and have the exact same output produced each time.Describe alternatives you've considered
To work around this in my tests I've used a UUIDv5 to generate a stable UUID based on the
relationship
relationship_type
,source_ref
, andtarget_ref
. Seems to work fine for my needs currently.Additional context
Example MISP input taken from https://www.circl.lu/doc/misp/feed-osint/0b988513-9535-42f0-9ebc-5d6aec2e1c79.json:
misp.event.circl-osint-feed-0b988513-9535-42f0-9ebc-5d6aec2e1c79.json
After running
misp_stix_converter export --version 2.1 --file misp.event.circl-osint-feed-0b988513-9535-42f0-9ebc-5d6aec2e1c79.json
twice I got these two outputs:misp.event.circl-osint-feed-0b988513-9535-42f0-9ebc-5d6aec2e1c79.out.json
misp.event.circl-osint-feed-0b988513-9535-42f0-9ebc-5d6aec2e1c79.out.json
Doing a
diff
on these two outputs produced this, where therelationship
UUIDs are all different. And that's the only difference.This was run on Python 3.11 with the below environment:
Code of Conduct
The text was updated successfully, but these errors were encountered: