169 lines
8.1 KiB
Markdown
169 lines
8.1 KiB
Markdown
# sbom-tools-action
|
|
|
|
Composite action that installs Trivy and the CycloneDX CLI with caching, ready for SBOM generation workflows.
|
|
|
|
## Why
|
|
|
|
The previous setup pinned `TRIVY_VERSION` and `CYCLONEDX_CLI_VERSION` in every consuming workflow. When the upstream `trivy/contrib/install.sh` started failing for older release-asset layouts, every repo needed a PR to bump. This action centralises the install logic and reads versions as inputs (typically wired to the gitea instance variables `vars.TRIVY_VERSION` / `vars.CYCLONEDX_CLI_VERSION`).
|
|
|
|
## Usage
|
|
|
|
```yaml
|
|
- uses: https://git.janhouse.lv/janhouse/sbom-tools-action@v1
|
|
with:
|
|
trivy-version: ${{ vars.TRIVY_VERSION }}
|
|
cyclonedx-version: ${{ vars.CYCLONEDX_CLI_VERSION }}
|
|
```
|
|
|
|
After this step, `trivy` and `cyclonedx-cli` are on `PATH`. Cache is keyed on the runner OS + both versions, so a bump invalidates and reinstalls automatically.
|
|
|
|
## Inputs
|
|
|
|
| Name | Description | Required |
|
|
| --- | --- | --- |
|
|
| `trivy-version` | Trivy release tag, e.g. `v0.70.0`. | yes |
|
|
| `cyclonedx-version` | CycloneDX CLI release tag, e.g. `v0.27.1`. | yes |
|
|
|
|
Both inputs are required so the consumer is explicit about source. Wire them to gitea instance vars to avoid hardcoding.
|
|
|
|
## Versioning
|
|
|
|
The repo follows lightweight tags: `v1`, `v1.0.0`, etc. Consumers pin to `@v1` for in-major updates, or `@<sha>` for full pinning.
|
|
|
|
## `scan` — SBOM, osv-scanner and the triage report (v2)
|
|
|
|
`uses: https://git.janhouse.lv/janhouse/sbom-tools-action/scan@v2` uploads the
|
|
repo's source SBOM to Dependency-Track, runs osv-scanner over the repo, and
|
|
reports to dtrack-panel which images the repo builds and its
|
|
`osv-scanner.toml` `[[IgnoredVulns]]`. The panel's auto-triage then marks
|
|
those NOT_AFFECTED in Dependency-Track — for the CI project and for the app's
|
|
own dependency tree in the running images — and closes CI-project findings for
|
|
dependencies that never reach the image (dev/build-time). VEX files under
|
|
`.vex/` (OpenVEX or CycloneDX VEX, `*.json`) are reported too. Inputs and an
|
|
example are in `scan/action.yml`. Authenticates with the same
|
|
`DEPENDENCY_TRACK_API_KEY` the upload uses; no extra secret.
|
|
|
|
Every decision holds for the package versions present when it was written,
|
|
until its `ignoreUntil` / `review_by` (default 90 days after it was added or
|
|
last changed), and while the CVE is not known-exploited (CISA KEV). Then the
|
|
panel reopens the findings (IN_TRIAGE) and the job log warns "VEX re-check
|
|
due". Re-check; editing the entry (e.g. a new `ignoreUntil`) re-confirms it.
|
|
|
|
## `vex` — the central VEX repo
|
|
|
|
`uses: https://git.janhouse.lv/janhouse/sbom-tools-action/[email protected]` posts every
|
|
`*.json` under `vex/` (OpenVEX or CycloneDX VEX) to dtrack-panel
|
|
(`/panel-ci/vex`): statements about third-party images and packages, applied
|
|
to the images they name, or wherever the package appears. The repo's complete
|
|
set each run; a removed statement withdraws its decisions. A rejected file
|
|
(invalid JSON, `not_affected` without justification or reason) fails the job.
|
|
|
|
## `osv-followup` — weekly advisories to Claude, monthly re-check (v2.4.1)
|
|
|
|
`uses: https://git.janhouse.lv/janhouse/sbom-tools-action/[email protected]`
|
|
is the follow-up half of `scan`: `scan` reports, `osv-followup` gets every
|
|
advisory decided.
|
|
|
|
- **Weekly (`scan`).** osv-scanner (pinned version + sha256) scans every
|
|
lockfile in the repo (`bun.lock`, `go.mod`, `requirements.txt`, ...) with
|
|
`--config osv-scanner.toml`, so one file at the root covers them all.
|
|
Advisories that the file does not cover and that no **open** issue labelled
|
|
`osv-followup` lists (hidden `<!-- osv-followup: ids -->` marker, every
|
|
alias counts) go into one new issue: per advisory the summary, severity,
|
|
package, version, lockfile and fixed versions, then a `@claude` request
|
|
with the repo's `context`. Claude (gitea-claude-bot → gitea-claude-runner)
|
|
either upgrades to a fixed version (within the repo's rules: CLAUDE.md,
|
|
AGENTS.md, FORK.md, bunfig `minimumReleaseAge`) or adds an entry whose
|
|
`reason` names the code and why it is safe, and opens one PR that closes the
|
|
issue. Nothing is merged automatically. An issue closed without its PR
|
|
being merged comes back the next week: the way to silence an advisory is an
|
|
entry, never closing the issue.
|
|
- **Monthly (`recheck`).** osv-scanner runs again with **no** ignores. Entries
|
|
whose advisory no longer matches any dependency are removed in a PR from
|
|
`osv/prune-<date>` (line-based, the rest of the file and its comments stay;
|
|
re-parsed before pushing; pushed with the token through `GIT_ASKPASS`).
|
|
The remaining entries go into one `osv-recheck` issue asking `@claude` to
|
|
verify each reason against today's code, refresh `ignoreUntil` on the ones
|
|
that still hold, rewrite inaccurate ones and remove the ones that no longer
|
|
hold. Neither is opened twice while one is open.
|
|
- `group-by: run` (default) puts all new advisories of a run in one issue:
|
|
one Claude run, one PR, no `osv-scanner.toml` merge conflicts between PRs.
|
|
`group-by: package` opens one issue per package (parallel PRs that each
|
|
append to the file will conflict).
|
|
|
|
### Entry format
|
|
|
|
```toml
|
|
# --- better-auth ---
|
|
|
|
# CVE-2026-110861
|
|
[[IgnoredVulns]]
|
|
id = "GHSA-44jh-23m7-hpcf"
|
|
ignoreUntil = 2027-02-17
|
|
reason = "code_not_reachable: only database-stored rate-limit records race; server/auth.ts keeps them in memory (no storage, no secondaryStorage)."
|
|
```
|
|
|
|
`reason` starts with a CycloneDX justification (`code_not_present`,
|
|
`code_not_reachable`, `requires_configuration`, `requires_dependency`,
|
|
`requires_environment`, `protected_by_compiler`, `protected_at_runtime`,
|
|
`protected_at_perimeter`, `protected_by_mitigating_control`), which
|
|
dtrack-panel maps to the Dependency-Track analysis. `ignoreUntil` (90 days
|
|
by default) is read by both osv-scanner and dtrack-panel: when it passes,
|
|
the panel reopens the findings and the weekly scan reports the advisory as
|
|
new (with the old reason quoted), so an entry nobody re-confirms expires
|
|
instead of hiding an advisory forever. osv-scanner 2.7 prints a deprecation
|
|
warning for `ignoreUntil` (its new name is `effectiveUntil`); keep
|
|
`ignoreUntil` until dtrack-panel reads the new key.
|
|
|
|
### Consumer workflow
|
|
|
|
```yaml
|
|
name: Security
|
|
on:
|
|
schedule:
|
|
- cron: '17 5 * * 1' # weekly: new advisories (Monday 05:17 UTC)
|
|
- cron: '47 6 1 * *' # monthly: re-check osv-scanner.toml (the 1st, 06:47 UTC)
|
|
workflow_dispatch:
|
|
inputs:
|
|
recheck:
|
|
description: Re-check osv-scanner.toml instead of scanning
|
|
type: boolean
|
|
default: false
|
|
dry_run:
|
|
description: Print instead of opening issues / PRs
|
|
type: boolean
|
|
default: false
|
|
concurrency:
|
|
group: security
|
|
cancel-in-progress: false
|
|
jobs:
|
|
osv:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: https://git.janhouse.lv/janhouse/sbom-tools-action/[email protected]
|
|
with:
|
|
mode: ${{ (inputs.recheck == true || inputs.recheck == 'true') && 'recheck' || 'auto' }}
|
|
recheck-cron: '47 6 1 * *'
|
|
dry-run: ${{ inputs.dry_run == true || inputs.dry_run == 'true' }}
|
|
token: ${{ secrets.DEPS_BOT_TOKEN }}
|
|
discord-webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
|
context: >-
|
|
What the app is, how and where it runs, what is exposed to whom,
|
|
which parts are build/test-only, and repo-specific rules.
|
|
```
|
|
|
|
`mode: auto` tells the two crons apart by `github.event.schedule`; when the
|
|
Gitea version sends none, a scheduled run on the 1st at or after
|
|
`recheck-hour` (default 6) UTC is the re-check, so keep the weekly cron
|
|
before 06:00 UTC and the monthly one after it, on different hours.
|
|
|
|
Requirements: the token's account (`bot`, `DEPS_BOT_TOKEN`) has write access
|
|
to the repo, and the repo is in gitea-claude-bot's allowlist (the bot only
|
|
acts on `@claude` from writers). The runner may not edit `.gitea/workflows`
|
|
or `.claude/`, so a fix that needs a workflow change ends as a comment.
|
|
|
|
Local test: `OSV_OFFLINE=1 DRY_RUN=true MODE=scan SERVER_URL=https://git.janhouse.lv REPOSITORY=owner/repo OSV_SCANNER=/path/to/osv-scanner python3 -I osv-followup/followup.py`
|
|
in the repo prints the issue it would open without talking to Gitea.
|