Detection as Code: Managing Detection Rules in Git

Detection as Code starts with a question or behavior to identify, continues to telemetry and logic definition, and concludes with testing, tuning, documentation, and controlled deployment. Quality is measured by coverage and investigative capability.
Threat Hunting and Detection Engineering translate knowledge about adversary behavior into measurable questions, data sources, and detection rules. The goal is not to generate more alerts, but to improve coverage and decision quality. This article focuses on Detection as Code and is intended for advanced Detection and SOC teams. The aim is to provide a working methodology that can be applied in practice, during professional interviews, and in a work environment, without settling for a dictionary definition.
The main challenge is that data is almost always incomplete. A repository, pull request, and lint can indicate a direction, but their meaning depends on time, asset, user, and expected activity. Therefore, we will build the test around an investigative question, required evidence, and clear completion criteria.
The practical scenario in the article is: a sample Repository structure without malicious code. All examples are laboratory data or descriptions of processes. When dealing with Penetration Testing, Web, or Cloud, work only with explicit authorization, defined Scope, and the ability to stop the test.




