Skip to main content

detection-rules-esql-py

CI Python uv Ruff Version License

Python parser and AST for ES|QL, Elasticsearch’s piped query language.

detection-rules-esql-py parses and checks ES|QL offline — syntax, stack-version feature gates, nested KQL() / EQL(), schema and type checks, and helpers for fields, sources, and rule shape — without sending the query to a cluster.

Elastic Security uses it to validate detection-rules.

Install

pip install detection-rules-esql-py

Quick start

import esql

# Prefer a Python triple-quoted string so ES|QL "..." values need no \" escapes.
tree = esql.parse_query("""
FROM logs-* METADATA _id, _version, _index
| WHERE event.category == "process"
| KEEP @timestamp, host.name, _id, _version, _index
""")
print(esql.get_from_sources(tree))
print(esql.get_unique_fields(tree))

# When the ES|QL string itself contains quotes, use ES|QL's """ delimiter
# (wrap the Python string in '''...''' so the delimiters do not collide):
tree = esql.parse_query('''ROW name = """Indiana "Indy" Jones"""''')

Documentation

Doc Contents
docs/maintaining.md Grammar and definitions sync
docs/detection-rules-integration.md How Elastic Security detection-rules uses the package
CHANGELOG.md Release notes
SUPPORT.md How to get help
CODE_OF_CONDUCT.md Elastic Community Code of Conduct
CONTRIBUTING.md Development setup and PR checklist

Development

git clone git@github.com:elastic/detection-rules-esql-py.git
cd detection-rules-esql-py
uv sync                 # creates .venv + installs package + ruff/pytest
make ci                 # lint + check-generated + test

Grammar maintenance:

make update-window      # sync + generate + check-generated
make ci

Requires uv (brew install uv or see Astral’s install docs).

License

Elastic License 2.0 — see LICENSE.txt.

Metadata

Release files for detection-rules-esql-py 0.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 detection-rules-esql-py 0.2.0
File Size Uploaded Provenance Actions
detection_rules_esql_py-0.2.0.tar.gz 432.2 kB Without provenance Details for detection_rules_esql_py-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for detection-rules-esql-py 0.2.0
File Interpreter ABI Platform Actions
detection_rules_esql_py-0.2.0-py3-none-any.whl Python 3 none any Details for detection_rules_esql_py-0.2.0-py3-none-any.whl

Total release size: 867.2 kB

Release files / detection_rules_esql_py-0.2.0.tar.gz

Download URL detection_rules_esql_py-0.2.0.tar.gz
Size 432.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1a59fb5209e66ac08e8b110a6e619cc819a857516dabf9c8141f4579e7fe1a34
BLAKE2b-256 checksum
How to use checksums
37e6168ff3342c6a367a834c5a1046ce0d3d97ffcb406672c46e120612e97bcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / detection_rules_esql_py-0.2.0-py3-none-any.whl

Download URL detection_rules_esql_py-0.2.0-py3-none-any.whl
Size 435.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6c800f112a6e99dc0e1a94333a72eb0f5422bba203972dcf18f05286136075f
BLAKE2b-256 checksum
How to use checksums
e321d79052d97fc8cc0c149e5a40df1cde960c96b22a6e6a2d57e758675c33dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for detection-rules-esql-py 0.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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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