Skip to content

Commit 7316f59

Browse files
authored
Security fixes (#504)
## Overview This PR adds a few security recommendations. The SBOM and provenance adjustment is for testing purposes as the GitHub Workflow doesn't currently push to DockerHub, but once we no longer have Docker autobuild services, we may be using this for production. Changes: * Updated `setuptools` to address a CWE issue * Restricted the allowed connections in PyPI and TestPyPI workflows * Added the `nodefaults` source in conda configurations * Specified a `nonroot` user for running the Docker service ## Related Issue / Discussion Docker Teams Pro subscription is ending in a few weeks. Birdhouse docker images will need to migrate to using the `push` option in `docker/build-push-action` very soon.
2 parents d1a87c9 + 39cab18 commit 7316f59

File tree

7 files changed

+27
-4
lines changed

7 files changed

+27
-4
lines changed

.github/workflows/docker-testing.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545
load: true
4646
cache-from: type=gha
4747
cache-to: type=gha,mode=max
48+
# platforms: linux/amd64,linux/arm64
49+
# sbom: false
4850
push: false
4951
- name: Run Docker image
5052
uses: addnab/docker-run-action@4f65fabd2431ebc8d299f8e5a018d79a769ae185 # v3.0.0

.github/workflows/publish-pypi.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ jobs:
2121
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
2222
with:
2323
disable-sudo: true
24-
egress-policy: audit
24+
egress-policy: block
25+
allowed-endpoints: >
26+
files.pythonhosted.org:443
27+
github.com:443
28+
pypi.org:443
29+
ruf-repo-cdn.sigstore.dev:443
30+
upload.pypi.org:443
2531
- name: Checkout Repository
2632
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2733
with:

.github/workflows/tag-testpypi.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ jobs:
2121
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
2222
with:
2323
disable-sudo: true
24-
egress-policy: audit
24+
egress-policy: block
25+
allowed-endpoints: >
26+
files.pythonhosted.org:443
27+
github.com:443
28+
pypi.org:443
29+
ruf-repo-cdn.sigstore.dev:443
30+
test.pypi.org:443
2531
- name: Checkout Repository
2632
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2733
with:

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,10 @@ RUN pip install . --no-deps
2323

2424
# Start WPS service on port 5000 of 0.0.0.0
2525
EXPOSE 5000
26+
27+
# Specify a non-root user to run the application
28+
RUN useradd --create-home --shell /bin/bash --uid 1000 nonroot && mkdir -p /tmp/matplotlib && chown -R nonroot:nonroot /code /home/nonroot /tmp/matplotlib /opt/conda/envs/finch
29+
USER nonroot
30+
ENV MPLCONFIGDIR=/tmp/matplotlib
31+
2632
CMD ["gunicorn", "--bind=0.0.0.0:5000", "-t 60", "finch.wsgi:application"]

environment-dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: finch
22
channels:
33
- conda-forge
4+
- nodefaults
45
dependencies:
56
- python >=3.10,<3.13
67
- pywps >=4.6

environment-docs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: finch
22
channels:
33
- conda-forge
4+
- nodefaults
45
dependencies:
56
- python >=3.10,<3.13
67
- anyascii >=0.3.0
@@ -10,7 +11,7 @@ dependencies:
1011
- nbsphinx >=0.9.5
1112
- pandas >=2.2.0
1213
- pywps >=4.5.1
13-
- setuptools >=71.0.0
14+
- setuptools >=78.1.1
1415
- sphinx >=7.0.0,<8.2.0 # Pinned until nbsphinx supports Sphinx 8.2
1516
- sphinxcontrib-bibtex >=2.6.0
1617
- xarray >=2023.11.0,<2025.3.0

environment.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: finch
22
channels:
33
- conda-forge
4+
- nodefaults
45
dependencies:
56
- python >=3.10,<3.13
67
- pip >=24.2.0
@@ -24,7 +25,7 @@ dependencies:
2425
- pyyaml >=6.0.1
2526
- scipy >=1.9.0
2627
- sentry-sdk
27-
- setuptools >=71.0.0
28+
- setuptools >=78.1.1
2829
- siphon
2930
- werkzeug >=3.0.6
3031
- xarray >=2023.11.0,<2025.03.0

0 commit comments

Comments
 (0)