docs/ci.md
86 lines · 3283 bytes
Running audit-report in CI
The pattern is always the same three steps:
- Collect an evidence package with
audit-tools(per-platform CLI). - Report on it with
audit-report, writingmd/html/jsonartifacts. - Gate the pipeline with
--fail-onso a control regression can block a merge or page a scheduled run.
Ready-to-copy starting points:
audit-toolsis not on PyPI — it is a set of per-platform scripts. Check the repo out (or clone it) and runapplications/<platform>/audit.pydirectly; Python puts the script's own directory onsys.path, so nocdis needed. Pass an absolute--outso every platform's package lands in one folder. Everything downstream only needs the<out>/<platform>_audit_<subject>_<date>/directory it writes.
Exact collection commands
Install audit-tools' dependencies once (pip install -r audit-tools/requirements.txt),
export the platform's credentials, then:
# AWS — credentials come from the standard AWS chain (env vars, profile, OIDC role)
python audit-tools/applications/aws/audit.py --out "$PWD/output"
# GitHub — needs GITHUB_TOKEN (read-only) in the environment
python audit-tools/applications/github/audit.py --org "$ORG" --out "$PWD/output"
# GitLab — needs GITLAB_TOKEN (read_api) in the environment
python audit-tools/applications/gitlab/audit.py \
--group "$GROUP" --url "$API_V4_URL" --out "$PWD/output"
Gating strategies
Snapshot gate — the current state must be clean.
audit-report "$PKG" --fail-on high
Exits non-zero if any high-severity control is unsupported in the newest package. Simple and strict; good for a scheduled run that should stay green.
Regression gate — this change must not make things worse.
Keep the previous package in the repo (or restore it from an artifact) and diff against it. The build fails only when a control that used to pass now fails, which avoids blocking on pre-existing debt.
audit-report "$PKG" --baseline ./baseline/"$LAST_PKG" --fail-on high
Trend artifact — show direction over time.
Point trend mode at a folder of retained packages to publish a heatmap of every
control across dates. Its --fail-on reflects the latest package, so it can
double as a snapshot gate while producing the timeline artifact.
audit-report ./history --trend --format html,json --out ./trend
Exit codes
| Code | Meaning |
|---|---|
0 |
Ran successfully; no --fail-on threshold was breached. |
1 |
A finding (or, in diff mode, a regression) met the --fail-on severity. |
2 |
Usage or input error (missing package, unknown format, mismatched platforms). |
Distinguishing 1 from 2 lets a workflow tell "the audit found a problem"
(expected, actionable) from "the job is misconfigured" (fix the pipeline).
Retaining history
audit-report never writes back to the package — it only reads. To build a
trend or a regression baseline, archive each run's package directory (a CI
artifact, a committed history/ folder, or object storage) and feed the
collection back in on the next run.