Files
pruefwerk/Dockerfile.agent
T
Sharang ParnerkarandClaude Opus 5.5 ee30ecfddb
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 11m59s
feat(secrets): Betterleaks instead of gitleaks, findings carry over (#516)
- The agent image ships Betterleaks 1.9.0 (MIT, gitleaks' successor by its
  author; pinned with checksum) instead of gitleaks 8.21.2. It reads our
  rules/gitleaks.toml unchanged, incl. the #464/#482 allowlists; `git .`
  replaces `detect --source .`, `dir .` stays. Live validation (which sends
  secrets to their providers) is never passed and a test pins that; the
  scan runs without network.
- The findings keep the scanner name `gitleaks` (finding_store::
  SECRET_SCANNER), so fingerprints (#491) and tracker issues carry over.
- RunFindings::adopt_renamed_secrets: a secret now reported under another
  rule (Betterleaks' composite aws-access-token reports a lone key id as
  generic-api-key; renamed vendor rules) takes over the stored row of the
  same target, file and match whose old rule no longer reports it: same id,
  status, triage and issue, with the new rule, title and severity.
- Compared on every fixture tree: identical results, except two planted
  hard-coded passwords Betterleaks finds in the C firmware fixture
  (generic-password), added to its nightly baseline.
- Docs (tools, guides), test plan check 33.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
2026-10-06 17:46:20 +02:00

184 lines
9.3 KiB
Docker

# Pinned versions of every tool the agent runs. They are also written to
# /opt/pruefwerk/tool-versions.json, so evidence can name the tool that
# produced a finding. Bump a version together with its checksum.
ARG RUST_VERSION=1.98.1
ARG CARGO_AUDIT_VERSION=0.22.2
ARG SYFT_VERSION=1.52.0
ARG SYFT_SHA256=caeedb81fb0491615f1ebd1761e4145d41ee86dd2cc7bf80669f9f5ad9d6133d
ARG BETTERLEAKS_VERSION=1.9.0
ARG BETTERLEAKS_SHA256=f8b185a39ffcece2a1ca82bf3a4e7435cd81963ffd16b7a9128daf75f35f6de7
# SBOM quality score (Interlynk, Apache-2.0), #496. The checksum is the one
# in the release's checksums.txt.
ARG SBOMQS_VERSION=2.1.2
ARG SBOMQS_SHA256=451c800019c81059f86eac2c1344c57572b3436e7e0ffeaa076459d195a39ab8
ARG SEMGREP_VERSION=1.177.0
ARG RUFF_VERSION=0.16.8
# mobsfscan pins an older semgrep; it is installed without its dependencies so
# it runs on the semgrep above, and its other dependencies are pinned here.
ARG MOBSFSCAN_VERSION=1.0.1
# DevSkim (MIT) is published as a .NET tool on nuget.org, not as a release
# binary: the package is pinned by checksum and run on the .NET runtime (MIT).
ARG DEVSKIM_VERSION=1.0.100
ARG DEVSKIM_SHA256=11a08ca73ef1020c4dd8efaf4e34ce0d59df75eed4fcef478724bc6be28f04fd
ARG DOTNET_RUNTIME_VERSION=10.0.12
ARG DOTNET_RUNTIME_SHA512=58388fdde4f13bd703c7a6f7defb3300b17e42ba5fe8bca50066f80f64ac7406620dcdfb4acc1eff7992750c8cc5cff8369dd12d09730c8a9e8760d6032f7f6e
FROM rust:1.94-bookworm AS builder
WORKDIR /app
COPY . .
# The version and commit GET /api/v1/platform/version reports (CI passes the
# latest release tag and the commit); the agent reads them at compile time and
# falls back to the crate version and "unknown" when they are empty.
ARG PRUEFWERK_VERSION=
ARG PRUEFWERK_COMMIT=
# compliance-agent depends on the private firmwerk git repo (platform/firmwerk). Authenticate
# the fetch with a PAT passed as a BuildKit secret (never baked into a layer).
# Build with: DOCKER_BUILDKIT=1 docker build --secret id=git_token,env=PLATFORM_CI_TOKEN ...
RUN --mount=type=secret,id=git_token \
if [ -s /run/secrets/git_token ]; then \
git config --global \
url."https://platform-ci:$(cat /run/secrets/git_token)@git.breakpilot.com/".insteadOf \
"ssh://git@git.breakpilot.com:22222/"; \
fi && \
CARGO_NET_GIT_FETCH_WITH_CLI=true cargo build --release -p compliance-agent
# cargo-audit is compiled here, where a C toolchain exists, so the runtime image
# needs none.
FROM rust:1.94-bookworm AS cargo-audit
ARG CARGO_AUDIT_VERSION
RUN cargo install cargo-audit --version "${CARGO_AUDIT_VERSION}" --locked
# The runtime without the agent binary: every scanner, pinned. Buildable on its
# own (`--target tools`), which is how the tool installs are tested.
FROM debian:bookworm-slim AS tools
ARG RUST_VERSION
ARG CARGO_AUDIT_VERSION
ARG SYFT_VERSION
ARG SYFT_SHA256
ARG BETTERLEAKS_VERSION
ARG BETTERLEAKS_SHA256
ARG SBOMQS_VERSION
ARG SBOMQS_SHA256
ARG SEMGREP_VERSION
ARG RUFF_VERSION
ARG MOBSFSCAN_VERSION
ARG DEVSKIM_VERSION
ARG DEVSKIM_SHA256
ARG DOTNET_RUNTIME_VERSION
ARG DOTNET_RUNTIME_SHA512
# No recommended packages: python3-pip would otherwise pull in a full C
# toolchain, which nothing at runtime needs.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates libssl3 git curl python3 python3-pip npm cppcheck \
&& rm -rf /var/lib/apt/lists/*
# Cargo resolves Rust lockfiles and metadata for the SBOM stage. Installed
# system-wide so the unprivileged user can run it; its caches go to the user's
# CARGO_HOME below.
ENV RUSTUP_HOME=/usr/local/rustup \
PATH=/usr/local/cargo/bin:${PATH}
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| CARGO_HOME=/usr/local/cargo sh -s -- -y --no-modify-path --profile minimal \
--default-toolchain "${RUST_VERSION}"
RUN curl -sSfL -o /tmp/syft.tar.gz \
"https://github.com/anchore/syft/releases/download/v${SYFT_VERSION}/syft_${SYFT_VERSION}_linux_amd64.tar.gz" \
&& echo "${SYFT_SHA256} /tmp/syft.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/syft.tar.gz -C /usr/local/bin syft \
&& rm /tmp/syft.tar.gz
# Betterleaks (MIT), gitleaks' successor by its author (#516): reads our
# gitleaks.toml. Its live validation is never switched on.
RUN curl -sSfL -o /tmp/betterleaks.tar.gz \
"https://github.com/betterleaks/betterleaks/releases/download/v${BETTERLEAKS_VERSION}/betterleaks_${BETTERLEAKS_VERSION}_linux_x64.tar.gz" \
&& echo "${BETTERLEAKS_SHA256} /tmp/betterleaks.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/betterleaks.tar.gz -C /usr/local/bin betterleaks \
&& rm /tmp/betterleaks.tar.gz
RUN curl -sSfL -o /tmp/sbomqs.tar.gz \
"https://github.com/interlynk-io/sbomqs/releases/download/v${SBOMQS_VERSION}/sbomqs_${SBOMQS_VERSION}_Linux_x86_64.tar.gz" \
&& echo "${SBOMQS_SHA256} /tmp/sbomqs.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/sbomqs.tar.gz -C /usr/local/bin sbomqs \
&& rm /tmp/sbomqs.tar.gz
RUN pip3 install --break-system-packages --no-cache-dir \
"semgrep==${SEMGREP_VERSION}" "ruff==${RUFF_VERSION}"
# Mobile app SAST (LGPL-3.0). The wrapper clears its substring path ignores;
# see compliance-agent/src/pipeline/mobsfscan.rs.
RUN pip3 install --break-system-packages --no-cache-dir --no-deps \
"mobsfscan==${MOBSFSCAN_VERSION}" \
&& pip3 install --break-system-packages --no-cache-dir \
"libsast==3.1.8" "billiard==4.3.0" "pyyaml==6.0.3" "colorama==0.4.6" \
"sarif-om==1.0.4" "jschema-to-python==1.2.3" "jsonpickle==4.1.2" "pbr==7.0.3" \
"tabulate==0.10.0" "xmltodict==1.0.4"
COPY docker/pruefwerk_mobsfscan.py /opt/pruefwerk/pruefwerk_mobsfscan.py
# .NET SAST without a build (#494): DevSkim on C#, VB.NET and .config files.
# The .NET runtime only (no SDK), with invariant globalisation so it needs no
# ICU; of DevSkim's bundled native libraries only the linux-x64 ones are kept.
# The licence texts stay next to each (LICENSE.txt, ThirdPartyNotices.txt).
RUN curl -sSfL -o /tmp/dotnet.tar.gz \
"https://builds.dotnet.microsoft.com/dotnet/Runtime/${DOTNET_RUNTIME_VERSION}/dotnet-runtime-${DOTNET_RUNTIME_VERSION}-linux-x64.tar.gz" \
&& echo "${DOTNET_RUNTIME_SHA512} /tmp/dotnet.tar.gz" | sha512sum -c - \
&& mkdir -p /opt/dotnet \
&& tar -xzf /tmp/dotnet.tar.gz -C /opt/dotnet \
&& rm /tmp/dotnet.tar.gz \
&& curl -sSfL -o /tmp/devskim.nupkg \
"https://api.nuget.org/v3-flatcontainer/microsoft.cst.devskim.cli/${DEVSKIM_VERSION}/microsoft.cst.devskim.cli.${DEVSKIM_VERSION}.nupkg" \
&& echo "${DEVSKIM_SHA256} /tmp/devskim.nupkg" | sha256sum -c - \
&& python3 -c "import zipfile; z = zipfile.ZipFile('/tmp/devskim.nupkg'); \
[z.extract(n, '/tmp/devskim') for n in z.namelist() if n.startswith('tools/net10.0/any/') or n == 'LICENSE.txt']" \
&& mv /tmp/devskim/tools/net10.0/any /opt/devskim \
&& mv /tmp/devskim/LICENSE.txt /opt/devskim/LICENSE.txt \
&& rm -rf /tmp/devskim /tmp/devskim.nupkg /opt/devskim/x86 /opt/devskim/amd64 /opt/devskim/arm64 /opt/devskim/*.pdb \
&& find /opt/devskim/runtimes -mindepth 1 -maxdepth 1 ! -name linux-x64 -exec rm -rf {} +
COPY --chmod=0755 docker/devskim.sh /usr/local/bin/devskim
RUN mkdir -p /opt/pruefwerk \
&& printf '{"rust":"%s","cargo-audit":"%s","syft":"%s","betterleaks":"%s","semgrep":"%s","ruff":"%s","cppcheck":"%s","mobsfscan":"%s","sbomqs":"%s","devskim":"%s","dotnet-runtime":"%s"}\n' \
"${RUST_VERSION}" "${CARGO_AUDIT_VERSION}" "${SYFT_VERSION}" "${BETTERLEAKS_VERSION}" \
"${SEMGREP_VERSION}" "${RUFF_VERSION}" "$(cppcheck --version | cut -d' ' -f2)" \
"${MOBSFSCAN_VERSION}" "${SBOMQS_VERSION}" "${DEVSKIM_VERSION}" "${DOTNET_RUNTIME_VERSION}" \
> /opt/pruefwerk/tool-versions.json
# The agent runs unprivileged. It writes only to its home (tool caches), the
# data root (uploaded artifacts, the OSCAL snapshot; mount a volume there) and
# /tmp (git checkouts), so the rest of the filesystem can be read-only.
RUN useradd --uid 10001 --user-group --create-home --home-dir /home/app --shell /usr/sbin/nologin app \
&& mkdir -p /data/compliance-scanner/artifacts /data/compliance-scanner/oscal \
&& chown -R app:app /data/compliance-scanner
ENV HOME=/home/app \
CARGO_HOME=/home/app/.cargo \
ARTIFACT_STORE_BASE_PATH=/data/compliance-scanner/artifacts \
BREAKPILOT_SNAPSHOT_DIR=/data/compliance-scanner/oscal
FROM tools
COPY --from=cargo-audit /usr/local/cargo/bin/cargo-audit /usr/local/cargo/bin/cargo-audit
COPY --from=builder /app/target/release/compliance-agent /usr/local/bin/compliance-agent
COPY --chmod=0755 docker/agent-entrypoint.sh /usr/local/bin/agent-entrypoint.sh
# OSCAL control-catalog snapshot: lets control mapping run without the
# breakpilot-compliance backend. The entrypoint seeds it into
# BREAKPILOT_SNAPSHOT_DIR on start (copy-if-absent).
COPY --from=builder /app/compliance-agent/controls/snapshot /opt/breakpilot/oscal-snapshot
# Copy documentation for the help chat assistant
COPY --from=builder /app/README.md /app/README.md
COPY --from=builder /app/docs /app/docs
ENV HELP_DOCS_PATH=/app
USER app
EXPOSE 3001 3002
# Liveness from the agent's own health endpoint (#262 makes it report its
# dependencies too).
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD curl -fsS "http://127.0.0.1:${AGENT_PORT:-3001}/api/v1/health" || exit 1
# Checks the data directories are writable, seeds the OSCAL snapshot, then runs
# the agent.
ENTRYPOINT ["/usr/local/bin/agent-entrypoint.sh"]