Pipelines (CI/CD)
A pipeline can send its security results to Phantom and ask whether a build may ship. Both use the REST API at http://127.0.0.1:8000, with the access token when one is set.
Sending results
Import SARIF 2.1.0 (most scanners write it), Nuclei or ZAP reports, JSON or CSV into a vault's findings:
curl -fsS -X POST "$PHANTOM/api/v1/vaults/$VAULT/findings/import" \
-H "Authorization: Bearer $PHANTOM_TOKEN" -H 'Content-Type: application/json' \
--data "$(jq -n --rawfile c results.sarif '{format: "sarif", content: $c, dry_run: true}')"With dry_run: true (the default) Phantom only previews what it would record: new findings, duplicates and rows refused because they are out of the vault's scope. Approve them by sending the same request with dry_run: false, by hand or in a protected pipeline step. Results for hosts outside the vault's scope are always refused, and targets are never created.
Asking whether a build may ship
curl -fsS "$PHANTOM/api/v1/vaults/$VAULT/findings/gate?fail_on=high&fail_on_overdue=true" \
-H "Authorization: Bearer $PHANTOM_TOKEN" | tee gate.json | jq -e .passedThe gate fails when:
- a finding was reopened: it had been resolved and a retest shows it is back (a regression);
- a finding is open at the
fail_onseverity or above (critical,high,medium,low), when given; - a finding is past its remediation date, when
fail_on_overdue=true.
It never fails on suspected, duplicate, false-positive, won't-fix or resolved findings, or on findings under an accepted risk. The answer lists the reasons and the findings behind them:
{
"passed": false,
"reasons": ["1 finding(s) reopened"],
"reopened": [{"id": 41, "title": "Open redirect", "severity": "medium", "status": "reopened"}],
"blocking": [],
"overdue": 0
}GitHub Actions
- name: Phantom gate
env:
PHANTOM: https://phantom.example.com
VAULT: 3
PHANTOM_TOKEN: ${{ secrets.PHANTOM_TOKEN }}
run: |
curl -fsS "$PHANTOM/api/v1/vaults/$VAULT/findings/gate?fail_on=high" \
-H "Authorization: Bearer $PHANTOM_TOKEN" | tee gate.json | jq -e .passedStore the token as a repository secret. To be told about changes instead of asking, use webhooks.