Skip to content

Commit 131ad6d

Browse files
mstykowclaude
andauthored
feat: add license-policy, fail-on, and sarif-file inputs for CI gating (#1)
* feat: add license-policy, fail-on, and sarif-file inputs for CI gating Surface the Provenant compliance gate as first-class inputs: `license-policy` (YAML policy file), `fail-on` (error|warning; fails the job when a matching license is found), and `sarif-file` (SARIF 2.1.0 for code-scanning upload). The entrypoint maps each to the corresponding `provenant scan` flag when set. Adds a README example that gates the build and uploads findings via upload-sarif. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Maxim Stykow <maxim.stykow@gmail.com> * docs: clarify the action auto-tracks latest Provenant (no per-release commits) Signed-off-by: Maxim Stykow <maxim.stykow@gmail.com> --------- Signed-off-by: Maxim Stykow <maxim.stykow@gmail.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 38c0595 commit 131ad6d

4 files changed

Lines changed: 95 additions & 17 deletions

File tree

AGENTS.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ contain the scanner, only a thin Docker container action that runs the published
3131

3232
## Versioning and releases
3333

34-
- The wrapped Provenant version is selected by the `FROM` tag in the `Dockerfile`, **not** by a
35-
call-time input (GitHub Actions forbids expressions in a container action's image reference).
36-
- Cutting an action release: bump the `Dockerfile` `FROM` tag to a concrete, working Provenant
37-
version, tag `vX.Y.Z`, and move the floating `vX` tag. Consumers pin `@vN` or a full SHA.
34+
- The `Dockerfile` is `FROM ghcr.io/getprovenant/provenant:latest`, so the action **auto-tracks the
35+
newest Provenant release** — GitHub rebuilds the image on each run and pulls `:latest`. There is
36+
**no per-Provenant-release commit or re-release of this action**; publish it once and it follows
37+
Provenant forward.
38+
- Cut an action release only for changes to the **action itself** (inputs, entrypoint, docs): tag
39+
`vX.Y.Z` and move the floating `vX` tag. Consumers pin `@vN` or a full SHA.
40+
- Trade-off: `@vN` is not pinned to a fixed scanner version. If reproducible version pinning is ever
41+
needed without per-release commits, convert to a composite action running
42+
`docker run …:${{ inputs.version }}` (default `latest`).

README.md

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,39 @@ jobs:
6969
args: --license --package --copyright
7070
```
7171

72+
### Fail the build on a disallowed license
73+
74+
Provide a [license-policy file](https://github.com/getprovenant/provenant/blob/main/docs/CLI_GUIDE.md#the-license-policy-file)
75+
that marks licenses with a `compliance_alert`, then gate on it. The job fails
76+
when a matching license is found, and the SARIF file surfaces the violations as
77+
pull-request and code-scanning alerts:
78+
79+
```yaml
80+
permissions:
81+
contents: read
82+
security-events: write # to upload SARIF
83+
84+
jobs:
85+
license-gate:
86+
runs-on: ubuntu-latest
87+
steps:
88+
- uses: actions/checkout@v7
89+
- uses: getprovenant/provenant-action@v1
90+
with:
91+
license-policy: .github/license-policy.yml
92+
fail-on: error
93+
sarif-file: provenant.sarif
94+
- uses: github/codeql-action/upload-sarif@v3
95+
if: always() # upload findings even when the gate fails the job
96+
with:
97+
sarif_file: provenant.sarif
98+
```
99+
72100
### Other scan options
73101

74102
Any `provenant scan` flag can be passed through `args` — for example
75-
`--ignore "node_modules/*"` to skip noise, `--incremental` with a cached
76-
`--cache-dir` to reuse work across runs, or `--license-policy policy.yml` for
77-
policy-aware review. See the [CLI Guide](https://github.com/getprovenant/provenant/blob/main/docs/CLI_GUIDE.md)
103+
`--ignore "node_modules/*"` to skip noise or `--incremental` with a cached
104+
`--cache-dir` to reuse work across runs. See the [CLI Guide](https://github.com/getprovenant/provenant/blob/main/docs/CLI_GUIDE.md)
78105
for the full set of workflows and flags.
79106

80107
## Inputs
@@ -86,11 +113,15 @@ for the full set of workflows and flags.
86113
| `output-file` | `-` | Where to write the report. `-` streams to stdout (the workflow log); any other value is a path written inside the workspace. |
87114
| `args` | `--license --package` | Extra raw arguments appended verbatim to `provenant scan`. Detections are opt-in — this is where you enable them (`--license`, `--package`, `--copyright`, `--info`, `--email`, `--url`, …). |
88115
| `paths-file` | _(empty)_ | Optional file listing exact files/directories to scan (one per line), relative to a single scan root in `paths`. Ideal for pull-request CI via `git diff --name-only`. When set, `paths` must stay a single root (the default `.`). |
116+
| `license-policy` | _(empty)_ | Optional path to a YAML license-policy file. Enables policy evaluation; required by `fail-on` and by SARIF output. |
117+
| `fail-on` | _(empty)_ | Fail the job (exit 3) when a file matches a policy whose `compliance_alert` is at or above this level: `error` or `warning`. Requires `license-policy`. |
118+
| `sarif-file` | _(empty)_ | Also write SARIF 2.1.0 of policy violations to this path, for `github/codeql-action/upload-sarif`. Meaningful only with `license-policy`. |
89119

90120
Under the hood the action runs:
91121

92122
```sh
93-
provenant scan <paths> [--paths-file <paths-file>] --<output-format> <output-file> <args>
123+
provenant scan <paths> [--paths-file <paths-file>] [--license-policy <file>] \
124+
[--fail-on <level>] [--sarif <sarif-file>] --<output-format> <output-file> <args>
94125
```
95126

96127
## Outputs
@@ -101,17 +132,18 @@ reading the report streamed to the workflow log when `output-file` is `-`.
101132

102133
## Versioning
103134

104-
The action is a Docker container action. The wrapped Provenant version is baked
105-
into the action's [`Dockerfile`](Dockerfile) per release, so the version you run
106-
is determined by the git ref you pin:
135+
The action always runs the **latest** published Provenant release: its
136+
[`Dockerfile`](Dockerfile) is `FROM ghcr.io/getprovenant/provenant:latest`, rebuilt on each run.
137+
So the wrapped scanner advances automatically with every Provenant release — there is no per-release
138+
update to this action.
139+
140+
You pin the **action's own** behavior by git ref:
107141

108-
- A **major version tag** (such as `@v1`) tracks the latest release within that
109-
major series — the best default for most workflows.
110-
- A **full commit SHA** is an exact, immutable pin.
142+
- A **major version tag** (such as `@v1`) — the best default; picks up action fixes within that major.
143+
- A **full commit SHA** — an exact, immutable pin of the action.
111144

112-
Because GitHub Actions does not allow expressions in a container action's image
113-
reference, the wrapped Provenant version cannot be selected at call time via an
114-
input; it is selected by the action release you pin to.
145+
Because the action tracks `:latest`, `@vN` does not pin a fixed scanner version. If you need a
146+
reproducible scanner version, pin the container directly instead (`docker run ghcr.io/getprovenant/provenant:<version> scan …`).
115147

116148
## How it works
117149

action.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,27 @@ inputs:
4848
to scan `paths` directly.
4949
required: false
5050
default: ""
51+
license-policy:
52+
description: >-
53+
Optional path to a YAML license-policy file (see the Provenant CLI guide for
54+
the format). Enables policy evaluation; required by `fail-on` and by SARIF
55+
output.
56+
required: false
57+
default: ""
58+
fail-on:
59+
description: >-
60+
Fail the job (exit code 3) when a scanned file matches a policy whose
61+
compliance_alert is at or above this level: "error" or "warning". Requires
62+
`license-policy`. Leave empty to report without gating.
63+
required: false
64+
default: ""
65+
sarif-file:
66+
description: >-
67+
Optional path to also write SARIF 2.1.0 of policy violations, for uploading
68+
with github/codeql-action/upload-sarif so findings appear as pull-request and
69+
code-scanning alerts. Meaningful only with `license-policy`.
70+
required: false
71+
default: ""
5172

5273
# The upstream image (gcr.io/distroless/static-debian12) ships no shell and its
5374
# ENTRYPOINT is the provenant binary itself, so optional/variadic inputs cannot
@@ -66,3 +87,6 @@ runs:
6687
- ${{ inputs.output-file }}
6788
- ${{ inputs.args }}
6889
- ${{ inputs.paths-file }}
90+
- ${{ inputs.license-policy }}
91+
- ${{ inputs.fail-on }}
92+
- ${{ inputs.sarif-file }}

entrypoint.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@
99
# $3 = output-file ("-" for stdout, or a path)
1010
# $4 = extra args (raw flags, word-split intentionally)
1111
# $5 = paths-file (optional; a --paths-file list, empty to skip)
12+
# $6 = license-policy (optional; a --license-policy file, empty to skip)
13+
# $7 = fail-on (optional; error|warning, empty to skip)
14+
# $8 = sarif-file (optional; a --sarif output path, empty to skip)
1215
set -eu
1316

1417
paths="${1:-.}"
1518
fmt="${2:-json-pp}"
1619
outfile="${3:--}"
1720
extra="${4:-}"
1821
pathsfile="${5:-}"
22+
policy="${6:-}"
23+
failon="${7:-}"
24+
sariffile="${8:-}"
1925

2026
case "$fmt" in
2127
json | json-pp | json-lines | yaml | cyclonedx | cyclonedx-xml | spdx-tv | spdx-rdf | debian | html)
@@ -37,6 +43,17 @@ set -- scan $paths
3743
if [ -n "$pathsfile" ]; then
3844
set -- "$@" --paths-file "$pathsfile"
3945
fi
46+
# License policy, the CI gate, and SARIF output. `--fail-on` and SARIF both need a
47+
# policy to be meaningful; the CLI validates the `--fail-on` requirement.
48+
if [ -n "$policy" ]; then
49+
set -- "$@" --license-policy "$policy"
50+
fi
51+
if [ -n "$failon" ]; then
52+
set -- "$@" --fail-on "$failon"
53+
fi
54+
if [ -n "$sariffile" ]; then
55+
set -- "$@" --sarif "$sariffile"
56+
fi
4057
# shellcheck disable=SC2086
4158
set -- "$@" "$fmt_flag" "$outfile" $extra
4259

0 commit comments

Comments
 (0)