Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 40 additions & 17 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,41 @@ on:
branches:
- master

# Declare default permissions as read only.
# Declare default permissions as read-only.
permissions: read-all

jobs:
GolangCI:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b # v2.15.0
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1

- name: Run golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: latest
args: --timeout=5m --output.sarif.path=golangci-lint-results.sarif --output.text.path=stdout

- name: Upload golangci-lint results to GitHub Security tab
uses: github/codeql-action/upload-sarif@c793b717bc78562f491db7b0e93a3a178b099162 # v4.32.5
with:
sarif_file: golangci-lint-results.sarif

TrivyCode:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Harden Runner
Expand All @@ -28,14 +56,14 @@ jobs:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@e368e328979b113139d6f9068e03accaed98a518 # 0.34.1
- name: Run Trivy vulnerability scanner in fs mode
uses: aquasecurity/trivy-action@97e0b3872f55f89b95b2f65b3dbab56962816478 # 0.34.2
with:
scan-type: 'fs'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL'
severity: 'CRITICAL,HIGH'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@c793b717bc78562f491db7b0e93a3a178b099162 # v4.32.5
Expand All @@ -46,43 +74,38 @@ jobs:
strategy:
matrix:
go-version:
- stable
- "stable"
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b # v2.15.0
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1

- name: VulnerabilityCheck
- name: Vulnerability Check
uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # v1.0.4
with:
repo-checkout: false
go-version-input: ${{matrix.go-version}}
output-format: sarif
output-file: govulncheck-results.sarif

- name: PrintSarif
id: PrintSarif
- name: Print Sarif
id: printSarif
run: |
cat govulncheck-results.sarif

if grep "'results'" govulncheck-results.sarif
if grep results govulncheck-results.sarif
then
echo "hasResults=true" >> $GITHUB_OUTPUT
else
echo "hasResults=false" >> $GITHUB_OUTPUT
fi

- name: Upload govolncheck results to GitHub Security tab
if: ${{ steps.PrintSarif.outputs.hasResults == 'true' }}
- name: Upload govulncheck results to Security tab
if: ${{ steps.printSarif.outputs.hasResults == 'true' }}
uses: github/codeql-action/upload-sarif@c793b717bc78562f491db7b0e93a3a178b099162 # v4.32.5
with:
sarif_file: govulncheck-results.sarif
2 changes: 1 addition & 1 deletion example/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestExampleMain(t *testing.T) {

req.Header.Add("Origin", "localhost")

res, resErr := http.DefaultClient.Do(req)
res, resErr := http.DefaultClient.Do(req) //nolint:gosec // all inputs are fixed, this is a test

if resErr != nil {
t.Errorf("got error for hello test page: %v", resErr)
Expand Down
2 changes: 1 addition & 1 deletion handler/basicauth/basic_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestBasicAuth(t *testing.T) {

tests := []struct {
User string
Pass string
Pass string //nolint:gosec
WantState int
}{
{
Expand Down
2 changes: 1 addition & 1 deletion handler/basicauth/htpasswdauth/htpasswd_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestHtpasswdAuth(t *testing.T) {

tests := []struct {
Username string
Password string
Password string //nolint:gosec
Valid bool
}{
{
Expand Down
6 changes: 3 additions & 3 deletions handler/basicauth/mapauth/map_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// Package mapauth implements the basic auth functionality using a user-pass-map.
package mapauth

import "maps"

import "errors"

// ErrNoAuthorizations is returned when no authorizations are configured.
Expand Down Expand Up @@ -46,9 +48,7 @@ func WithAuths(auths map[string]string) func(a *MapAuthenticator) error {
a.auths = make(map[string]string, len(auths))
}

for k, v := range auths {
a.auths[k] = v
}
maps.Copy(a.auths, auths)

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion handler/basicauth/mapauth/map_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestMapAuthenticator(t *testing.T) {
tests := []struct {
Auths map[string]string
User string
Pass string
Pass string //nolint:gosec
WantNewErr bool
Want bool
WantError bool
Expand Down
Loading