mirror of
https://github.com/usestrix/strix.git
synced 2026-08-17 09:29:49 +02:00
fix(container): pin the User-Agent to the installed Chromium and assert it at build
This commit is contained in:
@@ -116,9 +116,10 @@ RUN npm install -g retire@latest && \
|
||||
ln -sf ast-grep /home/pentester/.npm-global/lib/node_modules/@ast-grep/cli/sg
|
||||
|
||||
ENV AGENT_BROWSER_EXECUTABLE_PATH=/usr/bin/chromium
|
||||
# The User-Agent is derived from the installed Chromium at container start; see
|
||||
# containers/docker-entrypoint.sh. AGENT_BROWSER_ARGS is comma-separated, so no
|
||||
# flag value may contain a comma (window geometry comes from the display instead).
|
||||
# Must match the installed Chromium major; the build asserts it below.
|
||||
ENV AGENT_BROWSER_USER_AGENT="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36"
|
||||
# AGENT_BROWSER_ARGS is comma-separated, so no flag value may contain a comma
|
||||
# (window geometry comes from the virtual display instead).
|
||||
ENV AGENT_BROWSER_ARGS="--disable-blink-features=AutomationControlled,--no-first-run,--no-default-browser-check,--lang=en-US,--password-store=basic,--use-mock-keychain,--disable-dev-shm-usage"
|
||||
ENV AGENT_BROWSER_SCREENSHOT_DIR=/workspace/.agent-browser-screenshots
|
||||
ENV AGENT_BROWSER_IDLE_TIMEOUT_MS=180000
|
||||
@@ -128,6 +129,10 @@ RUN /home/pentester/.npm-global/bin/agent-browser doctor --offline --quick
|
||||
# headed mode here. `--no-sandbox` is build-only: buildkit has no unprivileged
|
||||
# user namespaces. The stale X lock/socket must go or the runtime Xvfb refuses.
|
||||
RUN set -eu; \
|
||||
chrome_major="$(chromium --version | grep -oE '[0-9]+' | head -1)"; \
|
||||
printf '%s' "${AGENT_BROWSER_USER_AGENT}" | grep -q "Chrome/${chrome_major}\." || { \
|
||||
echo "AGENT_BROWSER_USER_AGENT disagrees with installed Chromium ${chrome_major}"; exit 1; \
|
||||
}; \
|
||||
Xvfb :99 -screen 0 1280x800x24 -nolisten tcp >/tmp/xvfb-build.log 2>&1 & \
|
||||
xvfb_pid=$!; \
|
||||
for _ in $(seq 1 20); do xdpyinfo -display :99 >/dev/null 2>&1 && break; sleep 0.5; done; \
|
||||
|
||||
@@ -148,14 +148,8 @@ if [ ! -S /run/dbus/system_bus_socket ]; then
|
||||
sudo dbus-daemon --system --fork > /tmp/dbus.log 2>&1 || true
|
||||
fi
|
||||
|
||||
# A UA that disagrees with the installed browser's client hints is a trivially
|
||||
# detectable automation signal, so derive it instead of hardcoding a version.
|
||||
CHROME_MAJOR="$(chromium --version 2>/dev/null | grep -oE '[0-9]+' | head -1)"
|
||||
BROWSER_UA="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${CHROME_MAJOR:-131}.0.0.0 Safari/537.36"
|
||||
|
||||
cat << EOF | sudo tee /etc/profile.d/browser.sh
|
||||
export DISPLAY=:${DISPLAY_NUM}
|
||||
export AGENT_BROWSER_USER_AGENT="${BROWSER_UA}"
|
||||
EOF
|
||||
|
||||
echo ". /etc/profile.d/browser.sh" >> ~/.bashrc
|
||||
|
||||
Reference in New Issue
Block a user