Guide · 5 min
Add the GitHub Action
Run XploitScan automatically on every push and pull request. Posts a severity-table comment on PRs and uploads SARIF to the GitHub Security tab so findings appear inline in the PR diff.
Create the workflow file
In your repo, create the file .github/workflows/security-scan.yml and paste in the contents below.
name: XploitScan Security Scan
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
security-events: write
pull-requests: write
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run XploitScan
uses: bgage72590/xploitscan-action@v1
with:
path: '.'
fail-on: 'critical'
comment: 'true'@v1 tracks the latest v1 release. Pin the action to a full commit SHA so a moved tag cannot change what runs: uses: bgage72590/xploitscan-action@52a70ac6e502f6872d7dcd974a49ff9560c8e528 # v1.11.4.
Private repository without GitHub Code Security? Add upload-sarif: 'false' under with:. The scan and the PR comment still run and the SARIF file is still written to sarif-file. security-events: write is needed only for the code-scanning upload, so with upload-sarif: 'false' you can leave it out.
Without an API key the action runs the 30 free rules. API keys are a paid-plan feature (Pro or Team) — generate one under Settings → API Keys and pass it with the api-key input.
Pick a fail threshold
The fail-on input controls when the action returns an error and blocks the merge. Pick the right level for your project:
fail-on: 'none'
Report only, never block. Best for adding the action to an existing repo without breaking anyone's day-1 workflow.
fail-on: 'critical' (recommended)
Block merges while the scanned code contains any critical-severity finding (existing ones included). Lets reasonable PRs through but stops “walked into the room and gave away $10k” bugs.
fail-on: 'high'
Block on high or critical. Stricter — good for production-critical apps and compliance audits.
fail-on: 'medium'
Block on medium, high, or critical. A lone low finding does not fail.
fail-on: 'low'
Block on any graded finding (critical, high, medium, or low). Info findings never fail the build.
Commit and push
Commit the workflow file to your default branch and push.
git add .github/workflows/security-scan.yml git commit -m "Add XploitScan security scan" git push
Open a test PR
Make any small change on a branch and open a PR. Within a minute or two you should see:
· A green/yellow/red “XploitScan Security Scan / security” check on the PR
· A bot comment with a severity table:
## 🔴 XploitScan Security Report **Grade: F** | Score: 0/100 | 13 findings AI review skipped: no Anthropic API key is set. | Severity | Count | |----------|-------| | 🔴 Critical | 7 | | 🟠 High | 3 | | 🟡 Medium | 1 | | 🔵 Low | 2 | > Run `npx xploitscan scan .` locally for full details with fix suggestions.
The table counts graded findings. When some findings sit in vendored, generated, documentation or test files, the comment says how many: they are in the Security tab but not in the table or the grade. Later pushes to the same PR update this comment rather than adding a new one. To reproduce a run locally: npx xploitscan@1.19.0 scan .
· Findings inside the PR diff itself, via the GitHub Security tab
(Optional) Required check on main
In your repo Settings → Branches → main → Branch protection rule → check “Require status checks to pass before merging” and add the security check (the job name from the workflow). Now nothing merges until the scan passes.
What the action does on each run
- Sets up Node.js and installs one pinned release of the XploitScan CLI. A failed install fails the job.
- Scans
pathonce for the JSON report and computes the grade from it, holding out findings in test files and, unlessgrade-vendoredis on, in vendored, generated and documentation files. A scan that crashes or produces no usable report fails the job instead of passing as zero findings. - Writes the SARIF file and, when
upload-sarifis on, uploads it to code scanning. It refuses to upload an empty SARIF file when the scan found something, because an empty upload would close your open alerts. - On a
pull_requestevent withcommenton, posts or updates the summary comment. - Applies
fail-onto the graded counts, andfail-on-qualityseparately, so opting into one is not opting into the other.
Inputs
| Input | Default | What it does |
|---|---|---|
| path | '.' | Directory to scan. |
| fail-on | 'none' | Fail the job when a graded finding at this severity or higher is present: critical, high, medium, low or none. Info findings never fail it. |
| sarif-file | 'xploitscan-results.sarif' | Where the SARIF report is written. |
| upload-sarif | 'true' | Upload the SARIF file to GitHub code scanning. Set 'false' on a private repository without GitHub Code Security; the file is still written. |
| comment | 'true' | Post a summary comment on pull requests, updating the same comment on later pushes. |
| api-key | '' | XploitScan API key (xpls_…). Unlocks the full rule set; without it the action runs the free rules. |
| fail-on-quality | 'false' | Also fail on high-severity code-quality findings (QA…). They are reported either way. |
| grade-vendored | 'false' | Count findings in vendored, generated and documentation files toward the grade and fail-on. Test files stay held out. |
| anthropic-api-key | '' | Optional Anthropic API key for AI review. With a key set, the Action sends your code to Anthropic directly, under your own Anthropic account and not through XploitScan, in chunks of whole files and excerpts around each finding. Set the ai input to false to turn it off. |
| ai | 'true' | `ai` — set to `false` to send no code to Anthropic even when `anthropic-api-key` is set. `ai: false` in .xploitscanrc takes effect in the Action only after its CLI pin is bumped to a CLI release that adds the `ai` setting. |
Outputs
Give the step an id and later steps can read the results, for example to write the grade into the job summary:
- name: Run XploitScan
id: xploitscan
uses: bgage72590/xploitscan-action@v1
with:
fail-on: 'high'
api-key: ${{ secrets.XPLOITSCAN_API_KEY }}
- name: Record the grade
if: always()
run: echo "Grade ${{ steps.xploitscan.outputs.grade }} (${{ steps.xploitscan.outputs.score }}/100)" >> "$GITHUB_STEP_SUMMARY"grade— Security grade, A+ to F.score— Score from 0 to 100.findings-count— All findings, including ones not counted toward the grade.graded-findings-count— Findings that count toward the grade.ungraded-count— Findings in vendored, generated, documentation or test files.quality-count— Code-quality (QA…) findings.quality-high-count— Code-quality findings at high severity or above.critical-count— Graded critical findings.high-count— Graded high findings.medium-count— Graded medium findings.low-count— Graded low findings.sarif-file— Path of the SARIF file.
Troubleshooting
PR comment doesn't appear
Check that
comment: 'true'is set and that the workflow haspull-requests: writepermission. Forks of public repos cannot post comments — that's a GitHub safety restriction.SARIF upload fails
Make sure
security-events: writeis in the workflow permissions block. On a private repository, the upload needs GitHub Code Security; without it, setupload-sarif: 'false'(v1.11.0 or later) and the rest of the action still runs.Scan times out
Narrow the path:
path: 'packages/web/src'instead of.. Avoid scanningnode_modulesor build outputs.
Not on GitHub? The same CLI runs in GitLab CI and Bitbucket Pipelines. Prefer Check Runs without a workflow file? Use the GitHub App.
Want to call the scan engine directly from a custom build script?
Next: Call the API directly →