Hardening a local repository security scanner

Most leaked API keys and unsafe pull_request_target workflows are only noticed after a commit lands on a public GitHub branch. I started writing Wardline at Undrocs so I could catch those mistakes locally with one command before running git push.

Halfway through writing the first prototype, an obvious catch hit me: a security scanner is itself a program that reads untrusted input. People point it at unfamiliar repos full of weird lockfiles, broken Dockerfiles, and live credentials that must never leak into terminal scrollback or CI logs.

Four checks in one binary

Instead of wrapping four separate third-party tools with different output formats, Wardline runs four native Go scanners and emits findings under one schema:

PrefixDomainWhat it inspects
WL-SEC-*Secrets25 credential rules covering cloud keys, VCS/CI tokens, payment keys, PEM blocks, and YAML block scalars
WL-DEP-*Dependenciesgo.mod (go.work, replace/exclude) and npm package-lock.json (v1 to v3) checked against OSV.dev
WL-WF*Workflows.github/workflows/*.yml token permissions, shell script injection, unpinned actions, and artifact handling
WL-CFG-*ConfigDockerfile and docker-compose.yml root users, privileged containers, host mounts, and disabled TLS checks

Rules that kept the scanner safe

First, matched secrets are redacted inside the finding constructor before any console, JSON, or SARIF formatter touches them. If a scanner prints the raw AWS key it just caught into a public GitHub Actions log, the scanner just helped leak the secret. (I added the same header-stripping rule to Wiremark for benchmark reports.)

Second, workflow files are parsed into a static YAML syntax tree and never evaluated. Spotting ${{ github.event.issue.title }} inside a run: shell block only needs AST inspection, with zero risk of executing expressions from an untrusted repository.

Third, dependency checks read lockfiles and go.mod replace directives rather than loose version ranges in package.json, so OSV queries match the exact package versions a build actually links. And like Riftmap, the whole scan runs locally on your machine aside from optional OSV vulnerability lookups.


Linked mentions

You might also enjoy