AI pentesting guides / Free, open-source and AI pentesting

Workflow walkthrough

Running a pentest in GitHub Actions, step by step

To run a pentest in GitHub Actions, add a workflow that runs on a schedule or manual trigger, calls the pentest tool against a staging target with an explicit scope, fails above a chosen severity, and uploads the SARIF output so findings appear in the repository's Code Scanning alerts. The Pentest-Swarm action does most of that in one step.

This walkthrough uses the example workflow published in the Pentest-Swarm repository. The same structure applies to any tool that produces SARIF: the details that matter are permissions, secrets, scope and where the results end up.

Step 1: choose the trigger

The example runs weekly on a cron schedule (Mondays at 02:00 UTC) and on manual dispatch. A schedule suits adaptive pentests, which take longer than a typical pull request check. If you want a run after each staging deploy, trigger the workflow from your deployment job instead. Avoid running dynamic tests on pull requests from forks, which should never see your secrets.

Step 2: set permissions and secrets

  • Grant contents: read and security-events: write; the second is required to upload SARIF to Code Scanning.
  • Store the model API key as an encrypted repository or organisation secret, for example ANTHROPIC_API_KEY.
  • Store the target and scope as repository variables (PENTEST_TARGET, PENTEST_SCOPE) so they are not hard-coded.
  • Restrict who can edit those variables; changing them changes what gets tested.

Step 3: add the pentest step

  • Use Armur-Ai/Pentest-Swarm-AI@v0 with inputs target, scope, mode (manual, bugbounty, asm or ctf) and fail-on (critical, high, medium, low or none).
  • Set swarm: "true" to use the swarm scheduler, or leave it off for the stable sequential runner.
  • Use dry-run: "true" for a first trial, which plans without executing exploitation commands.
  • Pin a release with the version input once you are happy with results, so upgrades are deliberate.

Step 4: publish the results

Upload the report directory as a build artifact with actions/upload-artifact, using if: always() so you keep it even when the severity gate fails the job. Then upload the SARIF file with github/codeql-action/upload-sarif, reading the path from the action's sarif-path output. Findings then appear in the repository's Security tab alongside any static analysis results.

Common mistakes to avoid

  • Running against production because a variable was left at its default. Keep the production hostname out of the workflow entirely.
  • Triggering on pull_request_target or fork pull requests, which can expose secrets to untrusted code.
  • Leaving the job without a timeout-minutes value, so a long adaptive run ties up a runner.
  • Uploading SARIF only on success, which hides results exactly when the severity gate fails.
  • Floating on the latest release forever; pin a version once the workflow is stable.
With Pentest-Swarm

What the Pentest-Swarm action provides

The action installs a Pentest-Swarm release on the runner and runs a scan with your inputs. It is marked beta in the project's feature table.

  • Outputs: report-path (Markdown report), sarif-path (for Code Scanning) and findings-count.
  • Scope is enforced in code and fails closed, so the run cannot drift beyond PENTEST_SCOPE.
  • Copy the example from deploy/github-action/example-workflow.yml in the repository into .github/workflows/pentest.yml.
  • Prefer to run it locally first? npm install -g @armurai/pentestswarm and pentestswarm scan $TARGET --scope $SCOPE --follow.

Where it falls short

The GitHub Action is beta and its api-key input is documented as a Claude API key; for other providers, running the CLI directly in a workflow step gives you more control. GitHub-hosted runners can only reach internet-accessible targets, so testing internal staging needs a self-hosted runner inside that network. Adaptive runs vary in length, so set a job timeout. For a quick, deterministic DAST check on every pull request, a dedicated DAST action is a better fit.

Questions

Why do I need security-events: write?

GitHub requires that permission for a workflow to upload SARIF results to Code Scanning.

Can a GitHub Actions pentest test internal services?

Not from GitHub-hosted runners. Use a self-hosted runner placed inside the network that can reach the target.

Will the job fail on every finding?

Only on findings at or above the fail-on severity; others are reported but do not fail the job.

Sources

  1. Pentest-Swarm example workflow
  2. GitHub Docs: uploading a SARIF file
  3. GitHub Docs: using secrets in GitHub Actions