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

Feature Request: Make misp_stix_converter STIX 2.1 output relationship id's stable #68

Open
1 task done
gopackgo90 opened this issue Feb 16, 2025 · 0 comments
Open
1 task done

Comments

@gopackgo90
Copy link

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 relationship relationship_type, source_ref, and target_ref. Seems to work fine for my needs currently.

from uuid import UUID, uuid5

stix_bundle = {}  # Assume `stix_bundle` is a Python object representation of valid STIX 2.1 JSON
namespace = 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}"

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:

  1. misp.event.circl-osint-feed-0b988513-9535-42f0-9ebc-5d6aec2e1c79.out.json

  2. misp.event.circl-osint-feed-0b988513-9535-42f0-9ebc-5d6aec2e1c79.out.json

Doing a diff on these two outputs produced this, where the relationship UUIDs are all different. And that's the only difference.

133,160c133,160
<                 "relationship--330ac58d-4ec1-487e-8126-e97ec911c637",
<                 "relationship--eae25a61-5805-4f28-be54-668dd61dd871",
<                 "relationship--22be486b-cc2a-486d-b356-55cc785cb488",
<                 "relationship--de204fe5-d1b9-4490-a69f-639f037763bb",
<                 "relationship--8ad412cf-85cc-45fb-9416-1d44d8f1ef54",
<                 "relationship--c8fd4c98-8114-4b9e-803f-bd1da227bc4e",
<                 "relationship--8ba092f1-8e34-4910-9c00-2be9128fbaa0",
<                 "relationship--0f85a8eb-5292-4b78-bb45-cbc4c81674a4",
<                 "relationship--0e5f5d2f-5b78-44dd-b38e-af3077c53b99",
<                 "relationship--659d139a-8a32-4d26-8a8f-e8cee559a0e8",
<                 "relationship--c9f533a7-369a-45d2-bc88-c6a0c2ca3a7a",
<                 "relationship--26473484-56e9-489b-902e-26ac2a148a38",
<                 "relationship--593f45ff-58f0-48b0-b221-c68ed21ecb94",
<                 "relationship--9885973b-332d-4ac5-bd5c-239efdd18d5b",
<                 "relationship--5cf63ed7-993b-441a-9922-77d7fc112a43",
<                 "relationship--113a42ce-1776-45f4-90ac-995ca708f242",
<                 "relationship--6a739018-3dd1-4624-8993-713d6f755822",
<                 "relationship--4b24ba28-2021-4d15-a223-de563ee48d59",
<                 "relationship--744eb9c6-1340-4cef-b4de-13f20e07c9b2",
<                 "relationship--92f55577-b7cb-4367-8526-d996367879ff",
<                 "relationship--dc09a07e-3794-43eb-b299-380beb5e2ef9",
<                 "relationship--363200f4-ba48-4d4c-88c9-179583a03799",
<                 "relationship--d8f3dc90-e98c-4b59-94a4-bbb0163cb4a9",
<                 "relationship--ca6607e2-2da2-4c0a-85a2-9767758a8e0b",
<                 "relationship--edd303d9-996f-4b18-8663-69090d3be57a",
<                 "relationship--2029aa00-2f4b-4f43-a78b-6cf22559bf3c",
<                 "relationship--378d696b-f386-402b-a76d-c9c0db297d1c",
<                 "relationship--5f0400b0-4da1-4438-aae6-f392d8529583"
---
>                 "relationship--b83b6415-3377-4043-9fd8-f7c67f612294",
>                 "relationship--9fa3b665-08e3-4ce4-a25b-f125c0e1e4c2",
>                 "relationship--d69f0f4c-e372-495e-9c77-05471c6d268d",
>                 "relationship--b2b8e258-65c8-4c0a-8f4a-f7a660794390",
>                 "relationship--282f245c-df22-4930-82ab-fb8367b40700",
>                 "relationship--cff807ad-0799-4e12-8bed-0d25a567b6e9",
>                 "relationship--d7cb3ca8-55cd-40bf-9a6a-3ff67a2b6401",
>                 "relationship--8653a6e0-adfd-4228-8298-ad5fa6d01715",
>                 "relationship--c0e4beff-6773-4b6a-8aec-41d81d9f8c9c",
>                 "relationship--7fb45641-3d93-439d-8085-4f823291e353",
>                 "relationship--2069013b-fc74-43ef-ad73-2693240498d9",
>                 "relationship--05291526-4318-4903-941c-5a6d78739948",
>                 "relationship--b4e9aab5-7fef-47c8-9ad8-575fdf31924c",
>                 "relationship--e8345eb4-0bc0-4f16-ad2b-25db14ba24f3",
>                 "relationship--e7617d5b-80d5-4274-8f40-f2242f53792b",
>                 "relationship--a6ce405e-0f35-4b96-8e59-57423358745b",
>                 "relationship--75e2f8c2-393d-417c-bba6-f30b6cd11b16",
>                 "relationship--75b0f157-8cc6-4dd9-961b-50d2b4211c9c",
>                 "relationship--08221765-798f-48a4-8306-536ca24a0571",
>                 "relationship--ea2e071a-52a3-4451-a510-66c8fc8fb486",
>                 "relationship--2c94894c-de37-45b8-914e-a809633202d5",
>                 "relationship--8875b10b-d9ed-495b-b92b-5ab0b38bad3d",
>                 "relationship--1e393e30-baa1-4986-9d8d-16651566e674",
>                 "relationship--30d873df-a7ec-4477-8c5a-d2b79e9d262a",
>                 "relationship--9f38413d-4cb3-43c7-b5b4-183bbdaec4d4",
>                 "relationship--e7346590-cf21-42ac-8dd3-92c585ced616",
>                 "relationship--cc947fd7-2da1-4bf6-8071-e5c804125ecc",
>                 "relationship--95ab1a0f-d5e8-4054-ae1d-7dad38eeddad"
3019c3019
<             "id": "relationship--330ac58d-4ec1-487e-8126-e97ec911c637",
---
>             "id": "relationship--b83b6415-3377-4043-9fd8-f7c67f612294",
3029c3029
<             "id": "relationship--eae25a61-5805-4f28-be54-668dd61dd871",
---
>             "id": "relationship--9fa3b665-08e3-4ce4-a25b-f125c0e1e4c2",
3039c3039
<             "id": "relationship--22be486b-cc2a-486d-b356-55cc785cb488",
---
>             "id": "relationship--d69f0f4c-e372-495e-9c77-05471c6d268d",
3049c3049
<             "id": "relationship--de204fe5-d1b9-4490-a69f-639f037763bb",
---
>             "id": "relationship--b2b8e258-65c8-4c0a-8f4a-f7a660794390",
3059c3059
<             "id": "relationship--8ad412cf-85cc-45fb-9416-1d44d8f1ef54",
---
>             "id": "relationship--282f245c-df22-4930-82ab-fb8367b40700",
3069c3069
<             "id": "relationship--c8fd4c98-8114-4b9e-803f-bd1da227bc4e",
---
>             "id": "relationship--cff807ad-0799-4e12-8bed-0d25a567b6e9",
3079c3079
<             "id": "relationship--8ba092f1-8e34-4910-9c00-2be9128fbaa0",
---
>             "id": "relationship--d7cb3ca8-55cd-40bf-9a6a-3ff67a2b6401",
3089c3089
<             "id": "relationship--0f85a8eb-5292-4b78-bb45-cbc4c81674a4",
---
>             "id": "relationship--8653a6e0-adfd-4228-8298-ad5fa6d01715",
3099c3099
<             "id": "relationship--0e5f5d2f-5b78-44dd-b38e-af3077c53b99",
---
>             "id": "relationship--c0e4beff-6773-4b6a-8aec-41d81d9f8c9c",
3109c3109
<             "id": "relationship--659d139a-8a32-4d26-8a8f-e8cee559a0e8",
---
>             "id": "relationship--7fb45641-3d93-439d-8085-4f823291e353",
3119c3119
<             "id": "relationship--c9f533a7-369a-45d2-bc88-c6a0c2ca3a7a",
---
>             "id": "relationship--2069013b-fc74-43ef-ad73-2693240498d9",
3129c3129
<             "id": "relationship--26473484-56e9-489b-902e-26ac2a148a38",
---
>             "id": "relationship--05291526-4318-4903-941c-5a6d78739948",
3139c3139
<             "id": "relationship--593f45ff-58f0-48b0-b221-c68ed21ecb94",
---
>             "id": "relationship--b4e9aab5-7fef-47c8-9ad8-575fdf31924c",
3149c3149
<             "id": "relationship--9885973b-332d-4ac5-bd5c-239efdd18d5b",
---
>             "id": "relationship--e8345eb4-0bc0-4f16-ad2b-25db14ba24f3",
3159c3159
<             "id": "relationship--5cf63ed7-993b-441a-9922-77d7fc112a43",
---
>             "id": "relationship--e7617d5b-80d5-4274-8f40-f2242f53792b",
3169c3169
<             "id": "relationship--113a42ce-1776-45f4-90ac-995ca708f242",
---
>             "id": "relationship--a6ce405e-0f35-4b96-8e59-57423358745b",
3179c3179
<             "id": "relationship--6a739018-3dd1-4624-8993-713d6f755822",
---
>             "id": "relationship--75e2f8c2-393d-417c-bba6-f30b6cd11b16",
3189c3189
<             "id": "relationship--4b24ba28-2021-4d15-a223-de563ee48d59",
---
>             "id": "relationship--75b0f157-8cc6-4dd9-961b-50d2b4211c9c",
3199c3199
<             "id": "relationship--744eb9c6-1340-4cef-b4de-13f20e07c9b2",
---
>             "id": "relationship--08221765-798f-48a4-8306-536ca24a0571",
3209c3209
<             "id": "relationship--92f55577-b7cb-4367-8526-d996367879ff",
---
>             "id": "relationship--ea2e071a-52a3-4451-a510-66c8fc8fb486",
3219c3219
<             "id": "relationship--dc09a07e-3794-43eb-b299-380beb5e2ef9",
---
>             "id": "relationship--2c94894c-de37-45b8-914e-a809633202d5",
3229c3229
<             "id": "relationship--363200f4-ba48-4d4c-88c9-179583a03799",
---
>             "id": "relationship--8875b10b-d9ed-495b-b92b-5ab0b38bad3d",
3239c3239
<             "id": "relationship--d8f3dc90-e98c-4b59-94a4-bbb0163cb4a9",
---
>             "id": "relationship--1e393e30-baa1-4986-9d8d-16651566e674",
3249c3249
<             "id": "relationship--ca6607e2-2da2-4c0a-85a2-9767758a8e0b",
---
>             "id": "relationship--30d873df-a7ec-4477-8c5a-d2b79e9d262a",
3259c3259
<             "id": "relationship--edd303d9-996f-4b18-8663-69090d3be57a",
---
>             "id": "relationship--9f38413d-4cb3-43c7-b5b4-183bbdaec4d4",
3269c3269
<             "id": "relationship--2029aa00-2f4b-4f43-a78b-6cf22559bf3c",
---
>             "id": "relationship--e7346590-cf21-42ac-8dd3-92c585ced616",
3279c3279
<             "id": "relationship--378d696b-f386-402b-a76d-c9c0db297d1c",
---
>             "id": "relationship--cc947fd7-2da1-4bf6-8071-e5c804125ecc",
3289c3289
<             "id": "relationship--5f0400b0-4da1-4438-aae6-f392d8529583",
---
>             "id": "relationship--95ab1a0f-d5e8-4054-ae1d-7dad38eeddad",

This was run on Python 3.11 with the below environment:

antlr4-python3-runtime==4.9.3
certifi==2025.1.31
charset-normalizer==3.4.1
cybox==2.1.0.21
Deprecated==1.2.18
idna==3.10
lxml==5.3.1
maec==4.1.0.17
misp-lib-stix2==3.0.1.2
misp-stix==2025.2.14
mixbox==1.0.5
ordered-set==4.1.0
publicsuffixlist==1.0.2.20250213
pymisp==2.5.4
python-dateutil==2.9.0.post0
pytz==2025.1
requests==2.32.3
simplejson==3.20.1
six==1.17.0
stix==1.2.0.11
stix-edh==1.0.3
stix2-patterns==2.0.0
urllib3==2.3.0
weakrefmethod==1.0.3
wrapt==1.17.2

Code of Conduct

  • I agree to follow this project's Code of Conduct
gopackgo90 added a commit to gopackgo90/misp-stix that referenced this issue Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant