Skip to content

Commit 86fde74

Browse files
committed
fix: linting
- ensure credentials are not persisted past checkout of code - add zizmor.yml file to linters to allow pull_request_target in actions for auto-labeler to work on fork pull requests - add trivy.yml file to linters to ignore mypy_cache directory - add HEALTHCHECK and non-root user to Dockerfile Signed-off-by: jmeridth <[email protected]>
1 parent 06f3361 commit 86fde74

File tree

7 files changed

+30
-4
lines changed

7 files changed

+30
-4
lines changed

.github/linters/trivy.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
scan:
2+
skip-dirs:
3+
- .mypy_cache

.github/linters/zizmor.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
rules:
2+
dangerous-triggers: # to allow pull_request_target for auto-labelling fork pull requests
3+
ignore:
4+
- auto-labeler.yml
5+
- pr-title.yml
6+
- release.yml

.github/workflows/copilot-setup-steps.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ jobs:
2727
steps:
2828
- name: Checkout code
2929
uses: actions/[email protected]
30+
with:
31+
persist-credentials: false
3032

3133
- name: Set up Python
32-
uses: actions/setup-python@v5.6.0
34+
uses: actions/setup-python@v6.0.0
3335
with:
3436
python-version: 3.12
3537

.github/workflows/docker-image.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/[email protected]
18+
with:
19+
persist-credentials: false
1820
- name: Build the Docker image
1921
run: docker build . --file Dockerfile --platform linux/amd64 --tag issue-metrics:"$(date +%s)"

.github/workflows/linter.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ jobs:
2323
# Full git history is needed to get a proper
2424
# list of changed files within `super-linter`
2525
fetch-depth: 0
26-
- uses: actions/[email protected]
26+
persist-credentials: false
27+
- uses: actions/[email protected]
2728
with:
2829
python-version: "3.12"
2930
- name: Install dependencies

.github/workflows/python-package.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ jobs:
2222

2323
steps:
2424
- uses: actions/[email protected]
25+
with:
26+
persist-credentials: false
2527
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v5.6.0
28+
uses: actions/setup-python@v6.0.0
2729
with:
2830
python-version: ${{ matrix.python-version }}
2931
- name: Install dependencies

Dockerfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,17 @@ COPY requirements.txt *.py /action/workspace/
1818
RUN python3 -m pip install --no-cache-dir -r requirements.txt \
1919
&& apt-get -y update \
2020
&& apt-get -y install --no-install-recommends git=1:2.47.3-0+deb13u1 \
21-
&& rm -rf /var/lib/apt/lists/*
21+
&& rm -rf /var/lib/apt/lists/* \
22+
&& addgroup --system appuser \
23+
&& adduser --system --ingroup appuser --home /action/workspace --disabled-login appuser \
24+
&& chown -R appuser:appuser /action/workspace
25+
26+
# Run the action as a non-root user
27+
USER appuser
28+
29+
# Add a simple healthcheck to satisfy container scanners
30+
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
31+
CMD python3 -c "import os,sys; sys.exit(0 if os.path.exists('/action/workspace/issue_metrics.py') else 1)"
2232

2333
CMD ["/action/workspace/issue_metrics.py"]
2434
ENTRYPOINT ["python3", "-u"]

0 commit comments

Comments
 (0)