From aa8c9a11f946d6300aa3e60029ea2136519e539f Mon Sep 17 00:00:00 2001 From: Rich Piazza Date: Tue, 10 Sep 2024 19:25:33 -0400 Subject: [PATCH] handle object-markings-refs in SMOs --- stix2/datastore/relational_db/input_creation.py | 2 +- stix2/datastore/relational_db/relational_db_testing.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/stix2/datastore/relational_db/input_creation.py b/stix2/datastore/relational_db/input_creation.py index 23cd56e6..1b859751 100644 --- a/stix2/datastore/relational_db/input_creation.py +++ b/stix2/datastore/relational_db/input_creation.py @@ -347,7 +347,7 @@ def generate_insert_for_core(data_sink, stix_object, core_properties, schema_nam insert_statements.append(core_insert_statement) if "object_marking_refs" in stix_object: - if schema_name == "sdo": + if schema_name != "sco": object_markings_ref_table = data_sink.tables_dictionary["common.object_marking_refs_sdo"] else: object_markings_ref_table = data_sink.tables_dictionary["common.object_marking_refs_sco"] diff --git a/stix2/datastore/relational_db/relational_db_testing.py b/stix2/datastore/relational_db/relational_db_testing.py index 540b5eae..b051dc86 100644 --- a/stix2/datastore/relational_db/relational_db_testing.py +++ b/stix2/datastore/relational_db/relational_db_testing.py @@ -103,6 +103,10 @@ def extension_definition_insert(): schema="a schema", version="1.2.3", extension_types=["property-extension", "new-sdo", "new-sro"], + object_marking_refs=[ + "marking-definition--caa0d913-5db8-4424-aae0-43e770287d30", + "marking-definition--122a27a0-b96f-46bc-8fcd-f7a159757e77" + ], granular_markings=[ { "lang": "en_US", @@ -168,7 +172,7 @@ def kill_chain_test(): @stix2.CustomObject('x-custom-type', properties=[ ("phases", stix2.properties.ListProperty(stix2.KillChainPhase)), - ("test", stix2.properties.IntegerProperty()) + ("something_else", stix2.properties.IntegerProperty()) ] ) class CustomClass: @@ -183,7 +187,7 @@ def custom_obj(): "phase_name": "the phase name" } ], - test=5 + something_else=5 ) return obj