Skip to content

Commit 783d89e

Browse files
step-security-botsigmavirus24
authored andcommitted
[StepSecurity] Apply security best practices
Signed-off-by: StepSecurity Bot <[email protected]>
1 parent 75718ac commit 783d89e

9 files changed

+179
-11
lines changed

.github/dependabot.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: daily
7+
8+
- package-ecosystem: pip
9+
directory: /docs/source
10+
schedule:
11+
interval: daily

.github/workflows/build.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Python tests
22

33
on: [push, pull_request]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
test:
710
runs-on: ubuntu-latest
@@ -22,11 +25,16 @@ jobs:
2225
- { VERSION: "pypy3.9", TOXENV: "pypy", ALLOW_FAILURE: false }
2326

2427
steps:
28+
- name: Harden the runner (Audit all outbound calls)
29+
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
30+
with:
31+
egress-policy: audit
32+
2533
- name: Check out the repository
26-
uses: actions/checkout@v3
34+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
2735

2836
- name: Setup Python
29-
uses: actions/[email protected]
37+
uses: actions/setup-python@b55428b1882923874294fa556849718a1d7f2ca5 # v4.2.0
3038
with:
3139
python-version: ${{ matrix.PYTHON.VERSION }}
3240

.github/workflows/codeql-analysis.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ on:
2020
schedule:
2121
- cron: '32 17 * * 6'
2222

23+
permissions:
24+
contents: read
25+
2326
jobs:
2427
analyze:
2528
name: Analyze
@@ -37,12 +40,17 @@ jobs:
3740
# Learn more about CodeQL language support at https://git.io/codeql-language-support
3841

3942
steps:
43+
- name: Harden the runner (Audit all outbound calls)
44+
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
45+
with:
46+
egress-policy: audit
47+
4048
- name: Checkout repository
41-
uses: actions/checkout@v2
49+
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
4250

4351
# Initializes the CodeQL tools for scanning.
4452
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v1
53+
uses: github/codeql-action/init@231aa2c8a89117b126725a0e11897209b7118144 # v1.1.39
4654
with:
4755
languages: ${{ matrix.language }}
4856
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -53,7 +61,7 @@ jobs:
5361
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5462
# If this step fails, then you should remove it and run the build manually (see below)
5563
- name: Autobuild
56-
uses: github/codeql-action/autobuild@v1
64+
uses: github/codeql-action/autobuild@231aa2c8a89117b126725a0e11897209b7118144 # v1.1.39
5765

5866
# ℹ️ Command-line programs to run using the OS shell.
5967
# 📚 https://git.io/JvXDl
@@ -67,4 +75,4 @@ jobs:
6775
# make release
6876

6977
- name: Perform CodeQL Analysis
70-
uses: github/codeql-action/analyze@v1
78+
uses: github/codeql-action/analyze@231aa2c8a89117b126725a0e11897209b7118144 # v1.1.39
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Dependency Review Action
2+
#
3+
# This Action will scan dependency manifest files that change as part of a Pull Request,
4+
# surfacing known-vulnerable versions of the packages declared or updated in the PR.
5+
# Once installed, if the workflow run is marked as required,
6+
# PRs introducing known-vulnerable packages will be blocked from merging.
7+
#
8+
# Source repository: https://github.com/actions/dependency-review-action
9+
name: 'Dependency Review'
10+
on: [pull_request]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
dependency-review:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Harden the runner (Audit all outbound calls)
20+
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
21+
with:
22+
egress-policy: audit
23+
24+
- name: 'Checkout Repository'
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
- name: 'Dependency Review'
27+
uses: actions/dependency-review-action@67d4f4bd7a9b17a0db54d2a7519187c65e339de8 # v4

.github/workflows/docs.yml

+11-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,21 @@ name: Check documentation
1313
- "**.rst"
1414
- "docs/**"
1515

16+
permissions:
17+
contents: read
18+
1619
jobs:
1720
docs:
1821
name: Build documentation & check links
1922
runs-on: ubuntu-latest
2023
steps:
21-
- uses: actions/checkout@v3
22-
- uses: actions/setup-python@v4
24+
- name: Harden the runner (Audit all outbound calls)
25+
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
26+
with:
27+
egress-policy: audit
28+
29+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
30+
- uses: actions/setup-python@3605726ffa6ef7750b99ff496e5b88248b414e26 # v4.9.0
2331
with:
2432
python-version: "3.11"
2533

@@ -39,7 +47,7 @@ jobs:
3947
TOXENV: docs
4048

4149
- name: Upload documentation
42-
uses: actions/upload-artifact@v3
50+
uses: actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3.2.1
4351
with:
4452
name: docs
4553
path: docs/build

.github/workflows/labeler.yml

+13-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@ on:
66
- main
77
- master
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
labeler:
14+
permissions:
15+
contents: read # for actions/checkout to fetch code
16+
issues: write # for crazy-max/ghaction-github-labeler to create, rename, update and delete label
1117
runs-on: ubuntu-latest
1218
steps:
19+
- name: Harden the runner (Audit all outbound calls)
20+
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
21+
with:
22+
egress-policy: audit
23+
1324
- name: Check out the repository
14-
uses: actions/[email protected]
25+
uses: actions/checkout@a81bbbf8298c0fa03ea29cdc473d45769f953675 # v2.3.3
1526

1627
- name: Run Labeler
17-
uses: crazy-max/[email protected]
28+
uses: crazy-max/ghaction-github-labeler@52525cb66833763f651fc34e244e4f73b6e07ff5 # v3.1.1
1829
with:
1930
skip-delete: true

.github/workflows/release.yml

+10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ jobs:
1818
hashes: ${{ steps.hash.outputs.hashes }}
1919

2020
steps:
21+
- name: Harden the runner (Audit all outbound calls)
22+
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
23+
with:
24+
egress-policy: audit
25+
2126
- name: "Checkout repository"
2227
uses: "actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3"
2328

@@ -69,6 +74,11 @@ jobs:
6974
runs-on: "ubuntu-latest"
7075

7176
steps:
77+
- name: Harden the runner (Audit all outbound calls)
78+
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
79+
with:
80+
egress-policy: audit
81+
7282
- name: "Download dists"
7383
uses: "actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a"
7484
with:

.github/workflows/scorecards.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# This workflow uses actions that are not certified by GitHub. They are provided
2+
# by a third-party and are governed by separate terms of service, privacy
3+
# policy, and support documentation.
4+
5+
name: Scorecard supply-chain security
6+
on:
7+
# For Branch-Protection check. Only the default branch is supported. See
8+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
9+
branch_protection_rule:
10+
# To guarantee Maintained check is occasionally updated. See
11+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
12+
schedule:
13+
- cron: '20 7 * * 2'
14+
push:
15+
branches: ["main"]
16+
17+
# Declare default permissions as read only.
18+
permissions: read-all
19+
20+
jobs:
21+
analysis:
22+
name: Scorecard analysis
23+
runs-on: ubuntu-latest
24+
permissions:
25+
# Needed to upload the results to code-scanning dashboard.
26+
security-events: write
27+
# Needed to publish results and get a badge (see publish_results below).
28+
id-token: write
29+
contents: read
30+
actions: read
31+
# To allow GraphQL ListCommits to work
32+
issues: read
33+
pull-requests: read
34+
# To detect SAST tools
35+
checks: read
36+
37+
steps:
38+
- name: Harden the runner (Audit all outbound calls)
39+
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
40+
with:
41+
egress-policy: audit
42+
43+
- name: "Checkout code"
44+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
45+
with:
46+
persist-credentials: false
47+
48+
- name: "Run analysis"
49+
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
50+
with:
51+
results_file: results.sarif
52+
results_format: sarif
53+
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
54+
# - you want to enable the Branch-Protection check on a *public* repository, or
55+
# - you are installing Scorecards on a *private* repository
56+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
57+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
58+
59+
# Public repositories:
60+
# - Publish results to OpenSSF REST API for easy access by consumers
61+
# - Allows the repository to include the Scorecard badge.
62+
# - See https://github.com/ossf/scorecard-action#publishing-results.
63+
# For private repositories:
64+
# - `publish_results` will always be set to `false`, regardless
65+
# of the value entered here.
66+
publish_results: true
67+
68+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
69+
# format to the repository Actions tab.
70+
- name: "Upload artifact"
71+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
72+
with:
73+
name: SARIF file
74+
path: results.sarif
75+
retention-days: 5
76+
77+
# Upload the results to GitHub's code scanning dashboard.
78+
- name: "Upload to code-scanning"
79+
uses: github/codeql-action/upload-sarif@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
80+
with:
81+
sarif_file: results.sarif

.pre-commit-config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ repos:
4343
hooks:
4444
- id: setup-cfg-fmt
4545
args: [--min-py3-version, '3.7']
46+
- repo: https://github.com/gitleaks/gitleaks
47+
rev: v8.16.3
48+
hooks:
49+
- id: gitleaks

0 commit comments

Comments
 (0)