Read the code
bughunt scan reads every file in 30+ languages and gives you the short list worth a person's time.
bughunt scan ~/code/shop # the files as they are now
bughunt scan ~/code/shop --ref origin/main # a clean export of one branch
What a report looks like
4,210 raw flags in 1,930 files; 12 worth reading (3 from high-confidence rules)
left out: 2,140 style or housekeeping, 1,762 from broad rules (--broad), 296 in files that are not shipped, 0 already reviewed
A flag is a candidate, not a bug: read the code behind each line.
HIGH 3 sql-injection
MED 9 open-redirect
HIGH sql-injection app/models/order.rb:41 | Order.where("id = #{params[:id]}")
MED open-redirect app/controllers/sessions_controller.rb:18 | redirect_to params[:next]
Each line is a rule, a place and the code. A flag is a candidate, not a bug. Open the file and read around it before you call it one.
What is left out, and why
- Style and housekeeping rules: translation strings, formatting, tidiness. Real, but not what a bug hunt is for.
- Broad security rules, which flag every use of a common construct: any file path built from a variable, any link opened in a new tab. They are security rules, and are counted as such, but on a real codebase they bury the list.
--broadshows them. - Files that are not shipped: build scripts, fixtures, docs, generated and minified output.
- Tests and dependencies, which the scanner is told not to read.
Everything left out is counted on the second line of the report, one number per reason. To see all of it:
bughunt scan . --all
If the scanner could only partly read some files or rules, the report says how many and where they are listed. Silence is never used to mean "clean".
The repo does not get a say
You may be reading code you did not write. A comment such as nosemgrep on a line does not switch a finding off, the repo's own ignore file is not used, and bughunt scan runs nothing from the repo. A repo's settings file can leave findings out, but each one is counted.
What to do about a finding
Where the rule has them, a finding carries its weakness ids (such as CWE-89 and the OWASP category), links that explain it, and the rule's suggested change. They are in every report format.
Only new findings: the baseline
Once a person has read the shortlist, record it. From then on only new flags are reported.
bughunt scan . --baseline bughunt-baseline.json --update-baseline # after reviewing
bughunt scan . --baseline bughunt-baseline.json # from now on
A finding is recognised by its rule, its file and the flagged code, not by its line number. So:
- code added above it: still the same finding, still reviewed;
- the flagged line itself changes: a new finding, reported again.
Commit the baseline file so the whole team and CI share it.
Scanning a branch
--ref exports that branch or commit into bughunt's own folder and scans the copy. Your checkout is not touched, and untracked files and installed packages are not scanned.
Options
| Option | What it does |
|---|---|
--ref REF | Scan a clean export of a branch or commit. |
--broad | Also show the broad security rules. |
--all | Show everything, including what is normally left out. |
--baseline FILE | Report only findings not in this file. |
--update-baseline | Write every current finding to the baseline and report none. |
--jobs N | Scanner processes to run at once (default 3). |
--format, --output | How the report is written, and where. See Reports. |
To leave out rules or folders for one repo, see Settings.