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

Adding SCO to the MemoryStore results in error #340

Closed
emmanvg opened this issue Feb 12, 2020 · 1 comment · Fixed by #342
Closed

Adding SCO to the MemoryStore results in error #340

emmanvg opened this issue Feb 12, 2020 · 1 comment · Fixed by #342
Labels
Milestone

Comments

@emmanvg
Copy link
Contributor

emmanvg commented Feb 12, 2020

Below an example of how to trigger the problem:

from stix2.v21 import observables
from stix2 import MemoryStore

mem_store = MemoryStore()

file_observable = observables.File(
    name="example.exe",
    size=68 * 1000,
    magic_number_hex="50000000",
    hashes={
        "SHA-256": "841a8921140aba50671ebb0770fecc4ee308c4952cfeff8de154ab14eeef4649"
    }
)

mem_store.add(file_observable)

I obtain the following traceback:

Traceback (most recent call last):
  File "C:/Users/user-1/example_project/mem_store.py", line 98, in <module>
    example()
  File "C:/Users/user-1/example_project/mem_store.py", line 94, in example
    mem_store.add(file_observable)
  File "C:\Users\user-1\venv\lib\site-packages\stix2\datastore\__init__.py", line 216, in add
    return self.sink.add(*args, **kwargs)
  File "C:\Users\user-1\venv\lib\site-packages\stix2\datastore\memory.py", line 185, in add
    _add(self, stix_data, self.allow_custom, version)
  File "C:\Users\user-1\venv\lib\site-packages\stix2\datastore\memory.py", line 62, in _add
    obj_family.add(stix_obj)
  File "C:\Users\user-1\venv\lib\site-packages\stix2\datastore\memory.py", line 77, in add
    self.all_versions[obj["modified"]] = obj
  File "C:\Users\user-1\venv\lib\site-packages\stix2\base.py", line 195, in __getitem__
    return self._inner[key]
KeyError: 'modified'
@emmanvg emmanvg added the bug label Feb 12, 2020
@chisholm
Copy link
Contributor

Looks like the error is in version-related code which is trying to access the modified property. 2.1 SCO's don't have that property. Obviously that code was written before 2.1 SCOs became TLOs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants