bughunt

Use in CI

bughunt is built to be a CI step: a clear exit status, reports a dashboard can read, and a baseline so only new findings fail the build.

Exit status

StatusMeaning
0Ran, and found nothing new.
1Ran, and has findings.
2Could not run, in whole or in part: a tool is missing, a file is wrong, the host was refused, a layer or a fuzz target did not run.

"Could not run" is never reported as "nothing found".

Reports

bughunt scan . --format json  --output report.json
bughunt scan . --format sarif --output report.sarif

For a job summary people can read without opening the log:

bughunt audit . --format markdown >> "$GITHUB_STEP_SUMMARY"

All five formats are described under Reports.

Fail only on new findings

An existing codebase has flags that were already read and judged fine. Record them once and commit the file:

bughunt scan . --baseline bughunt-baseline.json --update-baseline

Then name it in bughunt.toml so every run uses it:

[scan]
baseline = "bughunt-baseline.json"

A change to the baseline file shows up in the pull request, so marking something as reviewed is itself reviewed.

GitHub Actions

name: bughunt
on: [pull_request]

permissions:
  contents: read
  security-events: write   # to upload the SARIF report

jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - name: Install bughunt and Opengrep
        run: |
          curl -fsSL https://raw.githubusercontent.com/sundarshahi/bughunt/main/install.sh | sh
          curl -fsSL https://raw.githubusercontent.com/opengrep/opengrep/main/install.sh | bash
          echo "$HOME/.local/bin" >> "$GITHUB_PATH"
      - run: bughunt scan . --format sarif --output bughunt.sarif
      - if: always()
        uses: github/codeql-action/upload-sarif@v4
        with:
          sarif_file: bughunt.sarif

The step fails the job when there are new findings, and the upload still runs so they appear on the pull request.

Fuzzing in CI

bughunt fuzz . --seconds 60     # on pull requests
bughunt fuzz . --seconds 600    # on a schedule

Upload the folder of failing inputs (fuzz/artifacts for Rust) when the step fails, so the input that broke the target is not lost with the runner.

The API layer in CI

Start the app and a throwaway database in the job, then point bughunt at localhost. Seed the database first, or most lookups will only ever answer "not found". See how to read the coverage lines.