2 Commits

Author SHA1 Message Date
t.behrendt 81eda53a59 refactor(setup-db): to run trivy in docker (#54)
CD / Release (push) Successful in 4s
As part of our safety initiative, I'm refactoring setup-db to run trivy inside a Docker container with minimal privileges, reducing leakage of secrets, files, etc. to a minimum in case the dependency gets compromised.
Additionally, we are always pinning the trivy docker image to a fixed digest. Renovate has been configured to keep the Trivy image version up-to-date.

Reviewed-on: #54
Reviewed-by: branch-buddy <branch-buddy@t00n.de>
Co-authored-by: Timo Behrendt <t.behrendt@t00n.de>
Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
2026-04-10 18:43:03 +02:00
renovate-bot a9ff551b88 chore(deps): update https://gitea.t000-n.de/t.behrendt/actions action to v0.2.1 (#49)
CD / Release (push) Successful in 1m14s
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [https://gitea.t000-n.de/t.behrendt/actions](https://gitea.t000-n.de/t.behrendt/actions) | action | minor | `0.1.5` → `0.2.1` |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the Dependency Dashboard for more information.

---

### Release Notes

<details>
<summary>t.behrendt/actions (https://gitea.t000-n.de/t.behrendt/actions)</summary>

### [`v0.2.1`](https://gitea.t000-n.de/t.behrendt/actions/compare/0.2.0...0.2.1)

[Compare Source](https://gitea.t000-n.de/t.behrendt/actions/compare/0.2.0...0.2.1)

### [`v0.2.0`](https://gitea.t000-n.de/t.behrendt/actions/compare/0.1.7...0.2.0)

[Compare Source](https://gitea.t000-n.de/t.behrendt/actions/compare/0.1.7...0.2.0)

### [`v0.1.7`](https://gitea.t000-n.de/t.behrendt/actions/compare/0.1.6...0.1.7)

[Compare Source](https://gitea.t000-n.de/t.behrendt/actions/compare/0.1.6...0.1.7)

### [`v0.1.6`](https://gitea.t000-n.de/t.behrendt/actions/compare/0.1.5...0.1.6)

[Compare Source](https://gitea.t000-n.de/t.behrendt/actions/compare/0.1.5...0.1.6)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My41LjQiLCJ1cGRhdGVkSW5WZXIiOiI0My41LjQiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbImFjdGlvbiIsImRlcHMiXX0=-->

Reviewed-on: t.behrendt/trivy-actions#49
Reviewed-by: t.behrendt <t.behrendt@noreply.localhost>
Co-authored-by: Renovate Bot <renovate@t00n.de>
Co-committed-by: Renovate Bot <renovate@t00n.de>
2026-03-15 21:52:37 +01:00
5 changed files with 44 additions and 7 deletions
+1 -1
View File
@@ -19,6 +19,6 @@ jobs:
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@74e7be819ecfc1a8d3e3fcf679e8f3e0a7065343 # 0.1.5 uses: https://gitea.t000-n.de/t.behrendt/actions/release-git-tag@3925c92fc33f3d2bc87d28d21ab691b7e6dd6cdf # 0.2.1
with: with:
tag: ${{ steps.tag.outputs.new-tag }} tag: ${{ steps.tag.outputs.new-tag }}
+1 -1
View File
@@ -18,6 +18,6 @@ jobs:
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@74e7be819ecfc1a8d3e3fcf679e8f3e0a7065343 # 0.1.5 uses: https://gitea.t000-n.de/t.behrendt/actions/release-git-tag@3925c92fc33f3d2bc87d28d21ab691b7e6dd6cdf # 0.2.1
with: with:
tag: ${{ steps.tag.outputs.new-tag }} tag: ${{ steps.tag.outputs.new-tag }}
+11
View File
@@ -4,6 +4,17 @@
"local>t.behrendt/renovate-configs:common", "local>t.behrendt/renovate-configs:common",
"local>t.behrendt/renovate-configs:action" "local>t.behrendt/renovate-configs:action"
], ],
"customManagers": [
{
"customType": "regex",
"description": "Update Trivy docker image",
"managerFilePatterns": ["/(^|/)setup-db/action\\.ya?ml$/"],
"datasourceTemplate": "docker",
"matchStrings": [
"default:\\s*\"(?<depName>ghcr\\.io/aquasecurity/trivy):(?<currentValue>[\\d\\.]+)(?:@(?<currentDigest>sha256:[a-f0-9]+))?\""
]
}
],
"packageRules": [ "packageRules": [
{ {
"matchManagers": ["dockerfile", "kubernetes", "helmfile", "helm-values"], "matchManagers": ["dockerfile", "kubernetes", "helmfile", "helm-values"],
+9 -4
View File
@@ -2,7 +2,9 @@
A reusable Gitea Action that sets up the Trivy 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. Trivy itself must be installed separately (e.g., using the `setup-trivy` action). The action runs Trivy inside **Docker** with a restricted container configuration so the Trivy runtime is isolated from the host while the database is downloaded into your cache directory.
**Note:** This action only prepares the vulnerability database. If you run Trivy on the runner host for scans (for example `trivy fs .`), install Trivy separately (e.g. with a `setup-trivy` action or your own step).
## Usage ## Usage
@@ -36,6 +38,9 @@ jobs:
## Inputs ## Inputs
| Input | Description | Required | Default | | Input | Description | Required | Default |
| ----------- | --------------------------------- | -------- | ---------------- | | ---------------- | --------------------------------------------------------------------------- | -------- | ------- |
| `cache-dir` | Path to the Trivy cache directory | No | `~/.cache/trivy` | | `cache-dir` | Path to the Trivy cache directory | No | `${{ runner.temp }}/trivy` |
| `trivy-version` | Docker image reference for Trivy (digest pin recommended) | No | Pinned `ghcr.io/aquasecurity/trivy` image in `action.yaml` |
**`trivy-version` is optional.** If you omit it, the action uses the default image (version and digest) from `action.yaml`. Set it only when you need a different Trivy image or your own digest pin.
+22 -1
View File
@@ -10,6 +10,10 @@ inputs:
description: "Path to the Trivy cache directory (default: ${{runner.temp}}/trivy)" description: "Path to the Trivy cache directory (default: ${{runner.temp}}/trivy)"
required: false required: false
default: "${{ runner.temp }}/trivy" default: "${{ runner.temp }}/trivy"
trivy-version:
description: "Trivy docker image version to use (full image reference including digest is recommended)"
required: false
default: "ghcr.io/aquasecurity/trivy:0.69.3@sha256:bcc376de8d77cfe086a917230e818dc9f8528e3c852f7b1aff648949b6258d1c"
outputs: outputs:
cache-dir: cache-dir:
@@ -32,4 +36,21 @@ runs:
trivy-db-${{ steps.current-date.outputs.current-date }} trivy-db-${{ steps.current-date.outputs.current-date }}
- if: steps.restore-db.outputs.cache-hit != 'true' - if: steps.restore-db.outputs.cache-hit != 'true'
shell: bash shell: bash
run: trivy fs --download-db-only --cache-dir "${{ inputs.cache-dir }}" run: |
docker run --rm \
--name trivy-db-download \
--user "$(id -u):$(id -g)" \
--read-only \
--env-file /dev/null \
--cap-drop ALL \
--pids-limit 64 \
--memory=512m \
--memory-swap=512m \
--cpus=1 \
--ipc private \
--cgroupns private \
--security-opt no-new-privileges \
--security-opt apparmor=docker-default \
--tmpfs /tmp:rw,noexec,nosuid,nodev,size=1g \
--mount type=bind,src=${{ inputs.cache-dir }},dst=/cache \
${{ inputs.trivy-version }} fs --download-db-only --cache-dir /cache