Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,30 @@ jobs:
dir=$RUNNER_TEMP/sprockets && mkdir -p "$dir"
cp clients/gallery/ruby/examples/rails/Gemfile.sprockets.lock "$dir/Gemfile.lock"
trivy fs --scanners vuln --ignore-unfixed --exit-code 1 --ignorefile .trivyignore.yaml "$dir"

# The app image production runs (the commit https://api.visualci.com/status reports), daily and by hand: CI's scan of
# an image only gates pull requests, so a CVE published after a deploy is caught here.
live-image:
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
packages: read
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
persist-credentials: false
- uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
with:
install_args: trivy
- run: |
commit=$(curl -fsS --retry 3 --max-time 10 https://api.visualci.com/status | jq -r '.commit // empty')
[[ "$commit" =~ ^[0-9a-f]{40}$ ]] || { echo "::error::no commit from https://api.visualci.com/status"; exit 1; }
trivy image --scanners vuln --ignore-unfixed --severity HIGH,CRITICAL --exit-code 1 --ignorefile .trivyignore.yaml \
"ghcr.io/docspring/visualci-app:$commit"
30 changes: 29 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,11 @@ jobs:
fetch-depth: 0
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
with:
install_args: actionlint shellcheck zizmor betterleaks
install_args: actionlint shellcheck zizmor betterleaks hadolint
- run: actionlint
# The renderer's two warnings (a `cd` and a pipe in the PDFBox download step) wait for its next rebuild: any edit
# to renderer.Dockerfile rebuilds the renderer image (its inputs hash), so it isn't touched for lint alone.
- run: hadolint docker/app.Dockerfile && hadolint --ignore DL3003 --ignore DL4006 docker/renderer.Dockerfile
# The online audits only on pull requests: a new advisory against a pinned action shouldn't turn main red, which
# holds back the CLI release (release.yml waits for a green CI on main) with no code change.
- run: if [ "$EVENT" = pull_request ]; then zizmor --no-progress .; else zizmor --no-progress --offline .; fi
Expand Down Expand Up @@ -709,6 +712,7 @@ jobs:
GH_TOKEN: ${{ github.token }}
run: |
echo "renderer=$(cat docker/renderer.version)" >>"$GITHUB_OUTPUT"
echo "date=$(date -u +%F)" >>"$GITHUB_OUTPUT"
# The CLI release the app's add-to-CI snippets install (frontend/scripts/cli-version.mjs): a build arg, so a
# new release rebuilds the cached frontend layer
cli=$(gh api repos/DocSpring/visualci/releases/latest --jq .tag_name)
Expand Down Expand Up @@ -744,7 +748,10 @@ jobs:
node:24-trixie-slim=docker-image://ghcr.io/docspring/visualci/mirror/node:24-trixie-slim@sha256:efb444a6c8b45a1ebdd70974912147dc2be917714174f52334e236aa23c0e3a6
debian:trixie-slim=docker-image://ghcr.io/docspring/visualci/mirror/debian:trixie-slim@sha256:ab3b3c8c5159eebfca4376430132d53c4d425f869c765ecbe47177a030da575d
push: ${{ env.PUSH == 'true' }}
# Pull requests load it into the runner's Docker for the Trivy scan below; main pushes it.
load: ${{ env.PUSH != 'true' }}
build-args: |
SECURITY_UPDATES_DATE=${{ steps.version.outputs.date }}
BUILD_SHA=${{ github.sha }}
RENDERER_VERSION=${{ steps.version.outputs.renderer }}
VISUALCI_ANALYTICS=1
Expand Down Expand Up @@ -797,6 +804,27 @@ jobs:
env:
DIGEST: ${{ steps.renderer_inputs.outputs.existing || steps.renderer_build.outputs.digest }}
run: echo "digest=$DIGEST" >>"$GITHUB_OUTPUT"
# Trivy on the images: fixable HIGH and CRITICAL vulnerabilities (ignores with an expiry in .trivyignore.yaml),
# and forbidden licences (AGPL and the like). It gates pull requests. On main it only reports, so a CVE published
# today never holds back a deploy; the Audit workflow scans the live app image daily and fails there.
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
with:
install_args: trivy
cache: false
- name: Trivy (app image)
continue-on-error: ${{ env.PUSH == 'true' }}
env:
IMAGE: ghcr.io/docspring/visualci-app:${{ github.sha }}
run: |
trivy image --scanners vuln --ignore-unfixed --severity HIGH,CRITICAL --exit-code 1 --ignorefile .trivyignore.yaml "$IMAGE"
trivy image --scanners license --severity CRITICAL --exit-code 1 "$IMAGE"
# The renderer only reports for now: fixing what it finds means rebuilding it (fresh Debian packages, which can
# move pixels, and a renderer.version bump), done on purpose in its own change (sc-9674).
- name: Trivy (renderer image, report only)
continue-on-error: true
env:
IMAGE: ${{ steps.renderer_inputs.outputs.tag }}
run: trivy image --scanners vuln --ignore-unfixed --severity HIGH,CRITICAL --exit-code 1 --ignorefile .trivyignore.yaml "$IMAGE"

deploy:
needs: [images, site]
Expand Down
7 changes: 7 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# hadolint (Dockerfile lint), run by CI's security job and the pre-commit hook. Fails on warnings and errors.
failure-threshold: warning
ignored:
# Pin apt package versions: Debian's archive drops a superseded version, so a pinned `pkg=1.2-3` stops installing at
# the next security update. The base image is pinned by digest instead (CI's build-contexts, .github/mirror.txt),
# and the app's image takes Debian's security updates on every build.
- DL3008
7 changes: 7 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ design is in `docs/design.md`; read it before changing the architecture, and upd
with a `statement` and an `expired_at` at most six months out. A new dependency licence goes into `deny.toml`'s
allow list only after a look (no copyleft in the CLI or the images). In `deny.toml`, ignores and licences nothing
uses any more fail the job: remove them.
- **Images are linted and scanned.** hadolint checks the Dockerfiles (`.hadolint.yaml`), and Trivy scans the built
images in CI's images job: fixable HIGH/CRITICAL vulnerabilities and forbidden licences fail a pull request (on main
they only report, and the Audit workflow scans the live app image daily). The Dockerfiles' `FROM` lines keep plain
tags: CI replaces each with the digest-pinned mirror copy (`build-contexts`, `.github/mirror.txt`), whose digests
are linux/amd64 only, so pinning them in `FROM` would break local builds on arm64. The app's runtime stage takes
Debian's security updates on every build. Editing `docker/renderer.Dockerfile` rebuilds the renderer (fresh
packages, which can move pixels): bump `docker/renderer.version` and check renders when you do.
- **Hold the merge lock from the final rebase to the merge.** A PR must be up to date with `main` before it merges,
so a merge by one agent sends every other agent's PR back through CI. Take Fleetlayer's lock, one per repository,
around the last rebase, the CI run and the merge, in one script, and only for one PR at a time:
Expand Down
6 changes: 5 additions & 1 deletion docker/app.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ FROM scratch AS bin
COPY --from=build /src/target/release/visualci-app /visualci-app

FROM debian:trixie-slim
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/* \
# Debian's security updates on top of the pinned base image (CI scans the result with Trivy). CI passes today's date,
# so BuildKit's layer cache never keeps yesterday's packages.
ARG SECURITY_UPDATES_DATE=
RUN apt-get update && apt-get upgrade -y --no-install-recommends \
&& apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/* \
&& useradd --uid 10001 --create-home visualci
WORKDIR /app
COPY --from=bin /visualci-app /usr/local/bin/visualci-app
Expand Down
4 changes: 4 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ pre-commit:
zizmor:
glob: "{.github/workflows/*,.github/actions/**/*,.github/zizmor.yml,clients/github-action/action.yml}"
run: zizmor --offline --no-progress .
# The Dockerfiles (.hadolint.yaml). The renderer's two ignores wait for its next rebuild (ci.yml's security job).
hadolint:
glob: "docker/*Dockerfile"
run: hadolint docker/app.Dockerfile && hadolint --ignore DL3003 --ignore DL4006 docker/renderer.Dockerfile
# Secrets in the staged changes (.betterleaks.toml allows the made-up ones).
betterleaks:
run: betterleaks git --pre-commit --staged --no-banner --config .betterleaks.toml .
1 change: 1 addition & 0 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ zizmor = "1.33.1"
betterleaks = "1.10.1"
cargo-deny = "0.22.3"
trivy = "0.77.0"
hadolint = "2.15.1"
Loading