Skip to content

Commit

Permalink
BUG: $lib.stix.import.ingest missing toprim on bundle (SYN-6749) (#3495)
Browse files Browse the repository at this point in the history
  • Loading branch information
vEpiphyte authored Jan 16, 2024
1 parent 340996a commit 2a2fd05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions synapse/lib/stormlib/stix.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ async def ingest(self, bundle, config=None):
if config is None:
config = stixingest

bundle = await s_stormtypes.toprim(bundle)
config = await s_stormtypes.toprim(config)

config.setdefault('bundle', {})
Expand Down
10 changes: 10 additions & 0 deletions synapse/tests/test_lib_stormlib_stix.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,16 @@ async def test_stix_import(self):
viewiden = await core.callStorm('return($lib.view.get().fork().iden)')
stix = s_common.yamlload(self.getTestFilePath('stix_import', 'oasis-example-00.json'))
msgs = await core.stormlist('yield $lib.stix.import.ingest($stix)', opts={'view': viewiden, 'vars': {'stix': stix}})
# self.stormHasNoWarnErr(msgs)
self.len(1, await core.nodes('ps:contact:name="adversary bravo"', opts={'view': viewiden}))
self.len(1, await core.nodes('it:prod:soft', opts={'view': viewiden}))

# Pass in a heavy dict object
viewiden = await core.callStorm('return($lib.view.get().fork().iden)')
stix = s_common.yamlload(self.getTestFilePath('stix_import', 'oasis-example-00.json'))
q = '''init { $data = ({"id": $stix.id, "type": $stix.type, "objects": $stix.objects}) }
yield $lib.stix.import.ingest($data)'''
msgs = await core.stormlist(q, opts={'view': viewiden, 'vars': {'stix': stix}})
self.len(1, await core.nodes('ps:contact:name="adversary bravo"', opts={'view': viewiden}))
self.len(1, await core.nodes('it:prod:soft', opts={'view': viewiden}))

Expand Down

0 comments on commit 2a2fd05

Please sign in to comment.