Skip to content

Commit 25c6ebc

Browse files
authored
Merge pull request #145 from EOPF-Explorer/security/permissions-and-blocking-checks
ci: add permissions block and make security checks blocking
2 parents b75f6e7 + e30c647 commit 25c6ebc

File tree

9 files changed

+565
-423
lines changed

9 files changed

+565
-423
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ updates:
1515
commit-message:
1616
prefix: "deps"
1717
include: "scope"
18+
cooldown:
19+
default-days: 7
1820

1921
# Enable version updates for GitHub Actions
2022
- package-ecosystem: "github-actions"
@@ -31,3 +33,5 @@ updates:
3133
commit-message:
3234
prefix: "ci"
3335
include: "scope"
36+
cooldown:
37+
default-days: 7

.github/workflows/build_uv_cache.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,21 @@ on:
1111
schedule:
1212
- cron: "0 0 */5 * *" # Every 5 days, before cache expiry
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
build-cache:
1619
runs-on: ubuntu-latest
17-
20+
permissions:
21+
contents: read
22+
actions: write # required by actions/cache/save
23+
1824
steps:
1925
- name: Checkout repository
2026
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
27+
with:
28+
persist-credentials: false
2129

2230
- name: Install uv
2331
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7
@@ -39,4 +47,4 @@ jobs:
3947
~/.cache/uv
4048
~/.local/share/uv
4149
.venv
42-
key: uv-main-${{ hashFiles('uv.lock') }}
50+
key: uv-main-${{ hashFiles('uv.lock') }}

.github/workflows/ci.yml

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,23 @@ on:
66
pull_request:
77
branches: [ main ]
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
pre-commit:
1114
runs-on: ubuntu-latest
1215
steps:
1316
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
17+
with:
18+
persist-credentials: false
1419
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
1520
with:
1621
python-version: '3.12'
17-
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
22+
- name: Install pre-commit
23+
run: pip install pre-commit
24+
- name: Run pre-commit
25+
run: pre-commit run --all-files
1826

1927
test:
2028
runs-on: ${{ matrix.os }}
@@ -25,6 +33,8 @@ jobs:
2533

2634
steps:
2735
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
36+
with:
37+
persist-credentials: false
2838

2939
- name: Restore global uv cache
3040
id: cache-restore
@@ -69,31 +79,3 @@ jobs:
6979
~/.local/share/uv
7080
.venv
7181
key: uv-main-${{ hashFiles('uv.lock') }}
72-
73-
security:
74-
runs-on: ubuntu-latest
75-
steps:
76-
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
77-
78-
- name: Set up Python
79-
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
80-
with:
81-
python-version: '3.12'
82-
83-
- name: Install dependencies
84-
run: |
85-
python -m pip install --upgrade pip
86-
pip install bandit safety
87-
88-
- name: Run security checks
89-
run: |
90-
bandit -r eopf_geozarr/ -f json -o bandit-report.json || true
91-
safety check --json --output safety-report.json || true
92-
93-
- name: Upload security reports
94-
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
95-
with:
96-
name: security-reports
97-
path: |
98-
bandit-report.json
99-
safety-report.json

.github/workflows/docs.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ on:
88
paths:
99
- "docs/**"
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
build-docs:
1316
permissions:
14-
contents: write
15-
pages: write
17+
contents: write # mkdocs gh-deploy pushes the site branch
18+
pages: write # GitHub Pages deployment
1619
runs-on: ubuntu-latest
1720
steps:
1821
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
22+
with:
23+
persist-credentials: false
1924

2025
- name: Set up Python
2126
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
@@ -38,4 +43,10 @@ jobs:
3843

3944
- name: Deploy docs
4045
if: github.event_name == 'push'
41-
run: uv run -- mkdocs gh-deploy --force
46+
env:
47+
GITHUB_TOKEN: ${{ github.token }}
48+
run: |
49+
git config user.name "github-actions[bot]"
50+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
51+
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
52+
uv run -- mkdocs gh-deploy --force

.github/workflows/release-please.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ on:
66
- main
77

88
permissions:
9-
contents: write
10-
pull-requests: write
9+
contents: read
1110

1211
jobs:
1312
release-please:
1413
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write # release-please creates releases and version bump commits
16+
pull-requests: write # release-please opens and updates release PRs
1517
steps:
1618
- name: Release Please
1719
id: release

.github/workflows/release.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ on:
44
release:
55
types: [published]
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
build:
912
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
actions: write
1016
steps:
1117
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
18+
with:
19+
persist-credentials: false
1220

1321
- name: Set up Python
1422
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
@@ -36,7 +44,8 @@ jobs:
3644
needs: build
3745
runs-on: ubuntu-latest
3846
permissions:
39-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
47+
actions: read
48+
id-token: write # IMPORTANT: mandatory for trusted publishing to PyPI
4049

4150
steps:
4251
- name: Download build artifacts

.github/workflows/security.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Security Audit
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
security:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
pull-requests: write # action-python-security-auditing posts and updates PR comments
18+
steps:
19+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
20+
with:
21+
persist-credentials: false
22+
- uses: developmentseed/action-python-security-auditing@8ebea22ea75dfba2244ed9883c2aa6cb4df8d9a9 # v0.6.0
23+
with:
24+
package_manager: uv
25+
bandit_scan_dirs: 'src/eopf_geozarr/'
26+
artifact_name: security-reports

pyproject.toml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ dependencies = [
3131
"pydantic>=2.12",
3232
"zarr>=3.1.1",
3333
"xarray>=2025.7.1",
34-
"dask[array,distributed]>=2025.5.1",
34+
"dask[array,distributed]>=2026.1.0",
3535
"numpy>=2.3.1",
3636
"rioxarray>=0.13.0",
3737
"cf-xarray>=0.8.0",
3838
"typing-extensions>=4.15.0",
3939
"zarr-cm>=0.2.0",
40-
"aiohttp>=3.8.1",
40+
"aiohttp>=3.13.3",
4141
"s3fs>=2024.6.0",
4242
"boto3>=1.34.0",
4343
"pyproj>=3.7.0",
@@ -51,7 +51,6 @@ dev = [
5151
"mypy>=1.0.0",
5252
"pre-commit>=3.0.0",
5353
"bandit[toml]>=1.7.0",
54-
"safety>=2.0.0",
5554
]
5655
test = [
5756
"jsondiff>=2.2.1",
@@ -221,5 +220,14 @@ skips = ["B101", "B601"]
221220

222221
[tool.uv]
223222
default-groups = ["dev", "test"]
223+
constraint-dependencies = [
224+
"urllib3>=2.6.3",
225+
"requests>=2.33.0",
226+
"cryptography>=46.0.6",
227+
"tornado>=6.5.5",
228+
"filelock>=3.20.3",
229+
"virtualenv>=20.36.1",
230+
"black>=26.3.1",
231+
]
224232

225233

0 commit comments

Comments
 (0)