Skip to content

Commit 58269d5

Browse files
[StepSecurity] Apply security best practices (#8)
Signed-off-by: StepSecurity Bot <[email protected]>
1 parent 6ddef84 commit 58269d5

File tree

6 files changed

+80
-9
lines changed

6 files changed

+80
-9
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: daily

.github/workflows/build.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ on:
55
branches: [ main ]
66
pull_request:
77

8+
permissions:
9+
contents: read
10+
811
jobs:
912
test:
13+
permissions:
14+
contents: read # for actions/checkout to fetch code
15+
pull-requests: read # for SonarSource/sonarcloud-github-action to determine which PR to decorate
1016
strategy:
1117
# By default, GitHub will maximize the number of jobs run in parallel
1218
# depending on the available runners on GitHub-hosted virtual machines.
@@ -18,16 +24,21 @@ jobs:
1824
os: [ ubuntu-22.04, macos-latest, windows-latest ]
1925
runs-on: ${{ matrix.os }}
2026
steps:
21-
- uses: actions/checkout@v4
27+
- name: Harden Runner
28+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
29+
with:
30+
egress-policy: audit
31+
32+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2233
with:
2334
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
2435
- name: Set up Python ${{ matrix.python-version }}
25-
uses: actions/setup-python@v5
36+
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
2637
with:
2738
python-version: ${{ matrix.python-version }}
2839

2940
- name: Run image
30-
uses: abatilo/actions-poetry@v3
41+
uses: abatilo/actions-poetry@fd0e6716a0de25ef6ade151b8b53190b0376acfd # v3
3142
with:
3243
poetry-version: ${{ matrix.poetry-version }}
3344

@@ -47,7 +58,7 @@ jobs:
4758

4859
- name: SonarCloud Scan
4960
if: matrix.python-version == '3.10' && matrix.os == 'ubuntu-22.04' && matrix.poetry-version == '1.7.1'
50-
uses: SonarSource/sonarcloud-github-action@master
61+
uses: SonarSource/sonarcloud-github-action@02ef91109b2d589e757aefcfb2854c2783fd7b19 # master
5162
env:
5263
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
5364
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/codeql-analysis.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ on:
2020
schedule:
2121
- cron: '25 7 * * 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 Runner
44+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
45+
with:
46+
egress-policy: audit
47+
4048
- name: Checkout repository
41-
uses: actions/checkout@v4
49+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4250

4351
# Initializes the CodeQL tools for scanning.
4452
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v3
53+
uses: github/codeql-action/init@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
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@v3
64+
uses: github/codeql-action/autobuild@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
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@v3
78+
uses: github/codeql-action/analyze@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
Lines changed: 27 additions & 0 deletions
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 Runner
20+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
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@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0

.github/workflows/scorecard.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ jobs:
3131
# actions: read
3232

3333
steps:
34+
- name: Harden Runner
35+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
36+
with:
37+
egress-policy: audit
38+
3439
- name: "Checkout code"
3540
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
3641
with:
@@ -68,6 +73,6 @@ jobs:
6873
# Upload the results to GitHub's code scanning dashboard (optional).
6974
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
7075
- name: "Upload to code-scanning"
71-
uses: github/codeql-action/upload-sarif@v3
76+
uses: github/codeql-action/upload-sarif@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
7277
with:
7378
sarif_file: results.sarif

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repos:
2+
- repo: https://github.com/gitleaks/gitleaks
3+
rev: v8.16.3
4+
hooks:
5+
- id: gitleaks
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: v4.4.0
8+
hooks:
9+
- id: end-of-file-fixer
10+
- id: trailing-whitespace
11+
- repo: https://github.com/pylint-dev/pylint
12+
rev: v2.17.2
13+
hooks:
14+
- id: pylint

0 commit comments

Comments
 (0)