Skip to content

Commit 4026fa5

Browse files
[StepSecurity] Apply security best practices (#346)
Signed-off-by: StepSecurity Bot <[email protected]> Signed-off-by: Miguel Martinez Trivino <[email protected]> Co-authored-by: Miguel Martinez Trivino <[email protected]>
1 parent 7c40147 commit 4026fa5

File tree

7 files changed

+173
-24
lines changed

7 files changed

+173
-24
lines changed

.github/workflows/codeql.yml

+78
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 Runner
44+
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
45+
with:
46+
egress-policy: audit
47+
48+
- name: Checkout repository
49+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
50+
51+
# Initializes the CodeQL tools for scanning.
52+
- name: Initialize CodeQL
53+
uses: github/codeql-action/init@6a28655e3dcb49cb0840ea372fd6d17733edd8a4 # v2.21.8
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@6a28655e3dcb49cb0840ea372fd6d17733edd8a4 # v2.21.8
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@6a28655e3dcb49cb0840ea372fd6d17733edd8a4 # v2.21.8
77+
with:
78+
category: "/language:${{matrix.language}}"

.github/workflows/lint.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ jobs:
2424
- artifact-cas
2525
runs-on: ubuntu-latest
2626
steps:
27-
- uses: actions/setup-go@v3
27+
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
2828
with:
2929
go-version: "1.20"
3030

31-
- uses: actions/checkout@v3
31+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
3232

3333
- name: Lint main module
34-
uses: golangci/golangci-lint-action@v3
34+
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
3535
if: ${{ matrix.app == 'main-module' }}
3636
with:
3737
version: v1.52
3838

3939
- name: Lint ${{ matrix.app }}
40-
uses: golangci/golangci-lint-action@v3
40+
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
4141
if: ${{ matrix.app != 'main-module' }}
4242
with:
4343
working-directory: app/${{ matrix.app }}
@@ -46,9 +46,9 @@ jobs:
4646
lint-protos:
4747
runs-on: ubuntu-latest
4848
steps:
49-
- uses: actions/checkout@v2
50-
- uses: bufbuild/buf-setup-action@v1
49+
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
50+
- uses: bufbuild/buf-setup-action@eb60cd0de4f14f1f57cf346916b8cd69a9e7ed0b # v1.26.1
5151
with:
5252
buf_user: ${{ secrets.buf_user }}
5353
buf_api_token: ${{ secrets.buf_api_token }}
54-
- uses: bufbuild/buf-lint-action@v1
54+
- uses: bufbuild/buf-lint-action@bd48f53224baaaf0fc55de9a913e7680ca6dbea4 # v1.0.3

.github/workflows/package_chart.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ on:
88
paths:
99
- deployment/chainloop/**
1010

11-
# https://github.com/ossf/scorecard/blob/7ed886f1bd917d19cb9d6ce6c10e80e81fa31c39/docs/checks.md#token-permissions
12-
permissions: read-all
11+
permissions:
12+
contents: read
1313

1414
jobs:
1515
package:
@@ -19,16 +19,16 @@ jobs:
1919
packages: write
2020
steps:
2121
- name: Docker login to Github Packages
22-
uses: docker/login-action@v2
22+
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0
2323
with:
2424
registry: ghcr.io
2525
username: ${{ github.actor }}
2626
password: ${{ secrets.GITHUB_TOKEN }}
2727

2828
- name: Install Helm
29-
uses: azure/setup-helm@v3
29+
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
3030

31-
- uses: actions/checkout@v3
31+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
3232

3333
- name: Package Chart
3434
run: helm package deployment/chainloop/

.github/workflows/release.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
CONTAINER_IMAGE_CAS: ghcr.io/chainloop-dev/chainloop/artifact-cas:${{ github.ref_name }}
3030
steps:
3131
- name: Install Cosign
32-
uses: sigstore/cosign-installer@main
32+
uses: sigstore/cosign-installer@ef6a6b364bbad08abd36a5f8af60b595d12702f8 # main
3333
with:
3434
cosign-release: "v2.0.2"
3535

@@ -43,7 +43,7 @@ jobs:
4343
sudo chmod u+x /usr/local/bin/jq
4444
4545
- name: Checkout
46-
uses: actions/checkout@v3
46+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
4747
with:
4848
fetch-depth: 0
4949

@@ -52,20 +52,20 @@ jobs:
5252
chainloop attestation init
5353
5454
- name: Docker login to Github Packages
55-
uses: docker/login-action@v2
55+
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0
5656
with:
5757
registry: ghcr.io
5858
username: ${{ github.actor }}
5959
password: ${{ secrets.GITHUB_TOKEN }}
6060

6161
- name: Set up Go
62-
uses: actions/setup-go@v3
62+
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
6363
with:
6464
go-version: "1.20"
6565

6666
- name: Run GoReleaser
6767
id: release
68-
uses: goreleaser/goreleaser-action@v3
68+
uses: goreleaser/goreleaser-action@b508e2e3ef3b19d4e4146d4f8fb3ba9db644a757 # v3.2.0
6969
with:
7070
distribution: goreleaser
7171
version: latest
@@ -75,14 +75,14 @@ jobs:
7575
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
7676
COSIGN_KEY: ${{ secrets.COSIGN_KEY }}
7777

78-
- uses: anchore/sbom-action@v0
78+
- uses: anchore/sbom-action@78fc58e266e87a38d4194b2137a3d4e9bcaf7ca1 # v0.14.3
7979
with:
8080
image: ${{ env.CONTAINER_IMAGE_CP }}
8181
format: cyclonedx-json
8282
artifact-name: controlplane.cyclonedx.json
8383
output-file: /tmp/sbom.cp.cyclonedx.json
8484

85-
- uses: anchore/sbom-action@v0
85+
- uses: anchore/sbom-action@78fc58e266e87a38d4194b2137a3d4e9bcaf7ca1 # v0.14.3
8686
with:
8787
image: ${{ env.CONTAINER_IMAGE_CAS }}
8888
format: cyclonedx-json
@@ -125,7 +125,7 @@ jobs:
125125
run: .github/workflows/utils/bump-chart-version.sh deployment/chainloop ${{ github.ref_name }}
126126

127127
- name: Create Pull Request
128-
uses: peter-evans/create-pull-request@v5
128+
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2
129129
with:
130130
commit-message: Bump Chart Version ${{ github.ref_name }}
131131
signoff: true

.github/workflows/scorecards.yml

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

.github/workflows/test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ jobs:
2424
- controlplane
2525
- artifact-cas
2626
steps:
27-
- uses: actions/checkout@v3
28-
- uses: actions/setup-go@v3
27+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
28+
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
2929
with:
3030
# go-version-file: go.mod
3131
# for now pin the verify action to 1.20.5
@@ -54,7 +54,7 @@ jobs:
5454
5555
# Check that the generated ent code is up to date
5656
# see https://entgo.io/docs/ci/
57-
- uses: ent/contrib/ci@master
57+
- uses: ent/contrib/ci@e38dfb6484dfbe64b8bd060fe6a219a1aa5da770 # master
5858
name: "Check all generated code is checked in"
5959
if: ${{ matrix.app != 'main-module' }}
6060
with:

app/controlplane/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.20 AS builder
1+
FROM golang:1.20@sha256:6e1a67ec11cc4eaa7a9699bc6e5385b00001669531284005ebd2ada4129138d9 AS builder
22

33
# Not linked libraries since it will be injected into a scratch container
44
ENV CGO_ENABLED=0

0 commit comments

Comments
 (0)