# KERN Code's audit tools in one image, built on the person's own machine the first time a whole-workspace audit runs
# (vscode-extension/src/auditTools.ts). Every scanner is a pinned release; kc_audit.py runs them and sorts what they report.
# The repository arrives as a tar (or a read-only mount), so an audit can never change a file.
FROM zricethezav/gitleaks:v8.21.2 AS gitleaks
FROM aquasec/trivy:0.57.1 AS trivy
FROM hadolint/hadolint:v2.12.0 AS hadolint
FROM koalaman/shellcheck:v0.10.0 AS shellcheck

FROM python:3.12-slim
RUN apt-get update && apt-get install -y --no-install-recommends curl git ca-certificates && rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir bandit==1.9.4
RUN curl -fsSL -o /usr/local/bin/opengrep https://github.com/opengrep/opengrep/releases/download/v1.30.2/opengrep_manylinux_x86 && chmod +x /usr/local/bin/opengrep
RUN git clone --filter=blob:none https://github.com/opengrep/opengrep-rules /rules && cd /rules && git checkout f1d2b562b414783763fd02a6ed2736eaed622efa && rm -rf .git
COPY --from=gitleaks /usr/bin/gitleaks /usr/local/bin/gitleaks
COPY --from=trivy /usr/local/bin/trivy /usr/local/bin/trivy
COPY --from=hadolint /bin/hadolint /usr/local/bin/hadolint
COPY --from=shellcheck /bin/shellcheck /usr/local/bin/shellcheck
COPY kc_audit.py /usr/local/bin/kc_audit.py
ENTRYPOINT ["python", "/usr/local/bin/kc_audit.py"]
