Skip to content

Commit e52cd03

Browse files
Add OpenSSF Scorecards GitHub Action (#1795)
Signed-off-by: Matthieu MOREL <[email protected]> Co-authored-by: Manuel de la Peña <[email protected]>
1 parent caaf25a commit e52cd03

File tree

4 files changed

+84
-10
lines changed

4 files changed

+84
-10
lines changed

.github/workflows/ci-test-go.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ jobs:
5353
steps:
5454
- name: Setup rootless Docker
5555
if: ${{ inputs.rootless-docker }}
56-
uses: ScribeMD/rootless-docker@0.2.2
56+
uses: ScribeMD/rootless-docker@6bd157a512c2fafa4e0243a8aa87d964eb890886 # v0.2.2
5757

5858
- name: Remove Docket root socket
5959
if: ${{ inputs.rootless-docker }}
6060
run: sudo rm -rf /var/run/docker.sock
6161

6262
- name: Check out code into the Go module directory
63-
uses: actions/checkout@v4
63+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
6464

6565
- name: Set up Go
66-
uses: actions/setup-go@v4
66+
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4
6767
with:
6868
go-version: '${{ inputs.go-version }}'
6969
cache-dependency-path: '${{ inputs.project-directory }}/go.sum'
@@ -72,7 +72,7 @@ jobs:
7272
- name: golangci-lint
7373
# TODO: Remove each example/module once it passes the golangci-lint
7474
if: ${{ inputs.platform == 'ubuntu-latest' && inputs.go-version == '1.20.x' && !contains(fromJSON('["examples/cockroachdb", "examples/toxiproxy", "modules/compose", "modules/pulsar", "modules/redis"]'), inputs.project-directory) }}
75-
uses: golangci/golangci-lint-action@v3
75+
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3
7676
with:
7777
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
7878
version: v1.54.1
@@ -110,7 +110,7 @@ jobs:
110110
111111
- name: Upload SonarCloud files
112112
if: ${{ github.ref_name == 'main' && github.repository_owner == 'testcontainers' && inputs.run-tests && !inputs.rootless-docker }}
113-
uses: actions/upload-artifact@v3
113+
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
114114
with:
115115
name: sonarcloud
116116
path: |
@@ -123,7 +123,7 @@ jobs:
123123
./scripts/check_environment.sh
124124
125125
- name: Test Summary
126-
uses: test-summary/action@62bc5c68de2a6a0d02039763b8c754569df99e3f
126+
uses: test-summary/action@62bc5c68de2a6a0d02039763b8c754569df99e3f # v2
127127
with:
128128
paths: "**/${{ inputs.project-directory }}/TEST-unit*.xml"
129129
if: always()

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
steps:
4848
- name: Checkout repository
49-
uses: actions/checkout@v4
49+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
5050

5151
# Initializes the CodeQL tools for scanning.
5252
- name: Initialize CodeQL
@@ -64,7 +64,7 @@ jobs:
6464
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
6565
# If this step fails, then you should remove it and run the build manually (see below)
6666
- name: Autobuild
67-
uses: github/codeql-action/autobuild@v2
67+
uses: github/codeql-action/autobuild@49abf0ba24d0b7953cb586944e918a0b92074c80 # v2
6868

6969
# ℹ️ Command-line programs to run using the OS shell.
7070
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -77,6 +77,6 @@ jobs:
7777
# ./location_of_script_within_repo/buildscript.sh
7878

7979
- name: Perform CodeQL Analysis
80-
uses: github/codeql-action/analyze@v2
80+
uses: github/codeql-action/analyze@49abf0ba24d0b7953cb586944e918a0b92074c80 # v2
8181
with:
8282
category: "/language:${{matrix.language}}"

.github/workflows/scorecards.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Scorecard analysis workflow
2+
on:
3+
# Only the default branch is supported.
4+
branch_protection_rule:
5+
push:
6+
branches: [ main ]
7+
8+
# Declare default permissions as read only.
9+
permissions: read-all
10+
11+
jobs:
12+
analysis:
13+
name: Scorecard analysis
14+
runs-on: ubuntu-latest
15+
permissions:
16+
# Needed if using Code scanning alerts
17+
security-events: write
18+
# Needed for GitHub OIDC token if publish_results is true
19+
id-token: write
20+
21+
steps:
22+
- name: "Checkout code"
23+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
24+
with:
25+
persist-credentials: false
26+
27+
- name: "Run analysis"
28+
uses: ossf/scorecard-action@80e868c13c90f172d68d1f4501dee99e2479f7af # v2.1.3
29+
with:
30+
results_file: results.sarif
31+
results_format: sarif
32+
# (Optional) fine-grained personal access token. Uncomment the `repo_token` line below if:
33+
# - you want to enable the Branch-Protection check on a *public* repository, or
34+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-fine-grained-pat-optional.
35+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
36+
37+
# Publish the results for public repositories to enable scorecard badges. For more details, see
38+
# https://github.com/ossf/scorecard-action#publishing-results.
39+
# For private repositories, `publish_results` will automatically be set to `false`, regardless
40+
# of the value entered here.
41+
publish_results: true
42+
43+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
44+
# format to the repository Actions tab.
45+
- name: "Upload artifact"
46+
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
47+
with:
48+
name: SARIF file
49+
path: results.sarif
50+
retention-days: 5
51+
52+
# required for Code scanning alerts
53+
- name: "Upload SARIF results to code scanning"
54+
uses: github/codeql-action/upload-sarif@83f0fe6c4988d98a455712a27f0255212bba9bd4 # v2.3.6
55+
with:
56+
sarif_file: results.sarif

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,28 @@
22

33
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=141451032&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdevcontainer.json&location=EastUs)
44

5+
**Builds**
6+
57
[![Main pipeline](https://github.com/testcontainers/testcontainers-go/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/testcontainers/testcontainers-go/actions/workflows/ci.yml)
6-
[![Go Report Card](https://goreportcard.com/badge/github.com/testcontainers/testcontainers-go)](https://goreportcard.com/report/github.com/testcontainers/testcontainers-go)
8+
9+
**Documentation**
10+
711
[![GoDoc Reference](https://camo.githubusercontent.com/8609cfcb531fa0f5598a3d4353596fae9336cce3/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f79616e6777656e6d61692f686f772d746f2d6164642d62616467652d696e2d6769746875622d726561646d653f7374617475732e737667)](https://pkg.go.dev/github.com/testcontainers/testcontainers-go)
812

13+
**Social**
14+
15+
[![Slack](https://img.shields.io/badge/Slack-4A154B?logo=slack)](https://testcontainers.slack.com/)
16+
17+
**Code quality**
18+
19+
[![Go Report Card](https://goreportcard.com/badge/github.com/testcontainers/testcontainers-go)](https://goreportcard.com/report/github.com/testcontainers/testcontainers-go)
20+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=testcontainers_testcontainers-go&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=testcontainers_testcontainers-go)
21+
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/testcontainers/testcontainers-go/badge)](https://api.securityscorecards.dev/projects/github.com/testcontainers/testcontainers-go)
22+
23+
**License**
24+
25+
[![License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/testcontainers/testcontainers-go/blob/main/LICENSE)
26+
927
_Testcontainers for Go_ is a Go package that makes it simple to create and clean up container-based dependencies for
1028
automated integration/smoke tests. The clean, easy-to-use API enables developers to programmatically define containers
1129
that should be run as part of a test and clean up those resources when the test is done.

0 commit comments

Comments
 (0)