Skip to main content

APIs and scripts for validating STIX and CybOX documents.

Project description

A Python tool and API that validates STIX and CybOX XML instance documents.

Source:

https://github.com/STIXProject/stix-validator

Documentation:

http://stix-validator.readthedocs.org

Information:

https://stixproject.github.io | https://cyboxproject.github.io

Build Status Code Health PyPI Version Badge

Validation

The STIX Document Validator (sdv) can perform the following forms of STIX document validation:

The following forms of CybOX document validation are also possible:

Dependencies

The STIX Document Validator has the following dependencies:

  • Python: Python interpreter

  • lxml >= v3.2.0: XML processing library.

    • libxml2 >= v2.9.1: Required XML processing C library for lxml.

  • xlrd >= v0.9.2: XLSX library for parsing STIX Profiles.

For a Windows installer of lxml, we recommend looking here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml

The STIX Document Validator supports Python 3.8+.

Installation

The recommended method for installing the STIX Document Validator is via pip.

$ pip install stix-validator

This will install the sdv package into your Python installation’s site-packages and four scripts found under sdv/scripts on your PATH.

How To Use

The STIX Document Validator bundles four scripts: stix_validator.py, profile_to_sch.py, profile_to_xslt.py, and cybox_validator.py,

STIX Validation

The stix_validator.py script can can validate a STIX XML document against STIX schemas, STIX Best Practices, and STIX Profiles.

NOTE: The STIX Profile validation should be considered experimental.

Validate using bundled schemas

$ stix-validator <stix_document.xml>

Validate using schemaLocation

$ stix-validator --use-schemaloc <stix_document.xml>

Validate using non-bundled schemas

$ stix-validator --schema-dir </path/to/schemas> <stix_document.xml>

NOTE: If you are trying to validate a STIX document from a checked-out copy of STIX schema repository, make sure you have also cloned the CybOX schema submodule with git submodule init and git submodule update.

Validate a directory of STIX documents

$ stix-validator </path/to/stix_dir>

Validate multiple files and/or directories

$ stix-validator <one.xml> <two.xml> <directory_of_files> ...

Check “best practice” guidance

$ stix-validator --best-practices <stix_document.xml>

Validate using STIX Profile

$ stix-validator --profile <stix_profile.xlsx> <stix_document.xml>

STIX Profile to Schematron Conversion

The profile_to_sch.py script performs a conversion from a valid STIX profile to schematron.

$ profile-to-sch <valid_stix_profile.xlsx>

Schematron output is sent to stdout.

STIX Profile to XSLT Conversion

The profile_to_xslt.py script performs a conversion from a valid STIX profile to XSLT.

$ profile-to-xslt <valid_stix_profile.xlsx>

XSLT output is sent to stdout.

CybOX Validation

The cybox_validator.py script can perform CybOX XML Schema validation.

Validate using bundled schemas

$ cybox-validator <cybox_document.xml>

Validate using schemaLocation

$ cybox-validator --use-schemaloc <cybox_document.xml>

Validate using non-bundled schemas

$ cybox-validator --schema-dir </path/to/schemas> <cybox_document.xml>

Validate a directory of CybOX documents

$ cybox-validator </path/to/cybox_dir>

Validate multiple files and/or directories

$ cybox-validator <one.xml> <two.xml> <directory_of_files> ...

All STIX and CybOX Documents?

The STIX Document Validator bundles XML schemas with it, which includes all STIX (v1.0 through v1.2.1) and CybOX (2.0 through v2.1) schema files. If a document includes instances of schematic constructs defined outside of the STIX or CybOX languages, a user must point the STIX Document Validator scripts at those schemas in order to validate.

To use schemas other than those bundled with the STIX Document Validator use the --schemas-dir flag to pass in a path to a schema directory.

Common Libxml2 Error

Users often report an error which looks something like the following:

Fatal error occurred: local union type: A type, derived by list or union, must have the
simple ur-type definition as base type, not '{http://cybox.mitre.org/common-2}(NULL)'., line 350

This error is caused by an insufficient version of libxml2 being installed on the system. The STIX Document Validator requires libxml2 v2.9.1 at a minimum and is not guaranteed to work properly with earlier versions.

To see what version of libxml2 you have installed, execute the xml2-config --version command and make sure you are running at least v2.9.1.

Terms

BY USING THE STIX DOCUMENT VALIDATOR, YOU SIGNIFY YOUR ACCEPTANCE OF THE TERMS AND CONDITIONS OF USE. IF YOU DO NOT AGREE TO THESE TERMS, DO NOT USE THE STIX DOCUMENT VALIDATOR.

For more information, please refer to the LICENSE.txt file

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stix-validator-3.0.0.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

stix_validator-3.0.0-py2.py3-none-any.whl (3.4 MB view details)

Uploaded Python 2 Python 3

File details

Details for the file stix-validator-3.0.0.tar.gz.

File metadata

  • Download URL: stix-validator-3.0.0.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.2

File hashes

Hashes for stix-validator-3.0.0.tar.gz
Algorithm Hash digest
SHA256 4c9c04e708e6b27bd2469e680dea0cc41ae0cd776066d9daf6cbd8b17c17718b
MD5 8887fbf1b702687f4c15c473dc669833
BLAKE2b-256 da3b4e6e41c1298a9a211f41e978dfad96f0a7569ab14e4b25f1f980daa62a7a

See more details on using hashes here.

File details

Details for the file stix_validator-3.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for stix_validator-3.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 224885f8bfa410060425798b86584521a32089e5366540d74bd6e02c5f0b07ce
MD5 a6f15f44ef42d8e3160eaaa5be05392a
BLAKE2b-256 bb70c6120e1d3b9a1e2a3185be2adb1247f8ed3a96ae5ab4dbac1a8e3926dafa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page