mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-12-03 10:18:18 +00:00
By the maintainer's decision of 2026-11-25, recorded in the handover. The option as offered: "Drop the duplicate chown layer", as offered: "`COPY --chown` on the app file layers instead of a final `chown -R`. Every file under `/app` stays owned by uid 1000, compared file by file in the rebuilt image." `RUN chown -R ousast /app` ran after the last COPY, so it copied every file of `/app` into a second layer: 194 MB beside the 189 MB `benchmarks` layer in the local image, and the build of 2026-11-25 spent 311 of its 470 seconds in it. The line is removed, and the copies it covered take `--chown=1000` as `benchmarks` already did: `pyproject.toml`, `README.md` and `LICENSE` in one, `src` in the other. Nothing after the last COPY writes under `/app`: the pip install runs with the uv_build backend and left nothing there in the image built on 2026-11-25. Two things are expected to change besides the layer. `/app` itself, which `WORKDIR` creates, is owned by root, where `chown -R` made it uid 1000. And the files that were gid 0 take gid 1000. No tracked use writes into `/app` as the runtime user: compose runs in `/work` and writes under `/reports`, the wrapper `ops/ousast-docker` works in the mounted repository, and the workflows build and push. Tests: the new `tests/test_task_images.py::test_app_layers_carry_their_owner` fails on a `RUN chown` in the final stage and on a `COPY` into it that does not start with `COPY --chown=1000 `. It failed before the change (1 failed, 15 passed) and passes after; with `tests/test_search_image.py`, 17 passed. On scratch copies it fails when the chown line is put back and when the flag is dropped from `COPY src ./src`. `test_digest_required_and_code_last` found its code line by `COPY src `; it accepts the new prefix, and its ordering check is unchanged. ruff, mypy, the three gates and compileall pass, and the gates print what they printed before the change. An independent reviewer approved the change in one round. Not claimed here: the rebuilt image. It follows in this step's next part, with the proof that every file under `/app` is owned by uid 1000 and that `/app` holds the tracked files only.
48 lines
2.1 KiB
Docker
48 lines
2.1 KiB
Docker
# syntax=docker/dockerfile:1
|
|
# Supply digests from plane/task-base.digest; deliberately no floating fallback.
|
|
ARG TASK_BASE_TAG=base-unpublished
|
|
ARG TASK_BASE_DIGEST
|
|
FROM ghcr.io/norandom/ousast-task-base:${TASK_BASE_TAG}@${TASK_BASE_DIGEST} AS joern-build
|
|
ENV PATH="/opt/joern-cli:${PATH}"
|
|
ARG JOERN_VERSION=v4.0.625
|
|
ARG ARCHIVE=joern-cli-linux-x86_64.zip
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends curl unzip \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN set -eux; \
|
|
cd /tmp; \
|
|
curl -fsSL -O "https://github.com/joernio/joern/releases/download/${JOERN_VERSION}/${ARCHIVE}"; \
|
|
curl -fsSL -O "https://github.com/joernio/joern/releases/download/${JOERN_VERSION}/${ARCHIVE}.sha512"; \
|
|
sed 's@ target/@ @' "${ARCHIVE}.sha512" > checksum.sha512; \
|
|
sha512sum -c checksum.sha512; \
|
|
unzip -q "${ARCHIVE}" -d /opt; \
|
|
rm -f "${ARCHIVE}" "${ARCHIVE}.sha512" checksum.sha512; \
|
|
/opt/joern-cli/joern-parse --help > /dev/null
|
|
|
|
RUN if [ ! -e /opt/joern-cli/jssrc2cpg ] && [ -x /opt/joern-cli/jssrc2cpg.sh ]; then \
|
|
ln -s jssrc2cpg.sh /opt/joern-cli/jssrc2cpg; \
|
|
fi
|
|
COPY ops/frontend-retention/install.py /tmp/frontend-retention-install.py
|
|
RUN python3 /tmp/frontend-retention-install.py /opt/joern-cli \
|
|
&& rm /tmp/frontend-retention-install.py
|
|
|
|
FROM ghcr.io/norandom/ousast-task-base:${TASK_BASE_TAG}@${TASK_BASE_DIGEST} AS engine
|
|
ENV PATH="/opt/joern-cli:${PATH}"
|
|
COPY --from=joern-build /opt/joern-cli /opt/joern-cli
|
|
# Create runtime identity before the application layers.
|
|
RUN if getent passwd 1000 > /dev/null; then \
|
|
usermod --login ousast --home /home/ousast --move-home "$(getent passwd 1000 | cut -d: -f1)"; \
|
|
else useradd --create-home --uid 1000 ousast; fi
|
|
WORKDIR /app
|
|
# Each layer under /app names the runtime user itself; a later `chown -R /app` would store every file twice.
|
|
COPY --chown=1000 pyproject.toml README.md LICENSE ./
|
|
COPY --chown=1000 src ./src
|
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
|
/venv/bin/pip install --no-deps --no-cache-dir .
|
|
COPY --chown=1000 benchmarks ./benchmarks
|
|
USER ousast
|
|
ENTRYPOINT ["python", "-m", "openultrasast.cli"]
|
|
CMD ["--help"]
|