Skip to content

Commit 0fd0f30

Browse files
[StepSecurity] Apply security best practices (#2417) (dotnet#41814)
Signed-off-by: StepSecurity Bot <[email protected]> Co-authored-by: StepSecurity Bot <[email protected]>
1 parent 332afb8 commit 0fd0f30

27 files changed

+6009
-32
lines changed

.github/dependabot.yml

Lines changed: 5730 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/check-for-build-warnings.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
pull_request_target:
55
types: [opened, synchronize, reopened]
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
status_checker_job:
912
name: Look for build warnings
@@ -13,11 +16,16 @@ jobs:
1316
issues: write
1417
pull-requests: write
1518
steps:
16-
- uses: actions/[email protected]
19+
- name: Harden Runner
20+
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
21+
with:
22+
egress-policy: audit
23+
24+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
1725
with:
1826
ref: ${{ github.event.pull_request.head.sha }}
1927

20-
- uses: dotnet/docs-tools/actions/status-checker@main
28+
- uses: dotnet/docs-tools/actions/status-checker@5e8bcc78465d45a7544bba56509a1a69922b6a5a # main
2129
with:
2230
repo_token: ${{ secrets.GITHUB_TOKEN }}
2331
docs_path: "docs"

.github/workflows/clean-repo.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
- cron: "0 1 1 * *" # Runs at 01:00, on day 1 of the month
66
workflow_dispatch:
77

8+
permissions:
9+
contents: read
10+
811
jobs:
912
clean-repo:
1013
runs-on: ubuntu-latest
@@ -14,12 +17,17 @@ jobs:
1417
pull-requests: write
1518

1619
steps:
17-
- uses: actions/[email protected]
20+
- name: Harden Runner
21+
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
22+
with:
23+
egress-policy: audit
24+
25+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
1826

1927
# Call clean repo
2028
- name: Clean repo
2129
id: clean-repo-step
22-
uses: dotnet/docs-tools/cleanrepo/CleanRepo@main
30+
uses: dotnet/docs-tools/cleanrepo/CleanRepo@5e8bcc78465d45a7544bba56509a1a69922b6a5a # main
2331
with:
2432
docfx_directory: '.'
2533
articles_directory: 'docs'

.github/workflows/dependabot-approve-and-automerge.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ jobs:
1010
runs-on: ubuntu-latest
1111
if: ${{ github.actor == 'dependabot[bot]' && github.repository_owner == 'dotnet' }}
1212
steps:
13+
- name: Harden Runner
14+
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
15+
with:
16+
egress-policy: audit
17+
1318
- name: Dependabot metadata
1419
id: metadata
1520
uses: dependabot/fetch-metadata@dbb049abf0d677abbd7f7eee0375145b417fdd34

.github/workflows/dependabot-bot.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ on:
1313
required: true
1414
default: "Manual run"
1515
# Run on the latest version of Ubuntu
16+
permissions:
17+
contents: read
18+
1619
jobs:
1720
dependabot-bot:
1821
runs-on: ubuntu-latest
@@ -22,7 +25,12 @@ jobs:
2225

2326
# Checkout the repo into the workspace within the VM
2427
steps:
25-
- uses: actions/[email protected]
28+
- name: Harden Runner
29+
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
30+
with:
31+
egress-policy: audit
32+
33+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
2634
# - name: Setup .NET
2735
# uses: actions/setup-dotnet@4d4a70f4a5b2a5a5329f13be4ac933f2c9206ac0
2836
# with:
@@ -36,7 +44,7 @@ jobs:
3644
# Run the .NET dependabot-bot tool
3745
- name: dependabot-bot
3846
id: dependabot-bot
39-
uses: dotnet/docs-tools/actions/dependabot-bot@main
47+
uses: dotnet/docs-tools/actions/dependabot-bot@5e8bcc78465d45a7544bba56509a1a69922b6a5a # main
4048
env:
4149
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4250
with:
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@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
21+
with:
22+
egress-policy: audit
23+
24+
- name: 'Checkout Repository'
25+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
26+
- name: 'Dependency Review'
27+
uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4

.github/workflows/do-not-merge-label-check.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
branches: [main]
1010
types: [labeled, unlabeled]
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
labels-preventing-merge-check:
1417
runs-on: ubuntu-latest
@@ -18,6 +21,11 @@ jobs:
1821
# Labels that prevent merging
1922
- 'DO NOT MERGE'
2023
steps:
24+
- name: Harden Runner
25+
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
26+
with:
27+
egress-policy: audit
28+
2129
- name: 'Check "${{ matrix.label }}" label'
2230
run: |
2331
echo "::notice::Merging permission is diabled for PRs when the '${{ matrix.label }}' label is applied."

.github/workflows/docs-verifier-tryfix.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ on:
33
issue_comment:
44
types: [created]
55

6+
permissions:
7+
contents: read
8+
69
jobs:
710
tryfix:
811
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/tryfix')
@@ -13,6 +16,11 @@ jobs:
1316
IS_TRY_FIX: true # differentiates /tryfix from the validation-only run.
1417
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1518
steps:
19+
- name: Harden Runner
20+
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
21+
with:
22+
egress-policy: audit
23+
1624
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
1725
id: get-pr
1826
with:
@@ -30,14 +38,14 @@ jobs:
3038
core.setFailed(`Request failed with error ${err}`)
3139
}
3240
- name: Checkout the repository
33-
uses: actions/[email protected]
41+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
3442

3543
- name: Checkout Pull Request
3644
run: |
3745
hub pr checkout ${{ github.event.issue.number }}
3846
3947
- name: Tryfix
40-
uses: dotnet/docs-actions/actions/docs-verifier@main
48+
uses: dotnet/docs-actions/actions/docs-verifier@5e8bcc78465d45a7544bba56509a1a69922b6a5a # main
4149

4250
- name: Push changes
4351
run: |

.github/workflows/docs-verifier.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ jobs:
99
name: MSDocs build verifier
1010
runs-on: ubuntu-latest
1111
steps:
12+
- name: Harden Runner
13+
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
14+
with:
15+
egress-policy: audit
16+
1217
- name: Checkout the repository
13-
uses: actions/[email protected]
18+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
1419

1520
- name: Validate
16-
uses: dotnet/docs-actions/actions/docs-verifier@main
21+
uses: dotnet/docs-actions/actions/docs-verifier@5e8bcc78465d45a7544bba56509a1a69922b6a5a # main

.github/workflows/live-protection.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ jobs:
44
comment:
55
runs-on: ubuntu-latest
66
steps:
7+
- name: Harden Runner
8+
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
9+
with:
10+
egress-policy: audit
11+
712
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
813
env:
914
SHOULD_COMMENT: ${{ github.base_ref == 'refs/heads/live' && !(github.event.issue.user.login == 'cxwtool' || github.head_ref == 'refs/heads/main') }}

0 commit comments

Comments
 (0)