How pre-commit scans work
Lighthouse reviews your staged changes each time you commit, before the code leaves your machine.
A pre-commit scan reviews the changes you're about to commit and reports security problems. It runs from a Git hook, so it happens on every commit without you doing anything.
$ git commit -m "add invoice export"
Running Lighthouse scan
! 2 finding(s)
critical 0 high 1 medium 0 low 1
report .git/lighthouse/findings/3f2a….md
view https://lighthouse.rewarelabs.com/scans/3f2a…
[main 4c1d2e7] add invoice exportWhat happens on commit
- Git runs the pre-commit hook that
reware-lighthouse initinstalled. - The hook runs
reware-lighthouse scan, which sends your staged changes (whatgit diff --cachedshows) to Lighthouse with your branch and commit. - Lighthouse reviews the change.
- The CLI prints a summary, saves the full report, and links to it in the dashboard.
- If a finding reaches your repository's blocking policy, the commit stops. Otherwise it goes through.
Only staged changes are scanned. Unstaged edits and untracked files aren't sent.
Scan without committing
git add -p
reware-lighthouse scanDepth
Pre-commit scans use Normal depth by default, which reviews the change itself and keeps commits fast. Max also uses what ingestion learned about the repository, and takes longer. See Scan depth.
What's sent
Your staged diff (including deleted files), your branch name, your HEAD commit, the newest commit already on the remote, and how many commits you haven't pushed. Lighthouse uses these to review the change against the matching code. The code is deleted from Lighthouse when the scan ends. Only the findings are kept.