From b613add07df4f8c31ac18b2902c2fba74fcdfa06 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 16 Apr 2024 12:16:05 -0400 Subject: [PATCH] Fix styling --- stix2/properties.py | 4 ++-- stix2/test/v21/test_datastore_relational_db.py | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/stix2/properties.py b/stix2/properties.py index 55358d41..f8e79ac9 100644 --- a/stix2/properties.py +++ b/stix2/properties.py @@ -746,7 +746,7 @@ def __init__(self, allowed, **kwargs): def clean(self, value, allow_custom, strict=False): cleaned_value, _ = super(OpenVocabProperty, self).clean( - value, allow_custom, strict + value, allow_custom, strict, ) # Disabled: it was decided that enforcing this is too strict (might @@ -755,7 +755,7 @@ def clean(self, value, allow_custom, strict=False): # if strict is True: has_custom = cleaned_value not in self.allowed - + if not allow_custom and has_custom: raise CustomContentError( "custom value in open vocab: '{}'".format(cleaned_value), diff --git a/stix2/test/v21/test_datastore_relational_db.py b/stix2/test/v21/test_datastore_relational_db.py index 39524ac0..8003843b 100644 --- a/stix2/test/v21/test_datastore_relational_db.py +++ b/stix2/test/v21/test_datastore_relational_db.py @@ -8,7 +8,7 @@ "postgresql://postgres:admin@localhost/postgres", False, None, - True + True, ) # Artifacts @@ -56,6 +56,7 @@ def test_encrypted_artifact(): continue assert encrypted_artifact_dict[attrib] == read_obj[attrib] + # Autonomous System as_dict = { "type": "autonomous-system", @@ -76,6 +77,7 @@ def test_autonomous_system(): for attrib in as_dict.keys(): assert as_dict[attrib] == read_obj[attrib] + # Directory directory_dict = { "type": "directory", @@ -106,6 +108,7 @@ def test_directory(): continue assert directory_dict[attrib] == read_obj[attrib] + # Domain Name domain_name_dict = { "type": "domain-name", @@ -115,7 +118,7 @@ def test_directory(): } -def test_autonomous_system(): +def test_domain_name(): store.sink.generate_stix_schema() domain_name_obj = stix2.parse(domain_name_dict) store.add(domain_name_obj) @@ -124,6 +127,7 @@ def test_autonomous_system(): for attrib in domain_name_dict.keys(): assert domain_name_dict[attrib] == read_obj[attrib] + # Email Address email_addr_dict = { "type": "email-addr", @@ -144,6 +148,7 @@ def test_email_addr(): for attrib in email_addr_dict.keys(): assert email_addr_dict[attrib] == read_obj[attrib] + # Email Message email_msg_dict = { "type": "email-message", @@ -255,6 +260,7 @@ def test_multipart_email_msg(): continue assert multipart_email_msg_dict[attrib] == read_obj[attrib] + # File # errors when adding magic_number_hex to store, so ignoring for now file_dict = { @@ -294,6 +300,7 @@ def test_file(): continue assert file_dict[attrib] == read_obj[attrib] + # ipv4 ipv6 ipv4_dict = { "type": "ipv4-addr", @@ -329,6 +336,7 @@ def test_ipv6(): for attrib in ipv6_dict.keys(): assert ipv6_dict[attrib] == read_obj[attrib] + # Mutex mutex_dict = { "type": "mutex", @@ -347,6 +355,7 @@ def test_mutex(): for attrib in mutex_dict.keys(): assert mutex_dict[attrib] == read_obj[attrib] + # Network Traffic # ipfix property results in a unconsumed value error with the store add network_traffic_dict = { @@ -392,6 +401,7 @@ def test_network_traffic(): continue assert network_traffic_dict[attrib] == read_obj[attrib] + # Process process_dict = { "type": "process", @@ -434,6 +444,7 @@ def test_process(): continue assert process_dict[attrib] == read_obj[attrib] + # Software software_dict = { "type": "software", @@ -481,6 +492,7 @@ def test_url(): for attrib in url_dict.keys(): assert url_dict[attrib] == read_obj[attrib] + # User Account user_account_dict = { "type": "user-account", @@ -519,6 +531,7 @@ def test_user_account(): continue assert user_account_dict[attrib] == read_obj[attrib] + # Windows Registry windows_registry_dict = { "type": "windows-registry-key", @@ -559,6 +572,7 @@ def test_windows_registry(): continue assert windows_registry_dict[attrib] == read_obj[attrib] + # x509 Certificate basic_x509_certificate_dict = { "type": "x509-certificate",