Skip to main content

Draft detections from plain English and review them like a senior detection engineer — Sigma and Cortex XQL, offline-safe, model-agnostic.

Project description

detflow

A detection-engineering copilot. Draft detections from plain English and review them like a senior detection engineer — in vendor-neutral Sigma or Cortex XSIAM XQL. Offline-safe, model-agnostic, and built to drop into a detection-as-code pipeline.

from detflow import draft, lint, review

# 1. Draft from plain English
d = draft("powershell launched with an encoded command by a Word macro")
print(d.rule)                     # → a Sigma rule

# 2. Lint it (deterministic, no model, never raises)
print(lint(d.rule).status)        # → pass | warn | fail

# 3. Review it like a senior engineer, deduped against your rule catalog
catalog = [{"name": "Encoded PowerShell", "source": "edr", "techniques": ["T1059.001"]}]
r = review(d.rule, catalog=catalog)
print(r.quality_score, r.false_positive_risk, r.verdict)
for o in r.overlaps:
    print("already covered by:", o.name, "—", o.reason)

Why

The Sigma ecosystem is strong at compiling rules (pySigma) and running them, but the authoring and review steps are still manual. detflow fills that gap:

  • Draft — describe a behavior in plain English, get a valid rule back. No blank page.
  • Lint — a fast, offline structural gate before you spend a model call.
  • Overlap — don't ship the same coverage twice; dedup against the rules you already run.
  • Review — a structured, senior-engineer assessment: quality, false-positive risk and why, ATT&CK coverage, gaps, concrete improvements, and a verdict.

It's the human-in-the-loop front end of a detection-as-code workflow: draft → lint → review → (you) merge.

Install

pip install detflow            # core: lint + overlap (stdlib + PyYAML)
pip install "detflow[llm]"     # + drafting/review via any OpenAI-compatible endpoint
pip install "detflow[langchain]"  # + bring your own LangChain model / failover chain

Models

detflow is model-agnostic. A model is anything with complete(system, user, *, json=False) -> str. Three ways to supply one:

From the environment (any OpenAI-compatible endpoint):

export DETFLOW_LLM_API_KEY=sk-...
export DETFLOW_LLM_BASE_URL=https://api.openai.com/v1   # or a local vLLM/Ollama
export DETFLOW_LLM_MODEL=gpt-4o-mini
from detflow import draft
draft("encoded powershell from an office macro")   # picks up the env model

Explicitly:

from detflow import review
from detflow.llm import OpenAIChatModel
review(rule, model=OpenAIChatModel(api_key="sk-...", model="gpt-4o-mini"))

With failover — wrap a langchain-failover chain so a primary-model outage transparently falls back to a secondary:

from langchain_failover import FailoverChatModel
from langchain_openai import ChatOpenAI
from detflow.llm import LangChainModel
from detflow import draft

chain = FailoverChatModel(models=[ChatOpenAI(model="gpt-4o-mini"), local_llm])
draft("...", model=LangChainModel(chain))

The two formats

  • Sigma (default) — vendor-neutral YAML; portable across SIEMs.
  • Cortex XSIAM XQL (fmt="cortex-xql") — author straight in XQL when you want full control on that platform.
draft("rare parent spawning powershell", fmt="cortex-xql")
review(my_xql, fmt="cortex-xql", techniques=["T1059.001"], catalog=catalog)

CLI

detflow draft "powershell with an encoded command from a word macro"
detflow draft "..." --format cortex-xql
detflow lint rule.yml
detflow review rule.yml --catalog catalog.json --json

Design

  • Never raises. lint, find_overlaps, and review always return a result; draft returns an error result (not an exception) when no model is configured.
  • Deterministic core. Lint and overlap need no network and no keys; review degrades to a deterministic floor (lint + overlap + parsed metadata) with no model.
  • Bring your own catalog. Overlap compares against a plain list of dicts you export from whatever platforms you run — no platform lock-in.

License

MIT © Vinay Vobbilichetty

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

detflow-0.1.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

detflow-0.1.0-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file detflow-0.1.0.tar.gz.

File metadata

  • Download URL: detflow-0.1.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for detflow-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2689dd04b52dccb643bc758e2837a80c58eaef90d2bd79d6bddd214982de5466
MD5 457541344caab92531c5840c5244ec10
BLAKE2b-256 939bff1b4db69eaf429c06c4352edc12260ad11d91532eee6c2f53aeeaaa97ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for detflow-0.1.0.tar.gz:

Publisher: release.yml on vinayvobbili/detflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file detflow-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: detflow-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for detflow-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a852f869b0639cc1bf301d6fc9c02fa7c6d77ce39da76504fed6c521f99016dd
MD5 34a22a73ef450c021758214799e17dc0
BLAKE2b-256 8c7e6f262a47a6ae8075ab5d3b1afe02b71828ceb786229a771f690b1ce1ae1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for detflow-0.1.0-py3-none-any.whl:

Publisher: release.yml on vinayvobbili/detflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page