Skip to content

Commit 4003f8d

Browse files
[StepSecurity] Apply security best practices (#4539)
Signed-off-by: StepSecurity Bot <[email protected]>
1 parent 6a2ae22 commit 4003f8d

13 files changed

+374
-57
lines changed

.github/dependabot.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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/mkdocs
10+
schedule:
11+
interval: daily
12+
13+
- package-ecosystem: pip
14+
directory: /tools/serve_header
15+
schedule:
16+
interval: daily

.github/workflows/check_amalgamation.yml

+13-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ jobs:
99
save:
1010
runs-on: ubuntu-latest
1111
steps:
12+
- name: Harden Runner
13+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
14+
with:
15+
egress-policy: audit
16+
1217
- name: Save PR number
1318
run: |
1419
mkdir -p ./pr
1520
echo ${{ github.event.number }} > ./pr/number
1621
echo ${{ github.event.pull_request.user.login }} > ./pr/author
17-
- uses: actions/upload-artifact@v4
22+
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
1823
with:
1924
name: pr
2025
path: pr/
@@ -32,14 +37,19 @@ jobs:
3237
--formatted
3338
3439
steps:
40+
- name: Harden Runner
41+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
42+
with:
43+
egress-policy: audit
44+
3545
- name: Checkout pull request
36-
uses: actions/checkout@v4
46+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3747
with:
3848
path: main
3949
ref: ${{ github.event.pull_request.head.sha }}
4050

4151
- name: Checkout tools
42-
uses: actions/checkout@v4
52+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4353
with:
4454
path: tools
4555
ref: develop

.github/workflows/cifuzz.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,27 @@ jobs:
88
Fuzzing:
99
runs-on: ubuntu-latest
1010
steps:
11+
- name: Harden Runner
12+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
13+
with:
14+
egress-policy: audit
15+
1116
- name: Build Fuzzers
1217
id: build
13-
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
18+
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@57fe4475324c5506adbfecdcdd2917f65c86ee9e # master
1419
with:
1520
oss-fuzz-project-name: 'json'
1621
dry-run: false
1722
language: c++
1823
- name: Run Fuzzers
19-
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
24+
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@57fe4475324c5506adbfecdcdd2917f65c86ee9e # master
2025
with:
2126
oss-fuzz-project-name: 'json'
2227
fuzz-seconds: 300
2328
dry-run: false
2429
language: c++
2530
- name: Upload Crash
26-
uses: actions/upload-artifact@v4
31+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
2732
if: failure() && steps.build.outcome == 'success'
2833
with:
2934
name: artifacts

.github/workflows/codeql-analysis.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,24 @@ jobs:
2626
security-events: write
2727

2828
steps:
29+
- name: Harden Runner
30+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
31+
with:
32+
egress-policy: audit
33+
2934
- name: Checkout repository
30-
uses: actions/checkout@v4
35+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3136

3237
# Initializes the CodeQL tools for scanning.
3338
- name: Initialize CodeQL
34-
uses: github/codeql-action/init@v3
39+
uses: github/codeql-action/init@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
3540
with:
3641
languages: c-cpp
3742

3843
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
3944
# If this step fails, then you should remove it and run the build manually (see below)
4045
- name: Autobuild
41-
uses: github/codeql-action/autobuild@v2
46+
uses: github/codeql-action/autobuild@277b89701e930e6af7a758f50afa5185bfc53c81 # v2.27.9
4247

4348
- name: Perform CodeQL Analysis
44-
uses: github/codeql-action/analyze@v2
49+
uses: github/codeql-action/analyze@277b89701e930e6af7a758f50afa5185bfc53c81 # v2.27.9

.github/workflows/comment_check_amalgamation.yml

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ jobs:
1717
issues: read
1818
pull-requests: write
1919
steps:
20+
- name: Harden Runner
21+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
22+
with:
23+
egress-policy: audit
24+
2025
- name: 'Download artifact'
2126
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6.4.0
2227
with:
+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 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/labeler.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- uses: srvaroa/labeler@master
18+
- name: Harden Runner
19+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
20+
with:
21+
egress-policy: audit
22+
23+
- uses: srvaroa/labeler@1b3cdb1af3e59155a08b9b2436d0d54feaff49e2 # master
1924
env:
2025
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/macos.yml

+26-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
# DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
2828
#
2929
# steps:
30-
# - uses: actions/checkout@v4
30+
# - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3131
# - name: Run CMake
3232
# run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
3333
# - name: Build
@@ -45,7 +45,7 @@ jobs:
4545
# DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
4646
#
4747
# steps:
48-
# - uses: actions/checkout@v4
48+
# - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4949
# - name: Run CMake
5050
# run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
5151
# - name: Build
@@ -62,7 +62,12 @@ jobs:
6262
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
6363

6464
steps:
65-
- uses: actions/checkout@v4
65+
- name: Harden Runner
66+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
67+
with:
68+
egress-policy: audit
69+
70+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
6671
- name: Run CMake
6772
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
6873
- name: Build
@@ -79,7 +84,12 @@ jobs:
7984
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
8085

8186
steps:
82-
- uses: actions/checkout@v4
87+
- name: Harden Runner
88+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
89+
with:
90+
egress-policy: audit
91+
92+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
8393
- name: Run CMake
8494
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
8595
- name: Build
@@ -96,7 +106,12 @@ jobs:
96106
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
97107

98108
steps:
99-
- uses: actions/checkout@v4
109+
- name: Harden Runner
110+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
111+
with:
112+
egress-policy: audit
113+
114+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
100115
- name: Run CMake
101116
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON
102117
- name: Build
@@ -111,7 +126,12 @@ jobs:
111126
standard: [11, 14, 17, 20, 23]
112127

113128
steps:
114-
- uses: actions/checkout@v4
129+
- name: Harden Runner
130+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
131+
with:
132+
egress-policy: audit
133+
134+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
115135
- name: Run CMake
116136
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_TestStandards=${{ matrix.standard }}
117137
- name: Build

.github/workflows/publish_documentation.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ jobs:
2323
if: github.repository == 'nlohmann/json'
2424
runs-on: ubuntu-22.04
2525
steps:
26-
- uses: actions/checkout@v4
26+
- name: Harden Runner
27+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
28+
with:
29+
egress-policy: audit
30+
31+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2732

2833
- name: Install virtual environment
2934
run: make install_venv -C docs/mkdocs
@@ -32,7 +37,7 @@ jobs:
3237
run: make build -C docs/mkdocs
3338

3439
- name: Deploy documentation
35-
uses: peaceiris/actions-gh-pages@v4
40+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
3641
with:
3742
github_token: ${{ secrets.GITHUB_TOKEN }}
3843
publish_dir: ./docs/mkdocs/site

.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: ["develop"]
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 Runner
39+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
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@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
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@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
80+
with:
81+
sarif_file: results.sarif

0 commit comments

Comments
 (0)