Skip to content

Commit bc88ead

Browse files
[StepSecurity] Apply security best practices
Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
1 parent b440994 commit bc88ead

9 files changed

Lines changed: 170 additions & 18 deletions

File tree

.github/dependabot.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,33 @@ updates:
44
directory: "/"
55
schedule:
66
interval: monthly
7+
8+
- package-ecosystem: github-actions
9+
directory: /
10+
schedule:
11+
interval: daily
12+
13+
- package-ecosystem: nuget
14+
directory: /Microsoft.Security.Application.Encoder.UnitTests
15+
schedule:
16+
interval: daily
17+
18+
- package-ecosystem: nuget
19+
directory: /Microsoft.Security.Application.Encoder
20+
schedule:
21+
interval: daily
22+
23+
- package-ecosystem: nuget
24+
directory: /Microsoft.Security.Application.HtmlSanitization.Tests
25+
schedule:
26+
interval: daily
27+
28+
- package-ecosystem: nuget
29+
directory: /Microsoft.Security.Application.HtmlSanitization
30+
schedule:
31+
interval: daily
32+
33+
- package-ecosystem: npm
34+
directory: /
35+
schedule:
36+
interval: daily

.github/workflows/codeql.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ on:
2020
schedule:
2121
- cron: "42 2 * * 5"
2222

23+
permissions:
24+
contents: read
25+
2326
jobs:
2427
analyze:
2528
name: Analyze
@@ -35,19 +38,24 @@ jobs:
3538
language: ["csharp"]
3639

3740
steps:
41+
- name: Harden the runner (Audit all outbound calls)
42+
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
43+
with:
44+
egress-policy: audit
45+
3846
- name: Checkout repository
39-
uses: actions/checkout@v5.0.0
47+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4048
with:
4149
fetch-depth: 0
4250

4351
# Initializes the CodeQL tools for scanning.
4452
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v3.30.5
53+
uses: github/codeql-action/init@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5
4654
with:
4755
languages: ${{ matrix.language }}
4856

4957
- name: Autobuild
50-
uses: github/codeql-action/autobuild@v3.30.5
58+
uses: github/codeql-action/autobuild@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5
5159

5260
- name: Perform CodeQL Analysis
53-
uses: github/codeql-action/analyze@v3.30.5
61+
uses: github/codeql-action/analyze@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5

.github/workflows/component-detection.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ jobs:
1212
dependency-submission:
1313
runs-on: ubuntu-slim
1414
steps:
15-
- uses: actions/checkout@v5.0.0
15+
- name: Harden the runner (Audit all outbound calls)
16+
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
17+
with:
18+
egress-policy: audit
19+
20+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1621
- name: Component detection
17-
uses: advanced-security/component-detection-dependency-submission-action@v0.1.0
22+
uses: advanced-security/component-detection-dependency-submission-action@d433c2f467e149a8009c8fbce92cc708ed15ef7b # v0.1.0

.github/workflows/dependency-review.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ jobs:
88
dependency-review:
99
runs-on: ubuntu-slim
1010
steps:
11+
- name: Harden the runner (Audit all outbound calls)
12+
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
13+
with:
14+
egress-policy: audit
15+
1116
- name: "Checkout Repository"
12-
uses: actions/checkout@v5.0.0
17+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1318
- name: "Dependency Review"
14-
uses: actions/dependency-review-action@v4.8.0
19+
uses: actions/dependency-review-action@56339e523c0409420f6c2c9a2f4292bbb3c07dd3 # v4.8.0

.github/workflows/dotnet.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ jobs:
2121
runs-on: ubuntu-slim
2222

2323
steps:
24-
- uses: actions/checkout@v5.0.0
24+
- name: Harden the runner (Audit all outbound calls)
25+
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
26+
with:
27+
egress-policy: audit
28+
29+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2530
- name: Setup .NET
26-
uses: actions/setup-dotnet@v5.0.0
31+
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
2732
with:
2833
global-json-file: global.json
2934
- name: Restore tools
@@ -39,13 +44,13 @@ jobs:
3944
run: |
4045
find . -name "*.trx" -exec dotnet tool run trx2junit --output TestResults/JUnit {} +
4146
- name: Upload coverage reports to Codecov
42-
uses: codecov/codecov-action@v5.5.1
47+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
4348
with:
4449
token: ${{ secrets.CODECOV_TOKEN }}
4550
slug: AlbusKavaliro/AntiXss
4651
- name: Upload test results to Codecov
4752
if: ${{ !cancelled() }}
48-
uses: codecov/test-results-action@v1.1.1
53+
uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1.1.1
4954
with:
5055
files: TestResults/JUnit/*.xml
5156
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/linter.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ on:
2424
###############
2525
# Set the Job #
2626
###############
27+
permissions:
28+
contents: read
29+
2730
jobs:
2831
build:
2932
# Name the Job
@@ -46,8 +49,13 @@ jobs:
4649
##########################
4750
# Checkout the code base #
4851
##########################
52+
- name: Harden the runner (Audit all outbound calls)
53+
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
54+
with:
55+
egress-policy: audit
56+
4957
- name: Checkout Code
50-
uses: actions/checkout@v5.0.0
58+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
5159
with:
5260
# Full git history is needed to get a proper
5361
# list of changed files within `super-linter`
@@ -57,7 +65,7 @@ jobs:
5765
# Run Linter against code base #
5866
################################
5967
- name: Lint Code Base
60-
uses: super-linter/super-linter@v8.3.1
68+
uses: super-linter/super-linter@47984f49b4e87383eed97890fe2dca6063bbd9c3 # v8.3.1
6169
env:
6270
VALIDATE_ALL_CODEBASE: false
6371
DEFAULT_BRANCH: main

.github/workflows/release.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,23 @@ jobs:
2222
id-token: write # to enable use of OIDC for npm provenance
2323
packages: write # to be able to publish to GitHub Packages
2424
steps:
25+
- name: Harden the runner (Audit all outbound calls)
26+
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
27+
with:
28+
egress-policy: audit
29+
2530
- name: Checkout
26-
uses: actions/checkout@v5.0.0
31+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2732
with:
2833
fetch-depth: 0
2934
- name: Setup .NET
30-
uses: actions/setup-dotnet@v5.0.0
35+
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
3136
with:
3237
global-json-file: global.json
3338
- name: Restore dependencies
3439
run: dotnet restore --locked-mode
3540
- name: Setup Node.js
36-
uses: actions/setup-node@v5.0.0
41+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
3742
with:
3843
node-version: "lts/*"
3944
check-latest: true

.github/workflows/scorecards.yml

Lines changed: 81 additions & 0 deletions
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: ["dev"]
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@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
40+
with:
41+
egress-policy: audit
42+
43+
- name: "Checkout code"
44+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
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@ebcb5b36ded6beda4ceefea6a8bc4cc885255bb3 # v3.34.1
80+
with:
81+
sarif_file: results.sarif

.github/workflows/semantic-pull-request.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ jobs:
1515
name: Validate PR title
1616
runs-on: ubuntu-slim
1717
steps:
18-
- uses: amannn/action-semantic-pull-request@v6.1.1
18+
- name: Harden the runner (Audit all outbound calls)
19+
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
20+
with:
21+
egress-policy: audit
22+
23+
- uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
1924
env:
2025
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)