Skip to content

Commit 2a2fd05

Browse files
authored
BUG: $lib.stix.import.ingest missing toprim on bundle (SYN-6749) (#3495)
1 parent 340996a commit 2a2fd05

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

synapse/lib/stormlib/stix.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,7 @@ async def ingest(self, bundle, config=None):
872872
if config is None:
873873
config = stixingest
874874

875+
bundle = await s_stormtypes.toprim(bundle)
875876
config = await s_stormtypes.toprim(config)
876877

877878
config.setdefault('bundle', {})

synapse/tests/test_lib_stormlib_stix.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,16 @@ async def test_stix_import(self):
333333
viewiden = await core.callStorm('return($lib.view.get().fork().iden)')
334334
stix = s_common.yamlload(self.getTestFilePath('stix_import', 'oasis-example-00.json'))
335335
msgs = await core.stormlist('yield $lib.stix.import.ingest($stix)', opts={'view': viewiden, 'vars': {'stix': stix}})
336+
# self.stormHasNoWarnErr(msgs)
337+
self.len(1, await core.nodes('ps:contact:name="adversary bravo"', opts={'view': viewiden}))
338+
self.len(1, await core.nodes('it:prod:soft', opts={'view': viewiden}))
339+
340+
# Pass in a heavy dict object
341+
viewiden = await core.callStorm('return($lib.view.get().fork().iden)')
342+
stix = s_common.yamlload(self.getTestFilePath('stix_import', 'oasis-example-00.json'))
343+
q = '''init { $data = ({"id": $stix.id, "type": $stix.type, "objects": $stix.objects}) }
344+
yield $lib.stix.import.ingest($data)'''
345+
msgs = await core.stormlist(q, opts={'view': viewiden, 'vars': {'stix': stix}})
336346
self.len(1, await core.nodes('ps:contact:name="adversary bravo"', opts={'view': viewiden}))
337347
self.len(1, await core.nodes('it:prod:soft', opts={'view': viewiden}))
338348

0 commit comments

Comments
 (0)