From d18efed25345002c778d39cdff3e8e2cc4aadba5 Mon Sep 17 00:00:00 2001 From: epiphyte Date: Tue, 16 Jan 2024 19:22:54 +0000 Subject: [PATCH] BUG: $lib.stix.import.ingest missing toprim on bundle (SYN-6749) --- synapse/lib/stormlib/stix.py | 1 + synapse/tests/test_lib_stormlib_stix.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/synapse/lib/stormlib/stix.py b/synapse/lib/stormlib/stix.py index 4626602a97..33c7cf259a 100644 --- a/synapse/lib/stormlib/stix.py +++ b/synapse/lib/stormlib/stix.py @@ -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', {}) diff --git a/synapse/tests/test_lib_stormlib_stix.py b/synapse/tests/test_lib_stormlib_stix.py index 5d82ae9c87..c4a090c536 100644 --- a/synapse/tests/test_lib_stormlib_stix.py +++ b/synapse/tests/test_lib_stormlib_stix.py @@ -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}))