Skip to content

Commit 7c40147

Browse files
authored
fix: least privilege support in automated workflows (#347)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent c5af143 commit 7c40147

File tree

7 files changed

+18
-7
lines changed

7 files changed

+18
-7
lines changed

.github/workflows/lint.yml

+2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ on:
55
branches:
66
- main
77
pull_request:
8+
89
permissions:
910
contents: read
1011
# Optional: allow read access to pull request. Use with `only-new-issues` option.
1112
pull-requests: read
13+
1214
jobs:
1315
golangci:
1416
name: lint

.github/workflows/package_chart.yaml

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

11+
# https://github.com/ossf/scorecard/blob/7ed886f1bd917d19cb9d6ce6c10e80e81fa31c39/docs/checks.md#token-permissions
12+
permissions: read-all
13+
1114
jobs:
1215
package:
1316
name: Package and push Helm Chart
@@ -35,4 +38,3 @@ jobs:
3538
for pkg in chainloop*.tgz; do
3639
helm push ${pkg} oci://ghcr.io/chainloop-dev/charts
3740
done
38-

.github/workflows/release.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
tags:
66
- "v*.*.*"
77

8+
# https://github.com/ossf/scorecard/blob/7ed886f1bd917d19cb9d6ce6c10e80e81fa31c39/docs/checks.md#token-permissions
9+
permissions:
10+
contents: read
11+
812
jobs:
913
test:
1014
uses: chainloop-dev/chainloop/.github/workflows/test.yml@main
@@ -27,7 +31,7 @@ jobs:
2731
- name: Install Cosign
2832
uses: sigstore/cosign-installer@main
2933
with:
30-
cosign-release: 'v2.0.2'
34+
cosign-release: "v2.0.2"
3135

3236
- name: Install Chainloop
3337
run: |

.github/workflows/test.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
# We want to call this workflow during release too
99
workflow_call:
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
build_and_test:
1316
name: Test
@@ -29,7 +32,7 @@ jobs:
2932
# due to issue with testcontainers
3033
# https://github.com/golang/go/issues/61431
3134
# https://github.com/testcontainers/testcontainers-go/issues/1359
32-
go-version: '1.20.5'
35+
go-version: "1.20.5"
3336
cache: true
3437
cache-dependency-path: go.sum
3538

internal/attestation/crafter/materials/cyclonedxjson_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestCyclonedxJSONCraft(t *testing.T) {
7676
},
7777
{
7878
name: "invalid sbom format",
79-
filePath: "./testdata/sbom.spdx.json",
79+
filePath: "./testdata/sbom-spdx.json",
8080
wantErr: "unexpected material type",
8181
},
8282
{

internal/attestation/crafter/materials/spdxjson_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func TestSPDXJSONCraft(t *testing.T) {
8787
},
8888
{
8989
name: "valid artifact type",
90-
filePath: "./testdata/sbom.spdx.json",
90+
filePath: "./testdata/sbom-spdx.json",
9191
},
9292
}
9393

@@ -105,7 +105,7 @@ func TestSPDXJSONCraft(t *testing.T) {
105105
uploader.On("UploadFile", context.TODO(), tc.filePath).
106106
Return(&casclient.UpDownStatus{
107107
Digest: "deadbeef",
108-
Filename: "sbom.spdx.json",
108+
Filename: "sbom-spdx.json",
109109
}, nil)
110110
}
111111

@@ -125,7 +125,7 @@ func TestSPDXJSONCraft(t *testing.T) {
125125

126126
// // The result includes the digest reference
127127
assert.Equal(got.GetArtifact(), &attestationApi.Attestation_Material_Artifact{
128-
Id: "test", Digest: "sha256:fe2636fb6c698a29a315278b762b2000efd5959afe776ee4f79f1ed523365a33", Name: "sbom.spdx.json",
128+
Id: "test", Digest: "sha256:fe2636fb6c698a29a315278b762b2000efd5959afe776ee4f79f1ed523365a33", Name: "sbom-spdx.json",
129129
})
130130
})
131131
}

0 commit comments

Comments
 (0)