Skip to content
Closed
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
12 changes: 8 additions & 4 deletions images/chromium-headful/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ARG CHROME_VERSION=145.0.7632.75

FROM docker.io/golang:1.25.0 AS server-builder
WORKDIR /workspace/server

Expand Down Expand Up @@ -152,6 +154,7 @@ FROM node:22-bullseye-slim AS node-22
FROM docker.io/ubuntu:22.04

# Allow cross-compilation when building with BuildKit platforms
ARG CHROME_VERSION
ARG TARGETARCH
ARG TARGETOS
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-ubuntu2204
Expand Down Expand Up @@ -287,13 +290,14 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-ap
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
apt update -y && \
apt -y install chromium && \
CHROMIUM_PKG_VERSION="$(apt-cache madison chromium | awk -v v="$CHROME_VERSION" '$3 ~ ("^" v) { print $3; exit }')" && \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awk regex prefix match may select wrong Chromium version

Low Severity

The awk pattern $3 ~ ("^" v) performs a prefix match using CHROME_VERSION as a regex. This has two issues: dots are unescaped regex wildcards (matching any character), and the lack of a version boundary means 145.0.7632.75 also matches versions like 145.0.7632.750. If a longer-prefixed version exists in the PPA and is selected, the installed Chromium would not match the ChromeDriver downloaded with the exact CHROME_VERSION, causing a silent version mismatch.

Additional Locations (1)
Fix in Cursor Fix in Web

test -n "$CHROMIUM_PKG_VERSION" && \
apt -y install "chromium=$CHROMIUM_PKG_VERSION" && \
apt --no-install-recommends -y install sqlite3;

# Chromedriver and Chromium are not necessarily the same version.
ARG CHROMEDRIVER_VERSION=146.0.7680.165
# Install ChromeDriver matching the installed Chromium version
RUN set -eux; \
curl -fsSL "https://storage.googleapis.com/chrome-for-testing-public/${CHROMEDRIVER_VERSION}/linux64/chromedriver-linux64.zip" -o /tmp/cd.zip; \
curl -fsSL "https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION}/linux64/chromedriver-linux64.zip" -o /tmp/cd.zip; \
unzip /tmp/cd.zip -d /tmp; \
mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver; \
chmod +x /usr/local/bin/chromedriver; \
Expand Down
12 changes: 8 additions & 4 deletions images/chromium-headless/image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ARG CHROME_VERSION=145.0.7632.75

FROM docker.io/golang:1.25.0 AS server-builder
WORKDIR /workspace/server

Expand Down Expand Up @@ -98,6 +100,7 @@ FROM node:22-bullseye-slim AS node-22
FROM docker.io/ubuntu:22.04

# Allow cross-compilation when building with BuildKit platforms
ARG CHROME_VERSION
ARG TARGETARCH
ARG TARGETOS
ARG CACHEIDPREFIX=${TARGETOS:-linux}-${TARGETARCH:-amd64}-ubuntu2204
Expand Down Expand Up @@ -153,13 +156,14 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-ap
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=$CACHEIDPREFIX-apt-cache \
--mount=type=cache,target=/var/lib/apt,sharing=locked,id=$CACHEIDPREFIX-apt-lib \
apt-get update -y && \
apt-get -y install chromium && \
CHROMIUM_PKG_VERSION="$(apt-cache madison chromium | awk -v v="$CHROME_VERSION" '$3 ~ ("^" v) { print $3; exit }')" && \
test -n "$CHROMIUM_PKG_VERSION" && \
apt-get -y install "chromium=$CHROMIUM_PKG_VERSION" && \
apt-get --no-install-recommends -y install sqlite3 unzip;

# Chromedriver and Chromium are not necessarily the same version.
ARG CHROMEDRIVER_VERSION=146.0.7680.165
# Install ChromeDriver matching the installed Chromium version
RUN set -eux; \
curl -fsSL "https://storage.googleapis.com/chrome-for-testing-public/${CHROMEDRIVER_VERSION}/linux64/chromedriver-linux64.zip" -o /tmp/cd.zip; \
curl -fsSL "https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION}/linux64/chromedriver-linux64.zip" -o /tmp/cd.zip; \
unzip /tmp/cd.zip -d /tmp; \
mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver; \
chmod +x /usr/local/bin/chromedriver; \
Expand Down
Loading