Skip to content

hypnguyen1209/offensive-claude / skills/threat-hunting

threat-hunting

Flagged

Use when hunting threats or engineering detections — ATT&CK Detection-Strategies, Sigma + correlation with Detection-as-Code CI, Windows endpoint hunting (Sysmon/ETW/LSASS/LOLBins), network C2 hunting (JA4+, beaconing, DNS tunneling), cloud-identity hunting, Atomic Red Team purple-team validation

scripts/sigma_pipeline.sh

View on GitHub
#!/usr/bin/env bash
# =============================================================================
# sigma_pipeline.sh - Detection-as-Code pipeline: lint -> convert -> artifact.
#
# Lints every Sigma rule (via dac_validate.py) then compiles the rule set to one
# or more SIEM backends with sigma-cli, writing per-backend artifacts. Designed to
# be the single command a CI job runs.
#
# USAGE:
#   ./sigma_pipeline.sh <rules_dir> [out_dir] [backend1 backend2 ...]
#   ./sigma_pipeline.sh ./rules ./build splunk microsoft365defender elasticsearch
#   (default backends: splunk microsoft365defender elasticsearch)
#
# DEPENDENCIES:
#   python3, pyyaml, sigma-cli and backend plugins:
#     pip install sigma-cli pysigma-backend-splunk \
#       pysigma-backend-microsoft365defender pysigma-backend-elasticsearch \
#       pysigma-pipeline-sysmon pyyaml
#
# EXIT: non-zero if lint finds errors or any backend conversion fails (CI gate).
# Defensive detection-engineering tooling. Authorized use only.
# =============================================================================
set -euo pipefail

RULES_DIR="${1:?usage: sigma_pipeline.sh <rules_dir> [out_dir] [backends...]}"
OUT_DIR="${2:-./build}"
shift || true
shift || true
BACKENDS=("$@")
if [ "${#BACKENDS[@]}" -eq 0 ]; then
  BACKENDS=(splunk microsoft365defender elasticsearch)
fi

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
mkdir -p "$OUT_DIR"

echo "[*] Stage 1/3 - lint $RULES_DIR (Detection-as-Code policy)"
python3 "$SCRIPT_DIR/dac_validate.py" "$RULES_DIR" --fail-on-error

# Map a sensible default pipeline per backend (sysmon mapping for windows backends).
pipeline_for() {
  case "$1" in
    splunk|elasticsearch) echo "sysmon" ;;
    *) echo "" ;;
  esac
}

echo "[*] Stage 2/3 - convert to backends: ${BACKENDS[*]}"
fail=0
for be in "${BACKENDS[@]}"; do
  pl="$(pipeline_for "$be")"
  out="$OUT_DIR/detections_${be}.txt"
  echo "    -> $be (pipeline='${pl:-none}') => $out"
  if [ -n "$pl" ]; then
    sigma convert -t "$be" -p "$pl" "$RULES_DIR" -o "$out" || fail=1
  else
    sigma convert -t "$be" "$RULES_DIR" -o "$out" || fail=1
  fi
done

echo "[*] Stage 3/3 - summary"
ls -la "$OUT_DIR"
if [ "$fail" -ne 0 ]; then
  echo "[!] One or more backend conversions failed." >&2
  exit 1
fi
echo "[+] Pipeline complete. Artifacts in $OUT_DIR/"
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall