Skip to content

Commit 839a038

Browse files
[StepSecurity] Apply security best practices (#34)
Signed-off-by: StepSecurity Bot <[email protected]>
1 parent a32d3b3 commit 839a038

File tree

6 files changed

+237
-17
lines changed

6 files changed

+237
-17
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Build
22

33
on: [push]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69

710
build:
@@ -11,13 +14,18 @@ jobs:
1114
name: '${{ matrix.platform }}'
1215
runs-on: ${{ matrix.platform }}
1316
steps:
17+
- name: Harden the runner (Audit all outbound calls)
18+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
19+
with:
20+
egress-policy: audit
21+
1422
- name: Check out repository code
15-
uses: actions/checkout@v4
23+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1624
with:
1725
fetch-depth: 0
1826

1927
- name: Install go 1.22
20-
uses: actions/setup-go@v5
28+
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
2129
with:
2230
go-version-file: go.mod
2331

@@ -44,47 +52,47 @@ jobs:
4452
GOOS=linux GOARCH=arm64 go build -o build/lin-arm64/vidx2pidx ./cmd
4553
4654
- name: Archive windows amd64 binaries
47-
uses: actions/upload-artifact@v4
55+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
4856
with:
4957
name: vidx2pidx-windows-amd64
5058
path: ./build/win-amd64/vidx2pidx.exe
5159
retention-days: 1
5260
if-no-files-found: error
5361

5462
- name: Archive windows arm64 binaries
55-
uses: actions/upload-artifact@v4
63+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
5664
with:
5765
name: vidx2pidx-windows-arm64
5866
path: ./build/win-arm64/vidx2pidx.exe
5967
retention-days: 1
6068
if-no-files-found: error
6169

6270
- name: Archive macos amd64 binaries
63-
uses: actions/upload-artifact@v4
71+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
6472
with:
6573
name: vidx2pidx-mac-amd64
6674
path: ./build/mac-amd64/vidx2pidx
6775
retention-days: 1
6876
if-no-files-found: error
6977

7078
- name: Archive macos arm64 binaries
71-
uses: actions/upload-artifact@v4
79+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
7280
with:
7381
name: vidx2pidx-mac-arm64
7482
path: ./build/mac-arm64/vidx2pidx
7583
retention-days: 1
7684
if-no-files-found: error
7785

7886
- name: Archive linux amd64 binaries
79-
uses: actions/upload-artifact@v4
87+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
8088
with:
8189
name: vidx2pidx-lin-amd64
8290
path: ./build/lin-amd64/vidx2pidx
8391
retention-days: 1
8492
if-no-files-found: error
8593

8694
- name: Archive linux arm64 binaries
87-
uses: actions/upload-artifact@v4
95+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
8896
with:
8997
name: vidx2pidx-lin-arm64
9098
path: ./build/lin-arm64/vidx2pidx

.github/workflows/codeql.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: ["main"]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: ["main"]
20+
schedule:
21+
- cron: "0 0 * * 1"
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
analyze:
28+
name: Analyze
29+
runs-on: ubuntu-latest
30+
permissions:
31+
actions: read
32+
contents: read
33+
security-events: write
34+
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
language: ["go"]
39+
# CodeQL supports [ $supported-codeql-languages ]
40+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
41+
42+
steps:
43+
- name: Harden the runner (Audit all outbound calls)
44+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
45+
with:
46+
egress-policy: audit
47+
48+
- name: Checkout repository
49+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
50+
51+
# Initializes the CodeQL tools for scanning.
52+
- name: Initialize CodeQL
53+
uses: github/codeql-action/init@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
54+
with:
55+
languages: ${{ matrix.language }}
56+
# If you wish to specify custom queries, you can do so here or in a config file.
57+
# By default, queries listed here will override any specified in a config file.
58+
# Prefix the list here with "+" to use these queries and those in the config file.
59+
60+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
61+
# If this step fails, then you should remove it and run the build manually (see below)
62+
- name: Autobuild
63+
uses: github/codeql-action/autobuild@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
64+
65+
# ℹ️ Command-line programs to run using the OS shell.
66+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
67+
68+
# If the Autobuild fails above, remove it and uncomment the following three lines.
69+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
70+
71+
# - run: |
72+
# echo "Run, Build Application using script"
73+
# ./location_of_script_within_repo/buildscript.sh
74+
75+
- name: Perform CodeQL Analysis
76+
uses: github/codeql-action/analyze@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
77+
with:
78+
category: "/language:${{matrix.language}}"
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 the runner (Audit all outbound calls)
20+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
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/release.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@ jobs:
1515
contents: write
1616
runs-on: ubuntu-latest
1717
steps:
18+
- name: Harden the runner (Audit all outbound calls)
19+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
20+
with:
21+
egress-policy: audit
22+
1823
- name: Checkout
19-
uses: actions/checkout@v4
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2025
with:
2126
fetch-depth: 0
2227

2328
- name: Set up Go 1.22
24-
uses: actions/setup-go@v5
29+
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
2530
with:
2631
go-version-file: go.mod
2732
check-latest: true
@@ -31,7 +36,7 @@ jobs:
3136
./scripts/release_notes > /tmp/RELEASE_NOTES
3237
3338
- name: Run GoReleaser
34-
uses: goreleaser/goreleaser-action@v6
39+
uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3 # v6.2.1
3540
with:
3641
version: latest
3742
args: release ${{ github.event_name != 'push' && '--snapshot' || '' }} --clean --release-notes=/tmp/RELEASE_NOTES

.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: ["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+
# 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@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
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@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@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
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@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
80+
with:
81+
sarif_file: results.sarif

.github/workflows/test.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,29 @@ name: Test
22

33
on: [push, pull_request, workflow_call]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69

710
lint:
11+
permissions:
12+
contents: read # for actions/checkout to fetch code
13+
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
814
name: Lint
915
timeout-minutes: 10
1016
strategy:
1117
matrix:
1218
platform: [ubuntu-latest]
1319
runs-on: ${{ matrix.platform }}
1420
steps:
15-
- uses: actions/checkout@v4
16-
- uses: golangci/golangci-lint-action@v6
21+
- name: Harden the runner (Audit all outbound calls)
22+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
23+
with:
24+
egress-policy: audit
25+
26+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
- uses: golangci/golangci-lint-action@2226d7cb06a077cd73e56eedd38eecad18e5d837 # v6.5.0
1728
with:
1829
# must be specified without patch version
1930
version: latest
@@ -26,10 +37,15 @@ jobs:
2637
go: [1.22.x]
2738
runs-on: ${{ matrix.platform }}
2839
steps:
40+
- name: Harden the runner (Audit all outbound calls)
41+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
42+
with:
43+
egress-policy: audit
44+
2945
- name: Check out repository code
30-
uses: actions/checkout@v4
46+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3147
- name: Install go 1.22
32-
uses: actions/setup-go@v5
48+
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
3349
with:
3450
go-version: ${{ matrix.go }}
3551
- name: Check formatting
@@ -44,10 +60,15 @@ jobs:
4460
name: '${{ matrix.platform }} | ${{ matrix.go }}'
4561
runs-on: ${{ matrix.platform }}
4662
steps:
63+
- name: Harden the runner (Audit all outbound calls)
64+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
65+
with:
66+
egress-policy: audit
67+
4768
- name: Check out repository code
48-
uses: actions/checkout@v4
69+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4970
- name: Install go 1.22
50-
uses: actions/setup-go@v5
71+
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
5172
with:
5273
go-version: ${{ matrix.go }}
5374
- name: Unit testing

0 commit comments

Comments
 (0)