back to home

elastic / detection-rules

2,524 stars
635 forks
192 issues
PythonShellMakefile

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing elastic/detection-rules in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/elastic/detection-rules)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

Detection Rules 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 Security’s Detection Engine. This repository was first announced on Elastic's blog post, Elastic Security opens public detection rules repo. For additional content, see the accompanying webinar, Elastic Security: Introducing the public repository for detection rules. Table of Contents • Detection Rules • Table of Contents • Overview of this repository • Getting started • How to contribute • Detections as Code (DaC) • RTAs • Licensing • Questions? Problems? Suggestions? Overview of this repository Detection Rules contains more than just static rule files. This repository also contains code for building Detections-as-code pipelines, unit testing in Python and integrating with the Detection Engine in Kibana. | folder | description | |------------------------------------------------ |------------------------------------------------------------------------------------ | | | Python module for rule parsing, validating and packaging | | | Miscellaneous files, such as ECS and Beats schemas and configuration files | | | Root directory where threat hunting package and queries are stored | | | Python library for handling the API calls to Kibana and the Detection Engine | | | Python library for parsing and validating Kibana Query Language | | | Root directory where rules are stored | | | Root directory where building block rules are stored | | | Python code for unit testing rules | Getting started Although rules can be added by manually creating files, we don't recommend it. This repository also consists of a python module that aids rule creation and unit testing. Assuming you have Python 3.12+, run the below command to install the dependencies using the makefile: Or install the dependencies using the following command: Note: The and packages are not available on PyPI and must be installed from the directory. The package has optional dependencies to be installed with . Remember, make sure to activate your virtual environment if you are using one. If installed via , the associated virtual environment is created in . If you are having trouble using a Python 3.12 environment, please see the relevant section in our troubleshooting guide. To confirm that everything was properly installed, run with the flag Note: • If you are using a virtual environment, make sure to activate it before running the above command. • If using Windows, you may have to also run depending on your python version. The contribution guide describes how to use the and commands to create and test a new rule when contributing to Detection Rules. For more advanced command line interface (CLI) usage, refer to the CLI guide. How to contribute We welcome your contributions to Detection Rules! Before contributing, please familiarize yourself with this repository, its directory structure, and our philosophy about rule creation. When you're ready to contribute, read the contribution guide to learn how we turn detection ideas into production rules and validate with testing. Detections as Code (DaC) The Detection Rules repo includes a number of commands to help one manage rules with an "as code" philosophy. We recommend starting with our DaC Specific Documentation for strategies and recommended setup information. However, if you would prefer to jump right in, please see our local detections as code documentation and custom rules documentation for information on how to configure this repo for use with custom rules followed by our CLI documentation for information on our commands to import and export rules. RTAs Red Team Automations (RTAs) used to emulate attacker techniques and verify the rules can be found in dedicated repository - Cortado. Licensing Everything in this repository — rules, code, etc. — is licensed under the Elastic License v2. These rules are designed to be used in the context of the Detection Engine within the Elastic Security application. If you’re using our Elastic Cloud managed service or the default distribution of the Elastic Stack software that includes the full set of free features, you’ll get the latest rules the first time you navigate to the detection engine. Occasionally, we may want to import rules from another repository that already have a license, such as MIT or Apache 2.0. This is welcome, as long as the license permits sublicensing under the Elastic License v2. We keep those license notices in and sublicense as the Elastic License v2 with all other rules. We also require contributors to sign a Contributor License Agreement before contributing code to any Elastic repositories. Questions? Problems? Suggestions? • Want to know more about the Detection Engine? Check out the overview in Kibana. • This repository includes new and updated rules that have not been released yet. To see the latest set of rules released with the stack, see the Prebuilt rule reference. • If you’d like to report a false positive or other type of bug, please create a GitHub issue and check if there's an existing one first. • Need help with Detection Rules? Post an issue or ask away in our Security Discuss Forum or the **#security-detection-rules** channel within Slack workspace. • For DaC specific cases, please see our support and scope documentation for more information.