Skip to main content

Match STIX content against STIX patterns

Project description

Build_Status Coverage

cti-pattern-matcher

This is an OASIS TC Open Repository. See the Governance section for more information.

The pattern-matcher is a prototype software tool for matching STIX Observed Data content against patterns used in STIX Indicators. The matcher accepts a pattern and one or more timestamped observations, and determines whether the observations match the criteria specified by the pattern. The purpose of this tool is to evaluate examples and test cases which implement the patterning specification, as a form of executable documentation and to verify patterns express the desired criteria.

Requirements

Installation

Install with pip:

$ pip install stix2-matcher

Usage

Installing the package creates a stix2-matcher script:

$ stix2-matcher -h
usage: stix2-matcher [-h] -p PATTERNS -f FILE [-e ENCODING] [-v] [-s STIX_VERSION]

Match STIX Patterns to STIX Observed Data

optional arguments:
  -h, --help            show this help message and exit
  -p PATTERNS, --patterns PATTERNS
                        Specify a file containing STIX Patterns,
                        one per line.
  -f FILE, --file FILE  A file containing JSON list of STIX
  observed-data SDOs
                        to match against.
  -e ENCODING, --encoding ENCODING
                        Set encoding used for reading observation
                        and pattern
                        files. Must be an encoding name Python
                        understands.
                        Default is utf8.
  -v, --verbose         Be verbose
  -s STIX_VERSION, --stix_version STIX_VERSION
                       Stix specification version. Default is 2.0

Testing

The STIX Pattern Matcher’s test suite can be run with pytest.

Updating the Grammar

The ANTLR pattern grammar is maintained in the stix2-json-schemas repository. If the grammar changes, the code in this repository should be updated to match. To do so, use the Java ANTLR package to generate new Python source files. (The .jar file is not needed for normal use of the validator).

  1. Download antlr-4.7-complete.jar from http://www.antlr.org/download/

  2. Clone the stix2-json-schemas repository or download the STIXPattern.g4 file.

  3. Change to the directory containing the STIXPattern.g4 file.

  4. Run the following command

    $ java -jar "/path/to/antlr-4.7-complete.jar" -Dlanguage=Python3 STIXPattern.g4 -o /path/to/cti-pattern-matcher/stix2matcher/grammars
  5. Commit the resulting files to git.

Governance

This GitHub public repository ( https://github.com/oasis-open/cti-pattern-matcher ) was proposed and approved [bis] by the OASIS Cyber Threat Intelligence (CTI) TC as an OASIS TC Open Repository to support development of open source resources related to Technical Committee work.

While this TC Open Repository remains associated with the sponsor TC, its development priorities, leadership, intellectual property terms, participation rules, and other matters of governance are separate and distinct from the OASIS TC Process and related policies.

All contributions made to this TC Open Repository are subject to open source license terms expressed in the BSD-3-Clause License. That license was selected as the declared “Applicable License” when the TC Open Repository was created.

As documented in “Public Participation Invited”“, contributions to this OASIS TC Open Repository are invited from all parties, whether affiliated with OASIS or not. Participants must have a GitHub account, but no fees or OASIS membership obligations are required. Participation is expected to be consistent with the OASIS TC Open Repository Guidelines and Procedures, the open source LICENSE designated for this particular repository, and the requirement for an Individual Contributor License Agreement that governs intellectual property.

Maintainers

TC Open Repository Maintainers are responsible for oversight of this project’s community development activities, including evaluation of GitHub pull requests and preserving open source principles of openness and fairness. Maintainers are recognized and trusted experts who serve to implement community goals and consensus design preferences.

Initially, the associated TC members have designated one or more persons to serve as Maintainer(s); subsequently, participating community members may select additional or substitute Maintainers, per consensus agreements.

Current Maintainers of this TC Open Repository

About OASIS TC Open Repositories

Feedback

Questions or comments about this TC Open Repository’s activities should be composed as GitHub issues or comments. If use of an issue/comment is not possible or appropriate, questions may be directed by email to the Maintainer(s) listed above. Please send general questions about Open Repository participation to OASIS Staff at repository-admin@oasis-open.org and any specific CLA-related questions to repository-cla@oasis-open.org.

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

stix2-matcher-3.0.0.tar.gz (55.3 kB view details)

Uploaded Source

Built Distribution

stix2_matcher-3.0.0-py2.py3-none-any.whl (58.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file stix2-matcher-3.0.0.tar.gz.

File metadata

  • Download URL: stix2-matcher-3.0.0.tar.gz
  • Upload date:
  • Size: 55.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.10 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8

File hashes

Hashes for stix2-matcher-3.0.0.tar.gz
Algorithm Hash digest
SHA256 191e7fad2b733889ff0842c06d8f488d469de234aa8c0175b198eb69f597ccee
MD5 eebc9a3fc11f8531a51ccf98dd95611d
BLAKE2b-256 15064c97945a3e6b8708f42b7cbdbd669a0837881e3164f732db33938f3a68a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: stix2_matcher-3.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 58.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.10 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8

File hashes

Hashes for stix2_matcher-3.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 52122d0505be7c6a94371faf43febf9b42ccd6a60acb062a73e5a0507dd78bf4
MD5 cefd6f117347d0fc193cd788287c2433
BLAKE2b-256 113151b11586b939937c5c374a7538d73f8bc9d553edcc7d6fc41f0815938686

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