Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VocabString class lookup failures #266

Closed
bworrell opened this issue Jun 3, 2015 · 0 comments
Closed

VocabString class lookup failures #266

bworrell opened this issue Jun 3, 2015 · 0 comments

Comments

@bworrell
Copy link
Contributor

bworrell commented Jun 3, 2015

If I try to parse an input document with a custom CV without registering a VocabString class for it, I get a parse error. This is on python-stix 1.2.0.1.dev0.

My foobar:FooVocab-1.0 instance below causes problems, but shouldn't.

<stix:STIX_Package 
    xmlns:coa="http://stix.mitre.org/CourseOfAction-1"
    xmlns:cybox="http://cybox.mitre.org/cybox-2"
    xmlns:cyboxCommon="http://cybox.mitre.org/common-2"
    xmlns:cyboxVocabs="http://cybox.mitre.org/default_vocabularies-2"
    xmlns:example="http://example.com"
    xmlns:incident="http://stix.mitre.org/Incident-1"
    xmlns:stix="http://stix.mitre.org/stix-1"
    xmlns:stixCommon="http://stix.mitre.org/common-1"
    xmlns:stixVocabs="http://stix.mitre.org/default_vocabularies-1"
    xmlns:foobar="a:testing:namespace"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="example:Package-73ce966d-52d2-4092-af41-114e45721814" version="1.2" timestamp="2015-06-02T20:21:54.139127+00:00">
    <stix:Incidents>
        <stix:Incident id="example:incident-b44bc002-4f4c-4dea-ab8b-2dbef815d016" timestamp="2015-06-02T20:21:54.139254+00:00" xsi:type='incident:IncidentType'>
            <incident:Title>Breach</incident:Title>
            <incident:COA_Requested>
                <incident:Course_Of_Action id="example:coa-9b5c8e6f-c7e4-45dc-812e-098d455bf023" timestamp="2015-06-02T20:21:54.139444+00:00" xsi:type='coa:CourseOfActionType'>
                    <coa:Title>Monitor activity related to known compromised accounts</coa:Title>
                    <coa:Type xsi:type="foobar:FooVocab-1.0">THIS SHOULD BE FINE</coa:Type>
                    <coa:Objective>
                        <coa:Description>This will further our investigation into the intruders who are re-using compromised accounts.</coa:Description>
                    </coa:Objective>
                </incident:Course_Of_Action>
            </incident:COA_Requested>
        </stix:Incident>
    </stix:Incidents>
</stix:STIX_Package>

Parse output:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "stix/core/stix_package.py", line 508, in from_xml
    return entity_parser.parse_xml(xml_file, encoding=encoding)
  File "stix/utils/parser.py", line 259, in parse_xml
    stix_package = STIXPackage().from_obj(stix_package_obj)
  File "stix/core/stix_package.py", line 455, in from_obj
    return_obj.incidents = Incidents.from_obj(obj.Incidents)
  File "stix/base.py", line 384, in from_obj
    return_obj.append(contained_type.from_obj(item))
  File "stix/incident/__init__.py", line 530, in from_obj
    return_obj.coa_requested = _COAsRequested.from_obj(obj.COA_Requested)
  File "stix/base.py", line 497, in from_obj
    return cls(items)
  File "stix/base.py", line 530, in __init__
    TypedCollection.__init__(self, *args)
  File "stix/base.py", line 440, in __init__
    self._initialize_inner(*args)
  File "stix/base.py", line 539, in _initialize_inner
    self.extend(arg)
  File "/home/bworrell/.virtualenvs/python-stix/lib/python2.7/_abcoll.py", line 669, in extend
    for v in values:
  File "stix/base.py", line 496, in <genexpr>
    items = (contained_type.from_obj(x) for x in obj_list)
  File "stix/incident/coa.py", line 124, in from_obj
    super(COARequested, cls).from_obj(obj, return_obj=return_obj)
  File "stix/incident/coa.py", line 61, in from_obj
    return_obj.course_of_action = CourseOfAction.from_obj(obj.Course_Of_Action)
  File "stix/coa/__init__.py", line 209, in from_obj
    return_obj.type_ = VocabString.from_obj(obj.Type)
  File "stix/common/vocabs.py", line 108, in from_obj
    klass = stix.lookup_extension(vocab_obj.xsi_type, default=cls)
  File "stix/__init__.py", line 79, in lookup_extension
    return _lookup_extension(typeinfo)
  File "stix/__init__.py", line 51, in _lookup_extension
    raise ValueError("Unregistered xsi:type %s" % xsi_type)
ValueError: Unregistered xsi:type foobar:FooVocab-1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant