Traditional SAST tools and linters are great at catching syntax issues and known taint patterns (eval, hardcoded secrets, basic SQLi). Where they struggle is semantic business-logic bugs a newly added /admin route missing an auth decorator, a TOCTOU check-then-act race condition on a balance transfer, a bare except Exception: pass swallowing a failed DB write, or an AI-generated security guard that doesn't actually enforce anything.
On the other end, dumping an entire repository into an LLM on every pull request is slow, expensive, and noisy.
I just open sourced LogicGuard v0.1.0 (MIT) to bridge the two with a diff-scoped, two-stage pipeline for Python, JavaScript, and TypeScript.
Instead of sending every changed line to a model, LogicGuard splits scanning into two distinct phases:
git diff and extracts structural risk candidates. If a PR touches clean code or non-matching logic, LogicGuard exits immediately with It supports OpenRouter (works with openrouter/free for $0 CI runs), Anthropic, local Ollama models, and a pure-AST --offline-only mode for private or air-gapped repos.
uvx logicguard rules
uvx logicguard diff --base main --offline-only
Or install globally via pipx install logicguard.
v0.1.0)
auth_bypass — Mutating API routes missing authentication/authorization guardsidor_ownership — Object access or mutation without verifying resource ownershiprace_toctou — Check-then-act state updates (e.g., balances, inventory) without locking or atomic updatessilent_except — Broad exception handlers silently swallowing failures around state changesai_hallucinated_guard — Placeholder or no-op validation checks commonly introduced by coding assistants
LogicGuard ships with a GitHub Marketplace Action that emits SARIF 2.1.0 inline directly into GitHub Code Scanning PR reviews and separates exit codes (0 clean, 1 findings, 2 provider/config error) so a flaky API doesn't masquerade as a security failure:
name: LogicGuard Security Diff Scan
on:
pull_request:
branches: [main]
permissions:
contents: read
security-events: write
jobs:
logicguard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: Aviation3006/logicguard@v0.1.0
env:
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
(Swap in provider: ollama or offline-only: true if your codebase cannot touch external APIs.)
Every rule follows a self-contained 2-file contract (src/logicguard/rules/<name>.py + tests/rules/test_<name>.py), and I've opened 8 good first issue rule specs (#2–#9) covering JWT none alg, SSRF, mass assignment, missing rate limits, open redirects, SQL string interpolation, insecure cookie flags, and upload path traversal.
If you try it on a repo or have strong opinions on AST pre-filter heuristics and false-positive handling in CI I'd love to hear your feedback in the comments or issues.