11# QWED Action v3.0 Docker Image
22# Includes all verification engines and security scanners
3- FROM python:3.11-slim
3+ # Vulnerability Fix: Upgrade to bookworm and pin digest for immutability
4+ # python:3.12-slim-bookworm @ 2024-02-11
5+ FROM python:3.12-slim-bookworm@sha256:4a8e0824201e50fc44ee8d208a2b3e44f33e00448907e524066fca5a96eb5567
46
57# Prevent python from writing pyc files to disc
68ENV PYTHONDONTWRITEBYTECODE=1
@@ -11,21 +13,52 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1113 git \
1214 && rm -rf /var/lib/apt/lists/*
1315
14- # Install dependencies (including httpx needed by qwed_sdk import chain)
15- # Note: z3-solver NOT included - not needed for secret/code scanning actions
16- # and requires C++ compiler to build from source
17- RUN pip install --no-cache-dir sympy colorama httpx
16+ # Create a non-root user for security
17+ RUN useradd -m -u 1000 appuser
18+
19+ # Fix permissions for GitHub Actions workspace
20+ RUN mkdir -p /github/workspace && chown -R appuser:appuser /github
21+
22+ # Install gosu and dos2unix for entrypoint management
23+ RUN apt-get update && apt-get install -y --no-install-recommends gosu dos2unix && rm -rf /var/lib/apt/lists/*
24+
25+ # Copy requirements file first to leverage cache
26+ COPY requirements.txt /app/requirements.txt
27+
28+ # Install dependencies with hash verification
29+ # Vulnerability Fix: Pin versions with hashes to prevent supply chain attacks
30+ RUN pip install --no-cache-dir --require-hashes -r /app/requirements.txt
1831
1932# Copy the entire QWED SDK (local version with guards)
20- COPY qwed_sdk /app/qwed_sdk/
33+ COPY --chown=appuser:appuser qwed_sdk /app/qwed_sdk/
2134
2235# Copy the entrypoint script
23- COPY action_entrypoint.py /action_entrypoint.py
36+ COPY --chown=appuser:appuser action_entrypoint.py /action_entrypoint.py
2437RUN chmod +x /action_entrypoint.py
2538
39+ # Create entrypoint.sh directly to avoid Windows line ending issues (CRLF)
40+ RUN printf '#!/bin/bash\n \
41+ set -e\n \
42+ \n \
43+ # Fix permissions for workspace\n \
44+ if [ -d "/github/workspace" ]; then\n \
45+ chown -R appuser:appuser /github/workspace\n \
46+ fi\n \
47+ \n \
48+ # Fix permissions for file commands\n \
49+ if [ -d "/github/file_commands" ]; then\n \
50+ chmod -R 777 /github/file_commands\n \
51+ fi\n \
52+ \n \
53+ # Switch to appuser and run the main entrypoint\n \
54+ exec gosu appuser python /action_entrypoint.py "$@"\n \
55+ ' > /entrypoint.sh && chmod +x /entrypoint.sh
56+
2657# Set Python path to use local SDK
2758ENV PYTHONPATH=/app
2859
2960WORKDIR /github/workspace
3061
31- ENTRYPOINT ["python" , "/action_entrypoint.py" ]
62+ # NOTE: We do NOT switch USER here. We start as root to fix permissions on mounted volumes
63+ # in entrypoint.sh, then drop privileges to appuser using gosu.
64+ ENTRYPOINT ["/entrypoint.sh" ]
0 commit comments