Skip to main content

Aristotle

Aristotle is a simple Python program that allows for the filtering and modifying of Suricata and Snort rulesets based on interpreted key-value pairs present in the metadata keyword within each rule. It can be run as a standalone script or utilized as a module.

docs/_static/aristotle.png

Documentation

https://aristotle-py.readthedocs.io/

Application Overview

Aristotle takes in a ruleset and can provide statistics on the included metadata keys. If a filter string is provided, it will also be applied against the ruleset and the filtered ruleset outputted.

Aristotle also offers the ability to intelligently process rules to extract, enrich, and add metadata to them. After initial filtering, rules can additionally undergo “Post Filter Modification” which can modify them based on user-defined criteria, to help ensure the resulting rules in the ruleset are enabled, configured, and optimized for the target environment.

Aristotle is compatible with Python 2.7 and Python 3.x.

In order for Aristotle to be most useful, it should be provided a ruleset that has rules with the metadata keyword populated with appropriate key-value pairs. Aristotle assumes that the provided ruleset conforms to the BETTER Schema.

Setup

Install dependencies:

pip install -r requirements.txt

Or if using as a module:

pip install aristotle

And refer to Aristotle as a Module.

Usage

usage: aristotle.py [-h] -r RULES [-f METADATA_FILTER]
                    [--summary [DISPLAY_MAX]] [-o OUTFILE]
                    [-s [STATS [STATS ...]]] [-i] [-c] [-n] [-e] [-t] [-g]
                    [-m] [-p PFMOD_FILE] [-q] [-d]

Filter Suricata and Snort rulesets based on metadata keyword values.

optional arguments:
  -h, --help            show this help message and exit
  -r RULES, --rules RULES, --ruleset RULES
                        path to a rules file, a directory containing '.rules'
                        file(s), or string containing the ruleset
  -f METADATA_FILTER, --filter METADATA_FILTER
                        Boolean filter string or path to a file containing it
  --summary [DISPLAY_MAX]
                        output a summary of the filtered ruleset to stdout,
                        limited to DISPLAY_MAX number of lines (or 16 if no
                        value given); if the option to output to a file is
                        set, the full, filtered ruleset will still be written.
  -o OUTFILE, --output OUTFILE
                        output file to write filtered ruleset to
  -s [STATS [STATS ...]], --stats [STATS [STATS ...]]
                        display ruleset statistics about specified key(s). If
                        no key(s) supplied, then summary statistics for all
                        keys will be displayed.
  -i, --enable-all-rules, --enable-all, --include-disabled
                        enable all valid rules, including those
                        disabled/commented out in the given rules file(s),
                        when applying the filter
  -c, --output-disabled-rules
                        include disabled rules in the output as commented out
                        lines.
  -n, --normalize, --better, --iso8601
                        try to convert date and cve related metadata values to
                        conform to the BETTER schema for filtering and
                        statistics. Dates are normalized to the format YYYY-
                        MM-DD and CVEs to YYYY-<num>. Also, 'sid' is removed
                        from the metadata.
  -e, --enhance         enhance metadata by adding additional key-value pairs
                        based on the rules.
  -t, --ignore-classtype, --ignore-classtype-keyword
                        don't incorporate the 'classtype' keyword and value
                        from the rule into the metadata structure for
                        filtering and reporting.
  -g, --ignore-filename
                        don't incorporate the 'filename' keyword (filename of
                        the rules file) into the metadata structure for
                        filtering and reporting.
  -m, --modify-metadata
                        modify the rule metadata keyword value on output to
                        contain the internally tracked and normalized metadata
                        data.
  -p PFMOD_FILE, --pfmod PFMOD_FILE, --pfmod-file PFMOD_FILE
                        YAML file of directives to apply actions on post-
                        filtered rules based on filter strings.
  -q, --quiet, --suppress_warnings
                        quiet; suppress warning logging
  -d, --debug           turn on debug logging

A filter string defines the desired outcome based on Boolean logic, and uses
the metadata key-value pairs as values in a (concrete) Boolean algebra.
The key-value pair specifications must be surrounded by double quotes.
Example:

python3 aristotle/aristotle.py -r examples/example.rules --summary -n
-f '(("priority high" AND "malware <ALL>") AND "created_at >= 2018-01-01")
AND NOT ("protocols smtp" OR "protocols pop" OR "protocols imap") OR "sid 80181444"'

Testing

Install the development dependencies and run the test suite with pytest:

pip install -r requirements-dev.txt
pytest
pytest --cov   # with coverage report

Tests that load the large examples/example.rules file are marked examples and can be skipped with pytest -m "not examples". Benchmarks (marked slow) are skipped unless pytest --run-slow -s is used; they print load and filter timings that can be compared before and after performance changes.

License

Aristotle is licensed under the Apache License, Version 2.0.

Authors

  • David Wharton

Metadata

Release files for aristotle 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aristotle 2.2.0
File Size Uploaded Provenance
aristotle-2.2.0.tar.gz 58.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for aristotle 2.2.0
File Interpreter ABI Platform
aristotle-2.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 88.6 kB

Release files / aristotle-2.2.0.tar.gz

Download URL aristotle-2.2.0.tar.gz
Size 58.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7abcb6726a2ad4f056d37af36b6e7b52b419b82986b33be3607f5bc83977c7b8
BLAKE2b-256 checksum
How to use checksums
47c015ab7d588284a2c176e03c58e326d80712abccf33b7f2f8d4ca294de37e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10

Release files / aristotle-2.2.0-py3-none-any.whl

Download URL aristotle-2.2.0-py3-none-any.whl
Size 30.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2607ea511dc54218c6d2eac4f8bf32ae439fac63f831e5e4405225faeab02f40
BLAKE2b-256 checksum
How to use checksums
73f7cdaf531a986d044c51bf9cadb2505a1e4f5894ae281e87389da1f43fb237
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10

Security for aristotle 2.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page