Skip to content

Commit dc143b4

Browse files
committed
Fix AIS parsing and register extension errors.
1 parent 7057b97 commit dc143b4

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

stix/extensions/marking/ais.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class NotProprietary(stix.Entity):
5555
_namespace = 'http://www.us-cert.gov/STIXMarkingStructure#AISConsentMarking-2'
5656

5757
cisa_proprietary = fields.TypedField("CISA_Proprietary")
58-
ais_consent = fields.TypedField("AISConsent", AISConsentType)
59-
tlp_marking = fields.TypedField("TLPMarking", TLPMarkingType)
58+
ais_consent = fields.TypedField("AISConsent", AISConsentType, key_name="ais_consent")
59+
tlp_marking = fields.TypedField("TLPMarking", TLPMarkingType, key_name="tlp_marking")
6060

6161
def __init__(self, cisa_proprietary='false', ais_consent=None,
6262
tlp_marking=None):
@@ -73,8 +73,8 @@ class IsProprietary(stix.Entity):
7373
_namespace = 'http://www.us-cert.gov/STIXMarkingStructure#AISConsentMarking-2'
7474

7575
cisa_proprietary = fields.TypedField("CISA_Proprietary")
76-
ais_consent = fields.TypedField("AISConsent", AISConsentType)
77-
tlp_marking = fields.TypedField("TLPMarking", TLPMarkingType)
76+
ais_consent = fields.TypedField("AISConsent", AISConsentType, key_name="ais_consent")
77+
tlp_marking = fields.TypedField("TLPMarking", TLPMarkingType, key_name="tlp_marking")
7878

7979
def __init__(self, cisa_proprietary='true', ais_consent=None,
8080
tlp_marking=None):
@@ -97,6 +97,7 @@ class AISMarkingStructure(MarkingStructure):
9797

9898
def __init__(self, is_proprietary=None, not_proprietary=None):
9999
super(AISMarkingStructure, self).__init__()
100+
100101
self.is_proprietary = is_proprietary
101102
self.not_proprietary = not_proprietary
102103

@@ -108,11 +109,11 @@ def __init__(self, is_proprietary=None, not_proprietary=None):
108109

109110
def _update_namespaces():
110111
# Update the python-stix namespace dictionary
111-
import stix.utils.nsparser as nsparser
112+
from stix.utils import nsparser
112113
import mixbox.namespaces
113114

114-
nsparser.STIX_NAMESPACES.add_namespace(NAMESPACES)
115-
mixbox.namespaces.register_namespace(NAMESPACES)
115+
nsparser.STIX_NAMESPACES.add_namespace(NAMESPACES[0])
116+
mixbox.namespaces.register_namespace(NAMESPACES[0])
116117

117118

118119
_update_namespaces()
@@ -211,7 +212,7 @@ def add_ais_marking(stix_package, proprietary, consent, color, **kwargs):
211212
212213
Note:
213214
The following line is required to register the AIS extension:
214-
>>> import stix.bindings.extensions.marking.ais
215+
>>> import stix.extensions.marking.ais
215216
216217
Any Markings under STIX Header will be removed. Please follow the
217218
guidelines for `AIS`_.

stix/test/extensions/marking/ais.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,9 @@ def test_add_ais_marking(self):
8484
admin_area_name_code_type='ISO 3166-2',
8585
organisation_name='NCCIC')
8686

87+
def test_bad_values_raises_error(self):
88+
self.assertRaises(ValueError, ais.TLPMarkingType, "ORANGE")
89+
self.assertRaises(ValueError, ais.AISConsentType, "WHAT?")
90+
8791
if __name__ == "__main__":
8892
unittest.main()

0 commit comments

Comments
 (0)