101 lines
3.1 KiB
Markdown
101 lines
3.1 KiB
Markdown
# ci-actions
|
|
|
|
Shared composite actions for Gitea Actions.
|
|
|
|
## trivy-gate
|
|
|
|
Scans a pushed image with Trivy (vulnerabilities + secrets) and fails when it
|
|
finds a **fixable** vulnerability of the given severities (default
|
|
`HIGH,CRITICAL`) or an embedded secret. Vulnerabilities without a fix are
|
|
reported but never block - otherwise a deploy could be stuck forever.
|
|
|
|
Intended order in a pipeline:
|
|
|
|
1. build and push only the immutable tag (`sha-…`)
|
|
2. `trivy-gate` on that tag
|
|
3. move the floating tag (`latest`, `stable-<arch>`) and deploy
|
|
|
|
```yaml
|
|
- id: trivy
|
|
uses: https://git.rfa.cz/tth-pub/ci-actions/trivy-gate@v1
|
|
with:
|
|
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:sha-${{ steps.build.outputs.sha }}
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
platform: linux/arm64 # single-platform non-amd64 images only
|
|
mode: block # or warn
|
|
skip: ${{ inputs.skip_trivy || 'false' }}
|
|
```
|
|
|
|
Source trees (apps that ship no image, e.g. an APK): `scan-type: fs` scans
|
|
the git-tracked files plus lockfiles generated in the job (also gitignored
|
|
ones like Flutter's `pubspec.lock`), so run it after the dependency fetch:
|
|
|
|
```yaml
|
|
- uses: https://git.rfa.cz/tth-pub/ci-actions/trivy-gate@v1.1
|
|
with:
|
|
scan-type: fs
|
|
```
|
|
|
|
Jobs without a Docker daemon (a `container:` image such as Flutter) fall
|
|
back to the pinned Trivy release binary, verified by SHA-256 (`runtime:
|
|
auto`); `jq` is installed with apt when missing.
|
|
|
|
Accepted risks go to `.trivyignore.yaml` in the calling repo, each with a
|
|
statement and an expiry, so they come back on their own:
|
|
|
|
```yaml
|
|
vulnerabilities:
|
|
- id: CVE-2026-12345
|
|
statement: not reachable, the affected feature is disabled
|
|
expired_at: 2026-12-31
|
|
```
|
|
|
|
The vulnerability DB lives in the Docker named volume `trivy-cache` on the
|
|
runner host (refreshed under an exclusive lock, scans read it read-only under
|
|
a shared lock, so parallel matrix jobs are fine).
|
|
|
|
## dtrack-sbom
|
|
|
|
Converts the `trivy-gate` report to CycloneDX and uploads it to
|
|
Dependency-Track. Never fails the job.
|
|
|
|
```yaml
|
|
- uses: https://git.rfa.cz/tth-pub/ci-actions/dtrack-sbom@v1
|
|
with:
|
|
report: ${{ steps.trivy.outputs.report }}
|
|
url: ${{ vars.DTRACK_URL }}
|
|
api-key: ${{ secrets.DTRACK_API_KEY }}
|
|
ca-pem: ${{ vars.RFA_CA_PEM }}
|
|
project: my-image
|
|
version: latest
|
|
```
|
|
|
|
## trivy-gate: misconfigurations
|
|
|
|
`scanners: misconfig` with `scan-type: fs` checks Dockerfiles, compose and
|
|
other IaC in the tree. These findings are reported (HIGH/CRITICAL by
|
|
default) and never block.
|
|
|
|
```yaml
|
|
- uses: https://git.rfa.cz/tth-pub/ci-actions/trivy-gate@v1.2
|
|
with:
|
|
scan-type: fs
|
|
scanners: misconfig
|
|
mode: warn
|
|
```
|
|
|
|
## gitleaks
|
|
|
|
Scans the commits of the push (`before..sha`, first-parent line, merge diffs
|
|
off, so merging upstream into a fork does not report upstream history) for
|
|
secrets, with redacted output. Without a `.gitleaks.toml` in the repo the
|
|
default rules apply with test files and fixtures allowlisted. The release
|
|
binary is verified by SHA-256.
|
|
|
|
```yaml
|
|
- uses: https://git.rfa.cz/tth-pub/ci-actions/gitleaks@v1.2
|
|
with:
|
|
mode: block # or warn
|
|
```
|