The stix2-validator library provides APIs and scripts for validating STIX 2.x documents against the official STIX specifications. It is currently at version 3.2.0 and receives regular updates, typically with minor releases addressing fixes and dependency updates, and less frequent major releases for specification updates and significant feature enhancements.
pip install stix2-validatorVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the `Validator` and use it to validate a STIX object represented as a Python dictionary. It shows both standard and verbose validation output. To validate a STIX document from a file, load its JSON content into a dictionary first.
Upgrade your Python environment to 3.7 or newer to use stix2-validator versions 3.0.0+.
Ensure that `request_header` values within network-traffic extension objects are provided as a list of strings, even if only one header is present (e.g., `['Host: example.com']`).
When initializing `Validator` or calling `validate()`, specify the `stix_version` parameter (e.g., `Validator(stix_version='2.0')` or `validator.validate(obj, stix_version='2.0')`) to ensure validation against the correct STIX specification version.
Upgrade `stix2-validator` to version 3.1.3 or newer, which includes fixes to address these `jsonschema` deprecation warnings by updating internal schema references.