Skip to content

Commit cfec46b

Browse files
[StepSecurity] Apply security best practices (#205)
Signed-off-by: StepSecurity Bot <[email protected]>
1 parent 642b1b0 commit cfec46b

File tree

9 files changed

+160
-11
lines changed

9 files changed

+160
-11
lines changed

.github/dependabot.yml

+10
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,13 @@ updates:
3838
schedule:
3939
interval: "weekly"
4040
day: "saturday"
41+
42+
- package-ecosystem: docker
43+
directory: /Docker/Linux
44+
schedule:
45+
interval: daily
46+
47+
- package-ecosystem: docker
48+
directory: /Docker/Windows
49+
schedule:
50+
interval: daily

.github/workflows/Build.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ jobs:
3838
BUILD_TYPE: ${{inputs.configuration}}
3939

4040
steps:
41-
- uses: actions/checkout@v4
41+
- name: Harden Runner
42+
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
43+
with:
44+
egress-policy: audit
45+
46+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
4247
with:
4348
submodules: 'recursive'
4449

@@ -109,15 +114,15 @@ jobs:
109114
110115
- name: Upload build as artifact
111116
if: inputs.platform == 'windows-2019' && (github.event_name == 'schedule' || github.event_name == 'push') && github.ref == 'refs/heads/main' && env.BUILD_TYPE == 'RelWithDebInfo'
112-
uses: actions/upload-artifact@v4
117+
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
113118
with:
114119
name: bpf_conformance-Release
115120
path: |
116121
${{github.workspace}}/build/upload
117122
118123
- name: Upload build as artifact
119124
if: inputs.platform == 'windows-2019' && (github.event_name == 'schedule' || github.event_name == 'push') && github.ref == 'refs/heads/main' && env.BUILD_TYPE == 'Debug'
120-
uses: actions/upload-artifact@v4
125+
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
121126
with:
122127
name: bpf_conformance-Debug
123128
path: |
@@ -137,7 +142,7 @@ jobs:
137142
138143
- name: Coveralls Parallel
139144
if: inputs.enable_coverage == true
140-
uses: coverallsapp/[email protected]
145+
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949 # v2.2.3
141146
with:
142147
github-token: ${{ secrets.github_token }}
143148
flag-name: run-${{inputs.build_type}}-${{inputs.platform}}-${{inputs.arch}}

.github/workflows/CICD.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,13 @@ jobs:
124124
- ubuntu_debug_coverage
125125
runs-on: ubuntu-latest
126126
steps:
127+
- name: Harden Runner
128+
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
129+
with:
130+
egress-policy: audit
131+
127132
- name: Coveralls Finished
128-
uses: coverallsapp/[email protected]
133+
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949 # v2.2.3
129134
with:
130135
github-token: ${{ secrets.github_token }}
131136
parallel-finished: true

.github/workflows/codeql-analysis.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ concurrency:
2929
group: codeql-${{ github.event.pull_request.number || github.sha }}
3030
cancel-in-progress: true
3131

32+
permissions:
33+
contents: read
34+
3235
jobs:
3336
analyze:
3437
name: Analyze
@@ -46,14 +49,19 @@ jobs:
4649
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
4750

4851
steps:
52+
- name: Harden Runner
53+
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
54+
with:
55+
egress-policy: audit
56+
4957
- name: Checkout repository
50-
uses: actions/checkout@v4
58+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
5159
with:
5260
submodules: 'recursive'
5361

5462
# Initializes the CodeQL tools for scanning.
5563
- name: Initialize CodeQL
56-
uses: github/codeql-action/init@v3
64+
uses: github/codeql-action/init@47b3d888fe66b639e431abf22ebca059152f1eea # v3.24.5
5765
with:
5866
languages: ${{ matrix.language }}
5967
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -74,7 +82,7 @@ jobs:
7482
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
7583
# If this step fails, then you should remove it and run the build manually (see below)
7684
- name: Autobuild
77-
uses: github/codeql-action/autobuild@v3
85+
uses: github/codeql-action/autobuild@47b3d888fe66b639e431abf22ebca059152f1eea # v3.24.5
7886

7987
# ℹ️ Command-line programs to run using the OS shell.
8088
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -87,6 +95,6 @@ jobs:
8795
# ./location_of_script_within_repo/buildscript.sh
8896

8997
- name: Perform CodeQL Analysis
90-
uses: github/codeql-action/analyze@v3
98+
uses: github/codeql-action/analyze@47b3d888fe66b639e431abf22ebca059152f1eea # v3.24.5
9199
with:
92100
category: "/language:${{matrix.language}}"
+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@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
21+
with:
22+
egress-policy: audit
23+
24+
- name: 'Checkout Repository'
25+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
26+
- name: 'Dependency Review'
27+
uses: actions/dependency-review-action@0efb1d1d84fc9633afcdaad14c485cbbc90ef46c # v2.5.1

.github/workflows/scorecards.yml

+76
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@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
35+
with:
36+
egress-policy: audit
37+
38+
- name: "Checkout code"
39+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
40+
with:
41+
persist-credentials: false
42+
43+
- name: "Run analysis"
44+
uses: ossf/scorecard-action@99c53751e09b9529366343771cc321ec74e9bd3d # v2.0.6
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@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
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@a56a03b370b87b26fde6d680755f818cfda0372b # v2.24.5
75+
with:
76+
sarif_file: results.sarif

.pre-commit-config.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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/pocc/pre-commit-hooks
11+
rev: v1.3.5
12+
hooks:
13+
- id: cpplint
14+
- repo: https://github.com/pre-commit/pre-commit-hooks
15+
rev: v4.4.0
16+
hooks:
17+
- id: end-of-file-fixer
18+
- id: trailing-whitespace

Docker/Linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) Microsoft Corporation
22
# SPDX-License-Identifier: MIT
33

4-
FROM ubuntu:22.04
4+
FROM ubuntu:22.04@sha256:f9d633ff6640178c2d0525017174a688e2c1aef28f0a0130b26bd5554491f0da
55

66
# Install dependencies
77
RUN apt-get update && apt-get install -y \

Docker/Windows/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) Microsoft Corporation
22
# SPDX-License-Identifier: MIT
33

4-
FROM mcr.microsoft.com/windows/nanoserver:ltsc2019
4+
FROM mcr.microsoft.com/windows/nanoserver:ltsc2019@sha256:0bd2e8d6d5cdb26eac9ebb0ef939a3b6362af71f3c1ac257fd5f0c53d1fc1388
55

66
WORKDIR /app
77

0 commit comments

Comments
 (0)