1 Commits

Author SHA1 Message Date
renovate-bot ac681e37c8 chore(deps): update https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment action to v0.1.36
renovate/stability-days Updates have met minimum release age requirement
CI / Test Setup Trivy amd64 (pull_request) Successful in 9s
CI / Test Setup DB (pull_request) Successful in 15s
CI / Test Get Images From Files (pull_request) Successful in 6s
CI / Test Merge SARIF Files (pull_request) Successful in 5s
CI / Test Setup Trivy arm64 (pull_request) Successful in 51s
2026-06-20 17:56:44 +00:00
11 changed files with 152 additions and 280 deletions
+2 -2
View File
@@ -15,10 +15,10 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Increment tag - name: Increment tag
id: tag id: tag
uses: https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment@e393dbb067c09fd43519392572ccf63b66cba92d # 0.1.39 uses: https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment@d6ea474a97989499561ba86fa974ad33215369f0 # 0.1.36
with: with:
token: ${{ secrets.GITEA_TOKEN }} token: ${{ secrets.GITEA_TOKEN }}
- name: Push tag - name: Push tag
uses: https://gitea.t000-n.de/t.behrendt/actions/release-git-tag@0841ccc70fc2c1526123785f3b0a510a6ba4bdfc # 0.2.7 uses: https://gitea.t000-n.de/t.behrendt/actions/release-git-tag@38c1bbd8bad3e7965744d03de85faa4a5b808d1b # 0.2.4
with: with:
tag: ${{ steps.tag.outputs.new-tag }} tag: ${{ steps.tag.outputs.new-tag }}
+9 -26
View File
@@ -4,24 +4,20 @@ on:
pull_request: pull_request:
jobs: jobs:
test-setup-osv: test-setup-trivy:
strategy: strategy:
matrix: matrix:
arch: [amd64, arm64] arch: [amd64, arm64]
name: Test Setup OSV Scanner ${{ matrix.arch }} name: Test Setup Trivy ${{ matrix.arch }}
runs-on: runs-on:
- ubuntu-latest - ubuntu-latest
- linux_${{ matrix.arch }} - linux_${{ matrix.arch }}
steps: steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup OSV Scanner - name: Setup Trivy
uses: ./setup-osv uses: ./setup-trivy
with: - name: Run Trivy
version: v2.4.0 run: trivy --version
amd64-digest: 15314940c10d26af9c6649f150b8a47c1262e8fc7e17b1d1029b0e479e8ed8a0
arm64-digest: 44e580752910f0ff36ec99aff59af20f65df1e859aa31e5605a8f0d055b496e9
- name: Run osv-scanner
run: osv-scanner --version
test-setup-db: test-setup-db:
name: Test Setup DB name: Test Setup DB
@@ -29,25 +25,12 @@ jobs:
- ubuntu-latest - ubuntu-latest
steps: steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: ./setup-osv - uses: ./setup-trivy
with:
version: v2.4.0
amd64-digest: 15314940c10d26af9c6649f150b8a47c1262e8fc7e17b1d1029b0e479e8ed8a0
arm64-digest: 44e580752910f0ff36ec99aff59af20f65df1e859aa31e5605a8f0d055b496e9
- name: Setup DB - name: Setup DB
id: setup-db id: setup-db
uses: ./setup-db uses: ./setup-db
with: - name: Run Trivy
# Keep CI fast; full ecosystem download is covered by the action default. run: trivy fs --skip-db-update --cache-dir ${{ steps.setup-db.outputs.cache-dir }} .
ecosystems: Go,npm,PyPI
- name: Run osv-scanner offline
run: |
test -n "${OSV_SCANNER_LOCAL_DB_CACHE_DIRECTORY}"
test "${OSV_SCANNER_LOCAL_DB_CACHE_DIRECTORY}" = "${{ steps.setup-db.outputs.cache-dir }}"
test -f "${OSV_SCANNER_LOCAL_DB_CACHE_DIRECTORY}/osv-scanner/Go/all.zip"
test -f "${OSV_SCANNER_LOCAL_DB_CACHE_DIRECTORY}/osv-scanner/npm/all.zip"
test -f "${OSV_SCANNER_LOCAL_DB_CACHE_DIRECTORY}/osv-scanner/PyPI/all.zip"
osv-scanner scan source --offline-vulnerabilities --allow-no-lockfiles .
test-get-images-from-files: test-get-images-from-files:
name: Test Get Images From Files name: Test Get Images From Files
+2 -2
View File
@@ -13,11 +13,11 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Increment tag - name: Increment tag
id: tag id: tag
uses: https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment@e393dbb067c09fd43519392572ccf63b66cba92d # 0.1.39 uses: https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment@d6ea474a97989499561ba86fa974ad33215369f0 # 0.1.36
with: with:
token: ${{ secrets.GITEA_TOKEN }} token: ${{ secrets.GITEA_TOKEN }}
prerelease: true prerelease: true
- name: Push tag - name: Push tag
uses: https://gitea.t000-n.de/t.behrendt/actions/release-git-tag@0841ccc70fc2c1526123785f3b0a510a6ba4bdfc # 0.2.7 uses: https://gitea.t000-n.de/t.behrendt/actions/release-git-tag@38c1bbd8bad3e7965744d03de85faa4a5b808d1b # 0.2.4
with: with:
tag: ${{ steps.tag.outputs.new-tag }} tag: ${{ steps.tag.outputs.new-tag }}
+2 -2
View File
@@ -1,3 +1,3 @@
# OSV Scanner Actions # Trivy Actions
Gitea compatible actions related to osv-scanner or the OSV ecosystem. Gitea compatible actions related to Trivy or the Trivy ecosystem.
+10 -2
View File
@@ -1,5 +1,13 @@
{ {
"$schema": "https://docs.renovatebot.com/renovate-schema.json", "$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["local>t.behrendt/renovate-configs:action"], "extends": [
"enabledManagers": "github-actions" "local>t.behrendt/renovate-configs:common",
"local>t.behrendt/renovate-configs:action"
],
"packageRules": [
{
"matchManagers": ["dockerfile", "kubernetes", "helmfile", "helm-values"],
"ignorePaths": ["get-images-from-files/test*"]
}
]
} }
+10 -22
View File
@@ -1,8 +1,8 @@
# Setup DB Action # Setup DB Action
A reusable Gitea Action that sets up the osv-scanner offline vulnerability database, restoring from cache if available. A reusable Gitea Action that sets up the Trivy vulnerability database, restoring from cache if available.
**Note:** This action only sets up the database. osv-scanner itself must be installed separately (e.g., using the `setup-osv` action). Subsequent steps receive `OSV_SCANNER_LOCAL_DB_CACHE_DIRECTORY` via the environment. **Note:** This action only sets up the database. Trivy itself must be installed separately (e.g., using the `setup-trivy` action).
## Usage ## Usage
@@ -10,7 +10,7 @@ A reusable Gitea Action that sets up the osv-scanner offline vulnerability datab
```yaml ```yaml
- name: Setup DB - name: Setup DB
uses: https://gitea.t000-n.de/t.behrendt/osv-scanner-actions/setup-db@0.0.1 uses: https://gitea.t000-n.de/t.behrendt/trivy-actions/setup-db@0.0.1
``` ```
### Complete Example ### Complete Example
@@ -26,28 +26,16 @@ jobs:
- linux_amd64 - linux_amd64
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup OSV Scanner - name: Setup Trivy
uses: https://gitea.t000-n.de/t.behrendt/osv-scanner-actions/setup-osv@0.0.1 uses: https://gitea.t000-n.de/t.behrendt/trivy-actions/setup-trivy@0.0.1
with:
version: "v2.4.0"
amd64-digest: "15314940c10d26af9c6649f150b8a47c1262e8fc7e17b1d1029b0e479e8ed8a0"
arm64-digest: "44e580752910f0ff36ec99aff59af20f65df1e859aa31e5605a8f0d055b496e9"
- name: Setup DB - name: Setup DB
id: setup-db uses: https://gitea.t000-n.de/t.behrendt/trivy-actions/setup-db@0.0.1
uses: https://gitea.t000-n.de/t.behrendt/osv-scanner-actions/setup-db@0.0.1
- name: Scan for vulnerabilities - name: Scan for vulnerabilities
run: osv-scanner scan source --offline-vulnerabilities -r . run: trivy fs .
``` ```
## Inputs ## Inputs
| Input | Description | Required | Default | | Input | Description | Required | Default |
| ------------- | --------------------------------------------------------------------------- | -------- | -------------------------------- | | ----------- | --------------------------------- | -------- | ---------------- |
| `cache-dir` | Path used as `OSV_SCANNER_LOCAL_DB_CACHE_DIRECTORY` | No | `${{ runner.temp }}/osv-scanner` | | `cache-dir` | Path to the Trivy cache directory | No | `~/.cache/trivy` |
| `ecosystems` | Comma-separated OSV ecosystems to download; empty downloads all ecosystems | No | _(all)_ |
## Outputs
| Output | Description |
| ----------- | ------------------------------------------------ |
| `cache-dir` | Path to the osv-scanner local DB cache directory |
+10 -69
View File
@@ -1,23 +1,19 @@
name: "Setup OSV Scanner DB" name: "Setup Trivy DB"
description: "Setup the osv-scanner offline vulnerability database, restoring from cache if available" description: "Setup the trivy database, restoring from cache if available"
author: "Timo Behrendt <t.behrendt@t00n.de>" author: "Timo Behrendt <t.behrendt@t00n.de"
branding: branding:
icon: "database" icon: "database"
color: "blue" color: "blue"
inputs: inputs:
cache-dir: cache-dir:
description: "Path used as OSV_SCANNER_LOCAL_DB_CACHE_DIRECTORY (default: ${{runner.temp}}/osv-scanner)" description: "Path to the Trivy cache directory (default: ${{runner.temp}}/trivy)"
required: false required: false
default: "${{ runner.temp }}/osv-scanner" default: "${{ runner.temp }}/trivy"
ecosystems:
description: "Comma-separated list of OSV ecosystems to download. Empty downloads all ecosystems."
required: false
default: ""
outputs: outputs:
cache-dir: cache-dir:
description: "Path to the osv-scanner local DB cache directory" description: "Path to the Trivy cache directory"
value: ${{ inputs.cache-dir }} value: ${{ inputs.cache-dir }}
runs: runs:
@@ -31,64 +27,9 @@ runs:
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with: with:
path: ${{ inputs.cache-dir }} path: ${{ inputs.cache-dir }}
key: osv-scanner-db-${{ steps.current-date.outputs.current-date }} key: trivy-db-${{ steps.current-date.outputs.current-date }}
restore-keys: | restore-keys: |
osv-scanner-db-${{ steps.current-date.outputs.current-date }} trivy-db-${{ steps.current-date.outputs.current-date }}
- name: Download offline databases - if: steps.restore-db.outputs.cache-hit != 'true'
if: steps.restore-db.outputs.cache-hit != 'true'
shell: bash shell: bash
run: | run: trivy fs --download-db-only --cache-dir "${{ inputs.cache-dir }}"
set -euo pipefail
CACHE_DIR="${{ inputs.cache-dir }}"
DB_DIR="${CACHE_DIR}/osv-scanner"
mkdir -p "${DB_DIR}"
ECOSYSTEMS_INPUT="${{ inputs.ecosystems }}"
if [ -n "${ECOSYSTEMS_INPUT}" ]; then
# shellcheck disable=SC2001
ECOSYSTEMS=$(echo "${ECOSYSTEMS_INPUT}" | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | grep -v '^$' || true)
else
ECOSYSTEMS=$(curl -fsSL https://osv-vulnerabilities.storage.googleapis.com/ecosystems.txt | grep -v '^$' | grep -v '^\[EMPTY\]$' || true)
fi
if [ -z "${ECOSYSTEMS}" ]; then
echo "No ecosystems to download" >&2
exit 1
fi
download_one() {
local ecosystem="$1"
local encoded
encoded=$(printf '%s' "${ecosystem}" | jq -sRr @uri)
local dest="${DB_DIR}/${ecosystem}"
mkdir -p "${dest}"
echo "Downloading ${ecosystem}..."
curl -fsSL "https://osv-vulnerabilities.storage.googleapis.com/${encoded}/all.zip" -o "${dest}/all.zip"
}
max_jobs=8
pids=()
while IFS= read -r ecosystem; do
[ -z "${ecosystem}" ] && continue
while [ "$(jobs -rp | wc -l)" -ge "${max_jobs}" ]; do
sleep 0.2
done
download_one "${ecosystem}" &
pids+=("$!")
done <<< "${ECOSYSTEMS}"
fail=0
for pid in "${pids[@]}"; do
wait "${pid}" || fail=1
done
if [ "${fail}" -ne 0 ]; then
echo "One or more ecosystem database downloads failed" >&2
exit 1
fi
echo "Downloaded $(find "${DB_DIR}" -name all.zip | wc -l) ecosystem database(s) to ${DB_DIR}"
- name: Export DB cache directory
shell: bash
run: |
echo "OSV_SCANNER_LOCAL_DB_CACHE_DIRECTORY=${{ inputs.cache-dir }}" >> "$GITHUB_ENV"
-51
View File
@@ -1,51 +0,0 @@
# Setup OSV Scanner Action
A reusable Gitea Action that downloads and sets up the osv-scanner binary for vulnerability scanning.
The downloaded binary is verified against a pinned SHA-256 digest for the runner architecture.
## Usage
### Basic Usage
```yaml
- name: Setup OSV Scanner
uses: your-username/osv-scanner-actions@main/setup-osv
with:
version: "v2.4.0"
amd64-digest: "15314940c10d26af9c6649f150b8a47c1262e8fc7e17b1d1029b0e479e8ed8a0"
arm64-digest: "44e580752910f0ff36ec99aff59af20f65df1e859aa31e5605a8f0d055b496e9"
```
Digests are published in each release's `osv-scanner_SHA256SUMS` file (e.g. for `osv-scanner_linux_amd64` / `osv-scanner_linux_arm64`). You may pass either bare hex or `sha256:<hex>`.
### Complete Example
```yaml
name: Security Scan
on: [push, pull_request]
jobs:
security:
runs-on:
- ubuntu-latest
- linux_amd64
steps:
- uses: actions/checkout@v4
- name: Setup OSV Scanner
uses: your-username/osv-scanner-actions@main/setup-osv
with:
version: "v2.4.0"
amd64-digest: "15314940c10d26af9c6649f150b8a47c1262e8fc7e17b1d1029b0e479e8ed8a0"
arm64-digest: "44e580752910f0ff36ec99aff59af20f65df1e859aa31e5605a8f0d055b496e9"
- name: Scan for vulnerabilities
run: osv-scanner scan source -r .
```
## Inputs
| Input | Description | Required | Default |
| -------------- | -------------------------------------------------------------------- | -------- | ------- |
| `version` | Explicit osv-scanner release tag (e.g. `v2.4.0`). `latest` is rejected | Yes | — |
| `amd64-digest` | SHA-256 of `osv-scanner_linux_amd64` (hex or `sha256:<hex>`) | Yes | — |
| `arm64-digest` | SHA-256 of `osv-scanner_linux_arm64` (hex or `sha256:<hex>`) | Yes | — |
-104
View File
@@ -1,104 +0,0 @@
name: "Setup OSV Scanner"
description: "Download and setup osv-scanner binary for vulnerability scanning"
author: "Gitea Actions"
branding:
icon: "shield"
color: "blue"
inputs:
version:
description: "osv-scanner version to download (e.g., v2.4.0). Must be an explicit release tag; 'latest' is not allowed."
required: true
amd64-digest:
description: "SHA-256 digest of the linux amd64 binary (hex or sha256:<hex>)"
required: true
arm64-digest:
description: "SHA-256 digest of the linux arm64 binary (hex or sha256:<hex>)"
required: true
runs:
using: "composite"
steps:
- name: Resolve architecture and digest
shell: bash
id: arch
run: |
set -euo pipefail
VERSION="${{ inputs.version }}"
if [ -z "${VERSION}" ] || [ "${VERSION}" = "latest" ]; then
echo "version must be an explicit release tag (e.g. v2.4.0); 'latest' is not allowed" >&2
exit 1
fi
case "$(uname -m)" in
x86_64)
ARCH="amd64"
DIGEST="${{ inputs.amd64-digest }}"
;;
aarch64)
ARCH="arm64"
DIGEST="${{ inputs.arm64-digest }}"
;;
*)
echo "Unsupported architecture: $(uname -m)" >&2
exit 1
;;
esac
if [ -z "${DIGEST}" ]; then
echo "Missing digest for architecture ${ARCH}" >&2
exit 1
fi
# Normalize sha256:<hex> / SHA256:<hex> to bare hex
DIGEST="${DIGEST#sha256:}"
DIGEST="${DIGEST#SHA256:}"
if ! [[ "${DIGEST}" =~ ^[a-fA-F0-9]{64}$ ]]; then
echo "Invalid ${ARCH} digest (expected 64-char hex or sha256:<hex>): ${DIGEST}" >&2
exit 1
fi
echo "ARCH=${ARCH}" >> "$GITHUB_OUTPUT"
echo "DIGEST=${DIGEST}" >> "$GITHUB_OUTPUT"
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Cache osv-scanner binary
id: cache-osv
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: /usr/local/bin/osv-scanner
key: osv-scanner-${{ steps.arch.outputs.version }}-${{ steps.arch.outputs.arch }}-${{ steps.arch.outputs.digest }}
restore-keys: |
osv-scanner-${{ steps.arch.outputs.version }}-${{ steps.arch.outputs.arch }}-${{ steps.arch.outputs.digest }}
- name: Download and install osv-scanner
if: steps.cache-osv.outputs.cache-hit != 'true'
shell: bash
run: |
set -euo pipefail
VERSION="${{ steps.arch.outputs.version }}"
ARCH="${{ steps.arch.outputs.arch }}"
EXPECTED_DIGEST="${{ steps.arch.outputs.digest }}"
DEST="/usr/local/bin/osv-scanner"
mkdir -p /usr/local/bin
curl -fsSL "https://github.com/google/osv-scanner/releases/download/${VERSION}/osv-scanner_linux_${ARCH}" -o "${DEST}"
ACTUAL_DIGEST=$(sha256sum "${DEST}" | awk '{print $1}')
if [ "${ACTUAL_DIGEST}" != "${EXPECTED_DIGEST}" ]; then
echo "Digest mismatch for osv-scanner ${VERSION} (linux_${ARCH})" >&2
echo " expected: ${EXPECTED_DIGEST}" >&2
echo " actual: ${ACTUAL_DIGEST}" >&2
rm -f "${DEST}"
exit 1
fi
chmod +x "${DEST}"
echo "Verified osv-scanner ${VERSION} (linux_${ARCH}) digest ${ACTUAL_DIGEST}"
- name: Add osv-scanner to PATH
shell: bash
run: |
echo "/usr/local/bin" >> "$GITHUB_PATH"
+39
View File
@@ -0,0 +1,39 @@
# Setup Trivy Action
A reusable Gitea Action that downloads and sets up the Trivy binary for vulnerability scanning.
## Usage
### Basic Usage
```yaml
- name: Setup Trivy
uses: your-username/trivy-actions@main/setup-trivy
with:
version: "v0.66.0" # Optional: Trivy version (default: latest)
```
### Complete Example
```yaml
name: Security Scan
on: [push, pull_request]
jobs:
security:
runs-on:
- ubuntu-latest
- linux_amd64
steps:
- uses: actions/checkout@v4
- name: Setup Trivy
uses: your-username/trivy-actions@main/setup-trivy
- name: Scan for vulnerabilities
run: trivy fs .
```
## Inputs
| Input | Description | Required | Default |
| --------- | ----------------------------------------- | -------- | -------- |
| `version` | Trivy version to download (e.g., v0.66.0) | No | `latest` |
+68
View File
@@ -0,0 +1,68 @@
name: "Setup Trivy"
description: "Download and setup Trivy binary for vulnerability scanning"
author: "Gitea Actions"
branding:
icon: "shield"
color: "blue"
inputs:
version:
description: "Trivy version to download (e.g., latest)"
required: false
default: "latest"
runs:
using: "composite"
steps:
- shell: bash
id: arch
run: |
set -e
case "$(uname -m)" in
x86_64)
ARCH="64bit"
;;
aarch64)
ARCH="ARM64"
;;
esac
echo "ARCH=$ARCH" >> $GITHUB_OUTPUT
- name: Resolve version
shell: bash
id: version
run: |
set -e
if [ "${{ inputs.version }}" = "latest" ]; then
VERSION=$(curl -s https://api.github.com/repos/aquasecurity/trivy/releases/latest | jq -r '.tag_name')
else
VERSION="${{ inputs.version }}"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Cache Trivy binary
id: cache-trivy
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: /usr/local/bin/trivy
key: trivy-${{ steps.version.outputs.version }}-${{ steps.arch.outputs.arch }}
restore-keys: |
trivy-${{ steps.version.outputs.version }}-${{ steps.arch.outputs.arch }}
- name: Download and install Trivy
if: steps.cache-trivy.outputs.cache-hit != 'true'
shell: bash
run: |
set -e
VERSION="${{ steps.version.outputs.version }}"
mkdir -p /usr/local/bin
curl -sL "https://github.com/aquasecurity/trivy/releases/download/${VERSION}/trivy_${VERSION#v}_Linux-${{ steps.arch.outputs.arch }}.tar.gz" -o trivy.tar.gz
tar -xzf trivy.tar.gz
chmod +x trivy
mv trivy /usr/local/bin/
rm trivy.tar.gz
- name: Add Trivy to PATH
shell: bash
run: |
echo "/usr/local/bin" >> $GITHUB_PATH