Skip to content

Commit 54aaadf

Browse files
committed
fix(security): implement docker non-root user, explicit COPY and secure ci actions
1 parent cb19df4 commit 54aaadf

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ jobs:
2525
--health-retries 5
2626
2727
steps:
28-
- uses: actions/checkout@v4
28+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
2929

3030
- name: Install uv
31-
uses: astral-sh/setup-uv@v4
31+
uses: astral-sh/setup-uv@857947113170757f49551c65d6484e5088f117c0 # v4.2.0
3232
with:
3333
enable-cache: true
3434

3535
- name: Set up Python 3.12
36-
uses: actions/setup-python@v5
36+
uses: actions/setup-python@f6742a91b3c2a4176985474360e200155b9e0f6b # v5.1.1
3737
with:
3838
python-version: "3.12"
3939

Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,19 @@ FROM python:3.12-slim-bookworm
1212

1313
WORKDIR /app
1414

15-
COPY --from=builder /app/.venv /app/.venv
15+
RUN useradd -m -u 1000 appuser && \
16+
chown appuser:appuser /app
17+
18+
COPY --from=builder --chown=appuser:appuser /app/.venv /app/.venv
1619

1720
ENV PATH="/app/.venv/bin:$PATH"
1821

19-
COPY . .
22+
COPY --chown=appuser:appuser src/ ./src/
23+
COPY --chown=appuser:appuser migrations/ ./migrations/
24+
COPY --chown=appuser:appuser alembic.ini pyproject.toml uv.lock ./
25+
COPY --chown=appuser:appuser scripts/ ./scripts/
26+
27+
USER appuser
2028

2129
EXPOSE 8000
2230

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async def override_get_session():
4848
"Content-Type": "application/json",
4949
}
5050
async with AsyncClient(
51-
base_url="http://test",
51+
base_url="https://test",
5252
transport=transport,
5353
headers=headers,
5454
) as client:

0 commit comments

Comments
 (0)