Skip to content

Commit ab13c1a

Browse files
authored
Merge pull request #92 from step-security-bot/chore/GHA-211746-stepsecurity-remediation
[StepSecurity] Apply security best practices
2 parents aa9bf49 + 4e3271b commit ab13c1a

6 files changed

Lines changed: 138 additions & 19 deletions

File tree

.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@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
45+
with:
46+
egress-policy: audit
47+
48+
- name: Checkout repository
49+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
50+
51+
# Initializes the CodeQL tools for scanning.
52+
- name: Initialize CodeQL
53+
uses: github/codeql-action/init@45580472a5bb82c4681c4ac726cfdb60060c2ee1 # v3.32.4
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@45580472a5bb82c4681c4ac726cfdb60060c2ee1 # v3.32.4
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@45580472a5bb82c4681c4ac726cfdb60060c2ee1 # v3.32.4
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@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
21+
with:
22+
egress-policy: audit
23+
24+
- name: 'Checkout Repository'
25+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
26+
- name: 'Dependency Review'
27+
uses: actions/dependency-review-action@05fe4576374b728f0c523d6a13d64c25081e0803 # v4.8.3

.github/workflows/docker-image-release.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ jobs:
1717

1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@v6
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2121

2222
- name: Run Gosec Security Scanner
23-
uses: securego/gosec@master
23+
uses: securego/gosec@f3e2fac4d58b7eca54307cd40ce2a836a12e4d95 # master
2424
with:
2525
args: ./...
2626

2727
- name: Set up Go
28-
uses: actions/setup-go@v6
28+
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
2929
with:
3030
go-version: '1.25'
3131

@@ -37,28 +37,28 @@ jobs:
3737
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
3838

3939
- name: Install Cosign
40-
uses: sigstore/cosign-installer@v4.0.0
40+
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
4141
with:
4242
cosign-release: 'v2.6.1'
4343

4444
- name: Set up Docker Buildx
45-
uses: docker/setup-buildx-action@v3
45+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
4646

4747
- name: Login to Docker Hub
48-
uses: docker/login-action@v3
48+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
4949
with:
5050
username: ${{ secrets.DOCKERHUB_USERNAME }}
5151
password: ${{ secrets.DOCKERHUB_TOKEN }}
5252

5353
- name: Login to GitHub Container Registry
54-
uses: docker/login-action@v3
54+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
5555
with:
5656
registry: ghcr.io
5757
username: ${{ github.actor }}
5858
password: ${{ secrets.GITHUB_TOKEN }}
5959

6060
- name: Build and push Docker Hub image
61-
uses: docker/build-push-action@v6
61+
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
6262
id: push-dockerhub
6363
with:
6464
context: .
@@ -76,7 +76,7 @@ jobs:
7676
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
7777

7878
- name: Build and push GHCR image
79-
uses: docker/build-push-action@v6
79+
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
8080
id: push-ghcr
8181
with:
8282
context: .

.github/workflows/docker-image-testing.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ jobs:
1919

2020
steps:
2121
- name: Checkout
22-
uses: actions/checkout@v6
22+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2323

2424
- name: Run Gosec Security Scanner
25-
uses: securego/gosec@master
25+
uses: securego/gosec@f3e2fac4d58b7eca54307cd40ce2a836a12e4d95 # master
2626
with:
2727
args: ./...
2828

2929
- name: Set up Go
30-
uses: actions/setup-go@v6
30+
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
3131
with:
3232
go-version: '1.25'
3333

@@ -40,23 +40,23 @@ jobs:
4040
# cosign-release: 'v2.6.0'
4141

4242
- name: Set up Docker Buildx
43-
uses: docker/setup-buildx-action@v3
43+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
4444

4545
- name: Login to Docker Hub
46-
uses: docker/login-action@v3
46+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
4747
with:
4848
username: ${{ secrets.DOCKERHUB_USERNAME }}
4949
password: ${{ secrets.DOCKERHUB_TOKEN }}
5050

5151
- name: Login to GitHub Container Registry
52-
uses: docker/login-action@v3
52+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
5353
with:
5454
registry: ghcr.io
5555
username: ${{ github.actor }}
5656
password: ${{ secrets.GITHUB_TOKEN }}
5757

5858
- name: Build and push image to Docker Hub and GHCR
59-
uses: docker/build-push-action@v6
59+
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
6060
id: push-all
6161
with:
6262
context: .
@@ -70,7 +70,7 @@ jobs:
7070
ghcr.io/wollomatic/socket-proxy:testing-${{ github.sha }}
7171
7272
# - name: Build and push Docker Hub image
73-
# uses: docker/build-push-action@v6
73+
# uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
7474
# id: push-dockerhub
7575
# with:
7676
# context: .
@@ -88,7 +88,7 @@ jobs:
8888
# COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
8989
#
9090
# - name: Build and push GHCR image
91-
# uses: docker/build-push-action@v6
91+
# uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
9292
# id: push-ghcr
9393
# with:
9494
# context: .

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repos:
2+
- repo: https://github.com/gitleaks/gitleaks
3+
rev: v8.16.3
4+
hooks:
5+
- id: gitleaks
6+
- repo: https://github.com/golangci/golangci-lint
7+
rev: v1.52.2
8+
hooks:
9+
- id: golangci-lint
10+
- repo: https://github.com/pre-commit/pre-commit-hooks
11+
rev: v4.4.0
12+
hooks:
13+
- id: end-of-file-fixer
14+
- id: trailing-whitespace

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# syntax=docker/dockerfile:1
2-
FROM --platform=$BUILDPLATFORM golang:1.26.0-alpine3.23 AS build
2+
FROM --platform=$BUILDPLATFORM golang:1.26.0-alpine3.23@sha256:d4c4845f5d60c6a974c6000ce58ae079328d03ab7f721a0734277e69905473e5 AS build
33
WORKDIR /application
44
COPY . ./
55
ARG TARGETOS

0 commit comments

Comments
 (0)