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

Fix the memory store to support the new top-level 2.1 SCOs. #342

Merged
merged 2 commits into from
Feb 14, 2020

Conversation

chisholm
Copy link
Contributor

Fixes #340 .

Checking whether an object is unversioned had been done via a marking check. But the marking check was really just a proxy to determining what we really wanted to know: whether the object was versioned. In hindsight, maybe that wasn't the best way to have done it, because it means that the new 2.1 SCOs are treated as versioned. (Although SCOs weren't TLOs at the time that code was written, so it wasn't wrong to have done it that way.)

I changed the check so it is done in a better way: if an object has the modified property, it is versioned. This should treat all current object types correctly. That doesn't work when you only have an ID, which is the case when you need to look up an object by ID (applicable to read operations). So that is also changed to simply react to the way the bookkeeping was set up for that ID when the object was added. If the ID was mapped to an _ObjectFamily, it is versioned; otherwise not. So marking checks are entirely removed from the implementation now.

Also added some unit tests for unversioned STIX objects.

@codecov-io
Copy link

Codecov Report

Merging #342 into master will decrease coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #342      +/-   ##
==========================================
- Coverage   98.17%   98.13%   -0.04%     
==========================================
  Files         124      124              
  Lines       14168    13868     -300     
==========================================
- Hits        13909    13609     -300     
  Misses        259      259
Impacted Files Coverage Δ
stix2/test/v21/test_datastore_memory.py 100% <100%> (ø) ⬆️
stix2/test/v20/test_datastore_memory.py 100% <100%> (ø) ⬆️
stix2/datastore/memory.py 100% <100%> (ø) ⬆️
stix2/datastore/filesystem.py 92.88% <0%> (-0.12%) ⬇️
stix2/patterns.py 98% <0%> (-0.02%) ⬇️
stix2/test/v21/test_datastore_filesystem.py 99.17% <0%> (-0.02%) ⬇️
stix2/test/v20/test_datastore_filesystem.py 99.19% <0%> (-0.02%) ⬇️
stix2/test/v21/test_relationship.py 100% <0%> (ø) ⬆️
stix2/test/v20/test_campaign.py 100% <0%> (ø) ⬆️
stix2/test/v21/test_core.py 100% <0%> (ø) ⬆️
... and 60 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fdb00c4...be52748. Read the comment docs.

Copy link
Contributor

@clenk clenk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@clenk clenk merged commit 8aca39a into oasis-open:master Feb 14, 2020
@emmanvg emmanvg added this to the 1.3.1 milestone Feb 14, 2020
@chisholm chisholm deleted the sco_tlo_memorystore branch February 14, 2020 20:33
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

Successfully merging this pull request may close these issues.

Adding SCO to the MemoryStore results in error
4 participants