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

Granular marking selector validation is incorrect #585

Open
chisholm opened this issue Feb 18, 2024 · 0 comments
Open

Granular marking selector validation is incorrect #585

chisholm opened this issue Feb 18, 2024 · 0 comments

Comments

@chisholm
Copy link
Contributor

Selector validation fails to validate compliant selectors. Here is an example taken from STIX 2.1 spec section 7.2.3.1:

import stix2

vuln = stix2.parse(
    {
      "id": "vulnerability--ee916c28-c7a4-4d0d-ad56-a8d357f89fef",
      "spec_version": "2.1",
      "created": "2016-02-14T00:00:00.000Z",
      "modified": "2016-02-14T00:00:00.000Z",
      "type": "vulnerability",
      "name": "CVE-2014-0160",
      "description": "The (1) TLS...",
      "external_references": [{
        "source_name": "cve",
        "external_id": "CVE-2014-0160"
      }],
      "labels": ["heartbleed", "has-logo"]
    }
)

marked_vuln = vuln.add_markings(stix2.TLP_GREEN, "external_references.[0].source_name")

This results in error:

Traceback (most recent call last):
  File "...\testx_selector_bug.py", line 42, in <module>
    marked_vuln = vuln.add_markings(stix2.TLP_GREEN, "external_references.[0].source_name")
  File "...\cti-python-stix2\stix2\markings\__init__.py", line 153, in add_markings
    return granular_markings.add_markings(obj, marking, selectors)
  File "...\cti-python-stix2\stix2\markings\granular_markings.py", line 165, in add_markings
    utils.validate(obj, selectors)
  File "...\cti-python-stix2\stix2\markings\utils.py", line 50, in validate
    raise exceptions.InvalidSelectorError(obj, s)
stix2.exceptions.InvalidSelectorError: Selector external_references.[0].source_name in Vulnerability is not valid!
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