Lion Cipher Lab

Draft Semgrep rules with a local LLM, then prove them against a labelled corpus

Why it matters

Writing a custom static-analysis rule is slow, fiddly work, and a code model will hand you a confident first draft in seconds. That draft is the trap. In this lab the draft looks right, says it ignores safe code, and runs without a single warning, yet a third of its findings are false alarms and it misses a real injection. Teams that ship rules like that teach developers to ignore the scanner. The skill an application security engineer is hired for is not prompting; it is proving. You will build the evidence (a labelled corpus, a precision and recall score, a Semgrep test suite and a held-out…

What you'll learn

Steps in this lab

  1. What you are proving, and the words you need
  2. Set up: a lab folder and Semgrep in a virtual environment
  3. Save the labelled corpus: 10 vulnerable snippets, 10 safe ones
  4. Save the scorer: precision and recall from the labels
  5. Get a draft: a live local model, or the labelled stub
  6. Gate 1: does the draft even use real Semgrep syntax?
  7. Measure BEFORE: score the raw draft on the corpus
  8. Turn the corpus into a Semgrep test suite
  9. Fix it by hand, one failure mode at a time, and re-measure each round
  10. Measure AFTER, then run a held-out set you did not tune on
  11. If you used a live model: measure the variance, not one lucky run
  12. The judgment: when to trust the draft, and how a pro does this

Open the full interactive lab →