Files
elastic-detection-rules/pyproject.toml
T
Mika Ayenson, PhD 1bc3dc0636 Fix stack-dependent related_integrations.version export (#6208)
* fix(integrations): emit stack-invariant OR ranges for related_integrations

Replace find_least_compatible_version with find_compatible_version_range
so prebuilt rules export the same related_integrations.version across
stack backports. Bump version.lock for rules whose export changes.

* fix(integrations): emit stack-invariant OR ranges for related_integrations

Replace find_least_compatible_version with find_compatible_version_range
so prebuilt rules export the same related_integrations.version across
stack backports. Bump pyproject.toml patch version.

Resolves #5601

* fix(integrations): satisfy ruff SIM110 in _major_has_compatible_stack

* fix(integrations): address review feedback for stack-major resolution

Iterate all majors overlapped by parsed Kibana bounds, derive legacy
stack walk versions from manifest range floors instead of 8.19.0, remove
a dead aligned-major branch, and drop RST-style double backticks in new
docstrings.

* fix(integrations): tighten stack-major overlap and anchor resolution

Walk every stack major whose band intersects a bounded Kibana clause
(e.g. >=8.12.0 <9.1.0 includes major 9) and pick the earliest compatible
stack point within a major for the legacy least-compatible walk.

* fix(integrations): annotate majors_to_check for pyright

* style(rule): apply ruff format for CI code-checks

Fix formatting on integration_name assignment that failed ruff format --check.

* fix(integrations): address PR review on version range export

Walk all stack majors for non-aligned packages, handle unbounded Kibana
ranges, restore schema comments, use immutable anchor tuples, and add
UNKNOWN_PACKAGE_INTEGRATION constant with regression tests.

* fix(integrations): anchor RI export to shipped stack backports only

Prebuilt rules ship to the stack lines in stack-schema-map, not every Kibana
major a manifest ever claimed. Filter against get_stack_versions() so dead
lines like Kibana 7.x do not pull azure 0.0.2 into related_integrations.

* refactor(integrations): simplify version range export helpers

Remove aligned-major fast path, redundant overlap checks, and dead
branches from the #5601 OR-range export. Cache shipped stack majors,
derive unbounded-range test expectations from _MAX_UNBOUNDED_STACK_MAJOR_SPAN,
and inline schema-floor fallback at its single call site.

* fix(rule): dedupe ES|QL related_integrations metadata package row

Skip the metadata-only package entry when the ES|QL query already names
a data stream for that package (e.g. azure.signinlogs). Kuery/EQL paths
are unchanged. Adds regression tests for azure signinlogs and aadgraph.

* test(integrations): drop brittle ES|QL rule-file export tests

Remove file-path-based related_integrations tests that depend on
local-only rule TOMLs and live manifest output. Keep the pure helper
coverage for _esql_metadata_package_row_needed.

* refactor(integrations): dedupe schema floor lookup and trim comments

Hoist _integration_schema_floor() to remove duplicate minimum_schema
calls in find_compatible_version_range. Shorten export-path comments
after audit; no behavior change.

* fix(integrations): walk shipped stack lines for RI anchor collection

Collect related_integrations anchors from each get_stack_versions() entry
instead of synthesizing stack-major floors (e.g. 9.0.0). AWS 5.x/6.x require
Kibana ^9.2+ and were missed, causing false version-mismatch warnings on 9.2+.

* fix(rule): dedupe NON_DATASET metadata RI rows when datasets cover package

Skip redundant related_integrations rows for endpoint, windows, and other
NON_DATASET_PACKAGES when the query already references package.* datasets.
Extends ES|QL metadata dedupe to EQL/KQL rules.
2026-06-05 17:23:45 -05:00

197 lines
5.6 KiB
TOML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
[project]
name = "detection_rules"
version = "1.6.49"
description = "Detection Rules is the home for rules used by Elastic Security. This repository is used for the development, maintenance, testing, validation, and release of rules for Elastic Securitys Detection Engine."
readme = "README.md"
requires-python = ">=3.12"
license = {file = "LICENSE.txt"}
keywords = ["Detection Rules", "Continuous Monitoring", "Data Protection", "Elastic", "Elastic Endgame", "Endpoint Security"]
classifiers = [
"Topic :: Software Development :: Build Tools",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
"Topic :: Security",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Testing",
"Topic :: Software Development",
"Topic :: Utilities"
]
dependencies = [
"Click~=8.3.0",
"elasticsearch~=8.12.1",
"eql==0.9.19",
"jsl==0.2.4",
"jsonschema>=4.21.1",
"marko==2.2.1",
"marshmallow-dataclass==8.7.1",
"marshmallow-jsonschema~=0.13.0",
"marshmallow-union~=0.1.15",
"marshmallow~=3.26.1",
"pywin32 ; platform_system=='Windows'",
# FIXME: pytoml is outdated and should not be used
"pytoml==0.1.21",
"PyYAML~=6.0.1",
"requests~=2.33.1",
"toml==0.10.2",
"typing-inspect==0.9.0",
"typing-extensions>=4.12",
"XlsxWriter~=3.2.0",
"semver==3.0.4",
"PyGithub==2.9.1",
"detection-rules-kql @ git+https://github.com/elastic/detection-rules.git#subdirectory=lib/kql",
"detection-rules-kibana @ git+https://github.com/elastic/detection-rules.git#subdirectory=lib/kibana",
"setuptools==78.1.1"
]
[project.optional-dependencies]
dev = [
"pep8-naming==0.15.1",
"flake8==7.3.0",
"pyflakes==3.4.0",
"pytest>=8.1.1",
"nodeenv==1.9.1",
"pre-commit==4.6.0",
"ruff>=0.11",
"pyright==1.1.409",
]
hunting = ["tabulate==0.10.0"]
[project.urls]
"Homepage" = "https://github.com/elastic/detection-rules"
"Bug Reports" = "https://github.com/elastic/detection-rules/issues"
"Research" = "https://www.elastic.co/security-labs"
"Elastic" = "https://www.elastic.co"
[build-system]
requires = ["setuptools", "wheel", "setuptools_scm"]
build-backend = "setuptools.build_meta"
[tool.setuptools]
package-data = {"kql" = ["*.g"]}
packages = ["detection_rules", "hunting"]
[tool.pytest.ini_options]
filterwarnings = [
"ignore::DeprecationWarning"
]
[tool.ruff]
line-length = 120
indent-width = 4
include = [
"pyproject.toml",
"detection_rules/**/*.py",
"hunting/**/*.py",
"tests/**/*.py",
]
show-fixes = true
[tool.ruff.lint]
select = [
"E", # pycodestyle
"F", # Pyflakes
"UP", # pyupgrade
"B", # flake8-bugbear
"SIM", # flake8-simplify
"I", # isort
"N", # pep8-naming
"UP", # pyupgrade
"YTT", # flake8-2020
"ANN", # flake8-annotations
"ASYNC", # flake8-async
"S", # flake8-bandit
"BLE", # flake8-blind-except
"B", # flake8-bugbear
"A", # flake8-builtins
"COM", # flake8-commas
"C4", # flake8-comprehensions
"DTZ", # flake8-datetimez
"T10", # flake8-debugger
"DJ", # flake8-django
"EM", # flake8-errmsg
"EXE", # flake8-executable
"ISC", # flake8-implicit-str-concat
"ICN", # flake8-import-conventions
"G", # flake8-logging-format
"INP", # flake8-no-pep420
"PIE", # flake8-pie
"PYI", # flake8-pyi
"PT", # flake8-pytest-style
"Q", # flake8-quotes
"RSE", # flake8-raise
"RET", # flake8-return
"SLF", # flake8-self
"SLOT", # flake8-slots
"TID", # flake8-tidy-imports
"TCH", # flake8-type-checking
"INT", # flake8-gettext
"ARG", # flake8-unused-arguments
"PTH", # flake8-use-pathlib
"TD", # flake8-todos
"FIX", # flake8-fixme
"ERA", # eradicate
"PGH", # pygrep-hooks
"PL", # Pylint
"TRY", # tryceratops
"FLY", # flynt
"PERF", # Perflint
"RUF", # Ruff-specific rules
]
ignore = [
"ANN401", # any-type
"EM101", # raw-string-in-exception
"EM102", # f-string-in-exception
"PT009", # pytest-unittest-assertion
"TRY003", # raise-vanilla-args
"N815", # mixed-case-variable-in-class-scope
"PLC0415", # import-outside-top-level, erratic behavior
"S603", # subprocess-without-shell-equals-true, prone to false positives
"COM812", # missing-trailing-comma, might cause issues with ruff formatter
]
[tool.ruff.lint.per-file-ignores]
"tests/*" = [
"ANN001", # missing-type-function-argument
"ANN002", # missing-type-args
"ANN003", # missing-type-kwargs
"ANN101", # missing-type-self
"ANN102", # missing-type-cls
"ANN201", # missing-return-type-undocumented-public-function
"ANN202", # missing-return-type-private-function
"ANN205", # missing-return-type-static-method
"ARG001", # unused-function-argument
"ANN206", # missing-return-type-class-method
"PLR2004", # magic-value-comparison
"SIM300", # yoda-conditions
"S101", # assert
"PT009", # pytest-unittest-assertion
"PT012", # pytest-raises-with-multiple-statements
"PT027", # pytest-unittest-raises-assertion
"FIX001", # line-contains-fixme
"FIX002", # line-contains-todo
# FIXME: the long static strings should be moved to the resource files
"E501", # line-too-long
# FIXME: we should avoid TODOs in the code as much as possible
"TD002", # missing-todo-author
"TD003", # missing-todo-link
]
[tool.pyright]
include = [
"detection_rules/",
"hunting/",
]
exclude = [
"tests/",
]
reportMissingTypeStubs = true
reportUnusedCallResult = "error"
typeCheckingMode = "strict"