Skip to content

Commit 599c193

Browse files
committed
Harden GitHub Actions workflows: minimal permissions, SHA pins, timeouts
- Add top-level on caller (ci.yml) and scheduled/event workflows (inactive_issues.yml, needs_contributor.yml) - Declare explicit job-level permissions across all reusable workflows - Pin all third-party actions to immutable commit SHAs (was using mutable tags, including the critical ) - Align codeql-action on v3 across quality.yml and cyber.yml - Add timeout-minutes on every job to prevent runaway builds - Add concurrency group on ci.yml with cancel-in-progress for PRs only - Add .github/dependabot.yml for automated SHA and npm dependency updates
1 parent f705606 commit 599c193

File tree

10 files changed

+103
-35
lines changed

10 files changed

+103
-35
lines changed

.github/dependabot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
groups:
8+
actions:
9+
patterns:
10+
- "*"
11+
- package-ecosystem: "npm"
12+
directory: "/glances/outputs/static"
13+
schedule:
14+
interval: "weekly"
15+
groups:
16+
npm:
17+
patterns:
18+
- "*"

.github/workflows/build.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ jobs:
1111
name: Build distribution 📦
1212
if: github.event_name == 'push'
1313
runs-on: ubuntu-latest
14+
timeout-minutes: 10
15+
permissions:
16+
contents: read
1417
steps:
15-
- uses: actions/checkout@v5
18+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
1619
- name: Set up Python
17-
uses: actions/setup-python@v6
20+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
1821
with:
1922
python-version: "3.14"
2023
- name: Install pypa/build
@@ -26,7 +29,7 @@ jobs:
2629
- name: Build a binary wheel and a source tarball
2730
run: python3 -m build
2831
- name: Store the distribution packages
29-
uses: actions/upload-artifact@v4
32+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
3033
with:
3134
name: python-package-distributions
3235
path: dist/
@@ -37,6 +40,7 @@ jobs:
3740
needs:
3841
- build
3942
runs-on: ubuntu-latest
43+
timeout-minutes: 5
4044
environment:
4145
name: pypi
4246
url: https://pypi.org/p/glances
@@ -45,12 +49,12 @@ jobs:
4549
id-token: write
4650
steps:
4751
- name: Download all the dists
48-
uses: actions/download-artifact@v5
52+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
4953
with:
5054
name: python-package-distributions
5155
path: dist/
5256
- name: Publish distribution 📦 to PyPI
53-
uses: pypa/gh-action-pypi-publish@release/v1
57+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
5458
with:
5559
skip-existing: true
5660
attestations: false
@@ -62,6 +66,7 @@ jobs:
6266
needs:
6367
- build
6468
runs-on: ubuntu-latest
69+
timeout-minutes: 5
6570
environment:
6671
name: testpypi
6772
url: https://pypi.org/p/glances
@@ -70,12 +75,12 @@ jobs:
7075
id-token: write
7176
steps:
7277
- name: Download all the dists
73-
uses: actions/download-artifact@v5
78+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
7479
with:
7580
name: python-package-distributions
7681
path: dist/
7782
- name: Publish distribution 📦 to TestPyPI
78-
uses: pypa/gh-action-pypi-publish@release/v1
83+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
7984
with:
8085
repository-url: https://test.pypi.org/legacy/
8186
skip-existing: true

.github/workflows/build_docker.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626

2727
create_docker_images_list:
2828
runs-on: ubuntu-latest
29+
timeout-minutes: 5
30+
permissions: {}
2931
outputs:
3032
tags: ${{ steps.config.outputs.tags }}
3133
steps:
@@ -50,6 +52,9 @@ jobs:
5052
5153
build_docker_images:
5254
runs-on: ubuntu-latest
55+
timeout-minutes: 60
56+
permissions:
57+
contents: read
5358
needs:
5459
- create_docker_images_list
5560
if: needs.create_docker_images_list.outputs.tags != '[]'
@@ -60,36 +65,36 @@ jobs:
6065
tag: ${{ fromJson(needs.create_docker_images_list.outputs.tags) }}
6166
steps:
6267
- name: Checkout
63-
uses: actions/checkout@v5
68+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
6469

6570
- name: Retrieve Repository Docker metadata
6671
id: docker_meta
67-
uses: docker/metadata-action@v5
72+
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
6873
with:
6974
images: ${{ env.DEFAULT_DOCKER_IMAGE }}
7075
labels: |
7176
org.opencontainers.image.url=https://nicolargo.github.io/glances/
7277
7378
- name: Set up QEMU
74-
uses: docker/setup-qemu-action@v3
79+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
7580
with:
7681
platforms: all
7782

7883
- name: Set up Docker Buildx
7984
id: buildx
80-
uses: docker/setup-buildx-action@v3
85+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
8186
with:
8287
version: latest
8388

8489
- name: Login to DockerHub
85-
uses: docker/login-action@v3
90+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
8691
if: ${{ env.PUSH_BRANCH == 'true' }}
8792
with:
8893
username: ${{ secrets.DOCKER_USERNAME }}
8994
password: ${{ secrets.DOCKER_TOKEN }}
9095

9196
- name: Build and push image
92-
uses: docker/build-push-action@v6
97+
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
9398
with:
9499
push: ${{ env.PUSH_BRANCH == 'true' }}
95100
tags: "${{ env.DEFAULT_DOCKER_IMAGE }}:${{ matrix.os != 'alpine' && format('{0}-', matrix.os) || '' }}${{ matrix.tag.tag }}"

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ on:
88
tags:
99
- v*
1010

11+
permissions: {}
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
16+
1117
jobs:
1218
quality:
1319
uses: ./.github/workflows/quality.yml

.github/workflows/cyber.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ jobs:
77
trivy:
88
name: Trivy scan
99
continue-on-error: true
10+
timeout-minutes: 15
1011

1112
runs-on: ubuntu-latest
1213

14+
permissions:
15+
contents: read
16+
security-events: write
17+
1318
steps:
1419
- name: Checkout code
15-
uses: actions/checkout@v5
20+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
1621

1722
- name: Run Trivy vulnerability scanner in repo mode
18-
uses: aquasecurity/trivy-action@master
23+
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # master
1924
with:
2025
scan-type: 'fs'
2126
ignore-unfixed: true
@@ -24,6 +29,6 @@ jobs:
2429
severity: 'CRITICAL'
2530

2631
- name: Upload Trivy scan results to GitHub Security tab
27-
uses: github/codeql-action/upload-sarif@v4
32+
uses: github/codeql-action/upload-sarif@820e3160e279568db735cee8ed8f8e77a6da7818 # v3
2833
with:
2934
sarif_file: 'trivy-results.sarif'

.github/workflows/inactive_issues.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ on:
33
schedule:
44
- cron: "30 1 * * *"
55

6+
permissions: {}
7+
68
jobs:
79
close-issues:
810
runs-on: ubuntu-latest
11+
timeout-minutes: 5
912
permissions:
1013
issues: write
1114
pull-requests: write
1215
steps:
13-
- uses: actions/stale@v10
16+
- uses: actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f # v10
1417
with:
1518
days-before-issue-stale: 90
1619
days-before-issue-close: -1

.github/workflows/needs_contributor.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ on:
33
issues:
44
types:
55
- labeled
6+
7+
permissions: {}
8+
69
jobs:
710
add-comment:
811
if: github.event.label.name == 'needs contributor'
912
runs-on: ubuntu-latest
13+
timeout-minutes: 5
1014
permissions:
1115
issues: write
1216
steps:
@@ -19,4 +23,4 @@ jobs:
1923
BODY: >
2024
This issue is available for anyone to work on.
2125
**Make sure to reference this issue in your pull request.**
22-
:sparkles: Thank you for your contribution ! :sparkles:
26+
:sparkles: Thank you for your contribution ! :sparkles:

.github/workflows/quality.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ jobs:
77
analyze:
88
name: Analyze
99
runs-on: ubuntu-latest
10+
timeout-minutes: 15
1011
permissions:
1112
actions: read
1213
contents: read
@@ -22,11 +23,11 @@ jobs:
2223

2324
steps:
2425
- name: Checkout repository
25-
uses: actions/checkout@v5
26+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
2627

2728
# Initializes the CodeQL tools for scanning.
2829
- name: Initialize CodeQL
29-
uses: github/codeql-action/init@v3
30+
uses: github/codeql-action/init@820e3160e279568db735cee8ed8f8e77a6da7818 # v3
3031
with:
3132
languages: ${{ matrix.language }}
3233
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -37,7 +38,7 @@ jobs:
3738
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
3839
# If this step fails, then you should remove it and run the build manually (see below)
3940
- name: Autobuild
40-
uses: github/codeql-action/autobuild@v3
41+
uses: github/codeql-action/autobuild@820e3160e279568db735cee8ed8f8e77a6da7818 # v3
4142

4243
# ℹ️ Command-line programs to run using the OS shell.
4344
# 📚 https://git.io/JvXDl
@@ -51,4 +52,4 @@ jobs:
5152
# make release
5253

5354
- name: Perform CodeQL Analysis
54-
uses: github/codeql-action/analyze@v3
55+
uses: github/codeql-action/analyze@820e3160e279568db735cee8ed8f8e77a6da7818 # v3

.github/workflows/test.yml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,21 @@ jobs:
99

1010
source-code-checks:
1111
runs-on: ubuntu-24.04
12+
timeout-minutes: 5
13+
14+
permissions:
15+
contents: read
1216

1317
steps:
14-
- uses: actions/checkout@v5
18+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
1519

1620
# - name: Check formatting with Ruff
17-
# uses: chartboost/ruff-action@v1
21+
# uses: chartboost/ruff-action@e18ae971ccee1b2d7bbef113930f00c670b78da4 # v1
1822
# with:
1923
# args: 'format --check'
2024

2125
- name: Check linting with Ruff
22-
uses: chartboost/ruff-action@v1
26+
uses: chartboost/ruff-action@e18ae971ccee1b2d7bbef113930f00c670b78da4 # v1
2327
with:
2428
args: 'check'
2529

@@ -35,18 +39,22 @@ jobs:
3539
needs: source-code-checks
3640
# https://github.com/actions/runner-images?tab=readme-ov-file#available-images
3741
runs-on: ubuntu-24.04
42+
timeout-minutes: 15
3843
strategy:
3944
matrix:
4045
# Python EOL version are note tested
4146
# Multiple Python version only tested for Linux
4247
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
4348

49+
permissions:
50+
contents: read
51+
4452
steps:
4553

46-
- uses: actions/checkout@v5
54+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
4755

4856
- name: Set up Python ${{ matrix.python-version }}
49-
uses: actions/setup-python@v6
57+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
5058
with:
5159
python-version: ${{ matrix.python-version }}
5260
cache: 'pip'
@@ -65,17 +73,22 @@ jobs:
6573
needs: source-code-checks
6674
# https://github.com/actions/runner-images?tab=readme-ov-file#available-images
6775
runs-on: windows-2025
76+
timeout-minutes: 15
6877
strategy:
6978
matrix:
7079
# Windows-curses not available for Python 3.14 for the moment
7180
# See https://github.com/zephyrproject-rtos/windows-curses/issues/76
7281
python-version: ["3.13"]
82+
83+
permissions:
84+
contents: read
85+
7386
steps:
7487

75-
- uses: actions/checkout@v5
88+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
7689

7790
- name: Set up Python ${{ matrix.python-version }}
78-
uses: actions/setup-python@v6
91+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
7992
with:
8093
python-version: ${{ matrix.python-version }}
8194
cache: 'pip'
@@ -95,17 +108,21 @@ jobs:
95108
needs: source-code-checks
96109
# https://github.com/actions/runner-images?tab=readme-ov-file#available-images
97110
runs-on: macos-15
111+
timeout-minutes: 15
98112
strategy:
99113
matrix:
100114
# Only test the latest stable version
101115
python-version: ["3.14"]
102116

117+
permissions:
118+
contents: read
119+
103120
steps:
104121

105-
- uses: actions/checkout@v5
122+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
106123

107124
- name: Set up Python ${{ matrix.python-version }}
108-
uses: actions/setup-python@v6
125+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
109126
with:
110127
python-version: ${{ matrix.python-version }}
111128
cache: 'pip'
@@ -129,10 +146,10 @@ jobs:
129146
# python-version: ["3.14"]
130147
# steps:
131148

132-
# - uses: actions/checkout@v5
149+
# - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
133150

134151
# - name: Set up Python ${{ matrix.python-version }}
135-
# uses: actions/setup-python@v6
152+
# uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
136153
# with:
137154
# python-version: ${{ matrix.python-version }}
138155
# cache: 'pip'

0 commit comments

Comments
 (0)