Skip to main content

Why detections exist

A finding describes one moment: this file, this commit, this vulnerability. A detection is the rule behind it, and it keeps checking forever. This is the difference between an agent that’s useful once and a platform that compounds. When an agent confirms a vulnerability, the valuable output isn’t only the fix — it’s the rule that catches the same mistake in every repository from then on, cheaply, without an agent having to re-derive it.

Detection types

CodeQL detections can be authored but are not yet executed. Only OpenGrep and policy detections have runtimes today; detections-runner stores other types and skips them with a note. The codeql-rule-creator skill and the editor’s CodeQL support exist so the rules are ready when execution lands.

OpenGrep rules

OpenGrep rules support two modes:
  • search — match a pattern. Use pattern, patterns, pattern-either, or pattern-regex.
  • taint — track data flow. Declare pattern-sources, pattern-sinks, and optionally pattern-sanitizers; a match is a source reaching a sink with nothing neutralizing it in between.
Taint mode is the one that earns its keep for security work, because it encodes reachability rather than mere presence. Rules carry a severity of INFO, WARNING, or ERROR, and OpenGrep filters by the rule’s own languages field at run time — so an irrelevant rule exits cheaply rather than wasting a pass.

Policy detections

A policy is a security requirement written in plain language. At run time, detections-runner spawns a policy-evaluator per policy, bound to that detection so every finding links back to it. Policies are the right tool when the rule is about intent — business logic, authorization, data handling — where no pattern captures the requirement and a human reviewer would need to reason about the code.

Fields that matter

The test-to-production lifecycle

New detections start at TEST. Run them, review what they catch, tune the rule, and promote to PRODUCTION when the signal is trustworthy. This exists because a noisy detection is worse than no detection — it trains your team to ignore results. Keeping unproven rules visibly in TEST lets you build the library without eroding trust in it.

Where detections come from

Compiled detections keep provenance back to the upstream document, so a rule can be traced to the requirement that motivated it.

Authoring a detection

In the web console. Open Detections and create one. The editor syntax-highlights by type — YAML for policies, Markdown with YAML frontmatter for rule types — and labels the language in the header. Customer types the UI doesn’t recognize still render with a generic label rather than breaking. With an agent. Often the better path, because agents can validate as they go:
  • opengrep-rule-creator writes and checks an OpenGrep rule.
  • policy-detection-creator turns a requirement into a stored policy.
  • detection-author reads a scan’s findings and authors a detection for each — the automated version of the same loop.
Ask in chat: “Write an OpenGrep rule that catches this pattern and store it as a test detection.”

Running detections

Add detections-runner as a workflow step. It lists every stored detection, triages which apply, and dispatches by type — OpenGrep rules directly, policies via one child evaluator each. Findings link back to the detection that produced them, so you can see which rules are earning their place. Its bias is deliberate: it dispatches when in doubt, because a detection that never ran is worse than a wasted pass.

The compounding loop

  1. An agent confirms a vulnerability in chat or a workflow run.
  2. detection-author — or you — turns it into a detection, at TEST.
  3. You review what it catches and promote it to PRODUCTION.
  4. A detections-runner workflow applies it on every pull request from then on.
Step 4 is cheap and repeatable. That’s the payoff for the reasoning spent in step 1.

Next steps

Run them in a workflow

Add detections-runner to a chain.

Findings

What a detection produces when it matches.