Skip to content

Commit acc7fc1

Browse files
[StepSecurity] Apply security best practices
Signed-off-by: StepSecurity Bot <[email protected]>
1 parent 8e42bcb commit acc7fc1

File tree

7 files changed

+157
-8
lines changed

7 files changed

+157
-8
lines changed

.github/workflows/000-codeql.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ on:
2323
schedule:
2424
- cron: '41 9 * * 1'
2525

26+
permissions:
27+
contents: read
28+
2629
jobs:
2730
analyze:
2831
name: Analyze
@@ -42,12 +45,17 @@ jobs:
4245
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
4346

4447
steps:
48+
- name: Harden Runner
49+
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
50+
with:
51+
egress-policy: audit
52+
4553
- name: Checkout repository
46-
uses: actions/checkout@v3
54+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
4755

4856
# Initializes the CodeQL tools for scanning.
4957
- name: Initialize CodeQL
50-
uses: github/codeql-action/init@v2
58+
uses: github/codeql-action/init@3e0e84636c6f5df46a2cb232ae1dd1384713150d # v2.25.15
5159
with:
5260
languages: ${{ matrix.language }}
5361
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -75,7 +83,7 @@ jobs:
7583
${GITHUB_WORKSPACE}/ux-src/MkGCC.sh ${GITHUB_WORKSPACE}/ux-src
7684
7785
- name: Perform CodeQL Analysis
78-
uses: github/codeql-action/analyze@v2
86+
uses: github/codeql-action/analyze@3e0e84636c6f5df46a2cb232ae1dd1384713150d # v2.25.15
7987
with:
8088
category: "/language:${{matrix.language}}"
8189

.github/workflows/001-flawfinder.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ on:
1717
schedule:
1818
- cron: '45 19 * * 1'
1919

20+
permissions:
21+
contents: read
22+
2023
jobs:
2124
flawfinder:
2225
name: Flawfinder
@@ -26,8 +29,13 @@ jobs:
2629
contents: read
2730
security-events: write
2831
steps:
32+
- name: Harden Runner
33+
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
34+
with:
35+
egress-policy: audit
36+
2937
- name: Checkout code
30-
uses: actions/checkout@v3
38+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
3139

3240
- name: Prepare RISC OS source tree
3341
run: bash ${GITHUB_WORKSPACE}/.rocog/scripts/ux-src gen github ${GITHUB_WORKSPACE}
@@ -39,4 +47,4 @@ jobs:
3947
output: 'flawfinder_results.sarif'
4048

4149
- name: Upload analysis results to GitHub Security tab
42-
uses: github/codeql-action/upload-sarif@v2
50+
uses: github/codeql-action/upload-sarif@3e0e84636c6f5df46a2cb232ae1dd1384713150d # v2.25.15
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@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
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/scorecards.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
32+
steps:
33+
- name: Harden Runner
34+
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
35+
with:
36+
egress-policy: audit
37+
38+
- name: "Checkout code"
39+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
40+
with:
41+
persist-credentials: false
42+
43+
- name: "Run analysis"
44+
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
45+
with:
46+
results_file: results.sarif
47+
results_format: sarif
48+
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
49+
# - you want to enable the Branch-Protection check on a *public* repository, or
50+
# - you are installing Scorecards on a *private* repository
51+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
52+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
53+
54+
# Public repositories:
55+
# - Publish results to OpenSSF REST API for easy access by consumers
56+
# - Allows the repository to include the Scorecard badge.
57+
# - See https://github.com/ossf/scorecard-action#publishing-results.
58+
# For private repositories:
59+
# - `publish_results` will always be set to `false`, regardless
60+
# of the value entered here.
61+
publish_results: true
62+
63+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
64+
# format to the repository Actions tab.
65+
- name: "Upload artifact"
66+
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
67+
with:
68+
name: SARIF file
69+
path: results.sarif
70+
retention-days: 5
71+
72+
# Upload the results to GitHub's code scanning dashboard.
73+
- name: "Upload to code-scanning"
74+
uses: github/codeql-action/upload-sarif@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15
75+
with:
76+
sarif_file: results.sarif

.github/workflows/sync-from-template.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ env:
3434
REPO_TEMPLATE: RISC-OS-Community/StandardRepoTemplate
3535
THIS_REPO: ${{ github.repository }}
3636

37+
permissions:
38+
contents: read
39+
3740
jobs:
3841
sync-from-template:
3942
# Do not run on the template repository itself
@@ -50,8 +53,13 @@ jobs:
5053

5154
steps:
5255
# Clone the template repository
56+
- name: Harden Runner
57+
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
58+
with:
59+
egress-policy: audit
60+
5361
- name: Check out template repository
54-
uses: actions/checkout@v2
62+
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
5563
with:
5664
repository: ${{ env.REPO_TEMPLATE }}
5765
token: ${{ github.token }}
@@ -65,7 +73,7 @@ jobs:
6573

6674
# Clone the target repository. Check out a branch
6775
- name: Check out ${{ github.repository }}
68-
uses: actions/checkout@v2
76+
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
6977
with:
7078
repository: ${{ github.repository }}
7179
token: ${{ github.token }}

.github/workflows/tweet-pull-request.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ on:
2525
env:
2626
THIS_REPO: ${{ github.repository }}
2727

28+
permissions:
29+
contents: read
30+
2831
jobs:
2932
# init:
3033
# runs-on: ubuntu-latest
@@ -42,10 +45,15 @@ jobs:
4245
tweet:
4346
runs-on: ubuntu-latest
4447
steps:
48+
- name: Harden Runner
49+
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
50+
with:
51+
egress-policy: audit
52+
4553
- name: Set current date as env variable
4654
run: echo "MSG_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
4755
- name: Send Tweet
48-
uses: ethomson/send-tweet-action@v1
56+
uses: ethomson/send-tweet-action@288f9339e0412e3038dce350e0da5ecdf12133a6 # v1.0.0
4957
with:
5058
status: "🎉 Today: ${{ env.MSG_DATE }}, new merge in ${{ env.THIS_REPO }}! ${{ github.event.pull_request.title }} You can check it out here: https://github.com/${{ env.THIS_REPO }} #RISC_OS #RISCOS #ROCOnGitHub #OpenSource #DevCommunity"
5159
consumer-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }}

.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/jumanjihouse/pre-commit-hooks
7+
rev: 3.0.0
8+
hooks:
9+
- id: shellcheck
10+
- repo: https://github.com/pre-commit/pre-commit-hooks
11+
rev: v4.4.0
12+
hooks:
13+
- id: end-of-file-fixer
14+
- id: trailing-whitespace

0 commit comments

Comments
 (0)