Skip to content

Commit e2af8d5

Browse files
mhmxsRichard Kovacs
and
Richard Kovacs
authored
Introduce static code analysis (#50)
* Introduce static code analysis * Replace named returns where possible * Allow storage.googleapis.com for nilcheck --------- Co-authored-by: Richard Kovacs <[email protected]>
1 parent 7a4b2e5 commit e2af8d5

File tree

13 files changed

+591
-109
lines changed

13 files changed

+591
-109
lines changed

.github/workflows/build_test_ci.yml

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,31 @@ on:
66
pull_request:
77
branches: [ "main" ]
88

9-
jobs:
9+
permissions:
10+
contents: read
11+
pull-requests: read
12+
actions: read
13+
14+
concurrency:
15+
group: build-test-ci-${{ github.ref }}-1
16+
cancel-in-progress: true
1017

18+
jobs:
1119
go-build-test:
1220
runs-on: ubuntu-latest
1321
steps:
22+
- name: Harden Runner
23+
uses: step-security/harden-runner@v2
24+
with:
25+
disable-sudo: true
26+
egress-policy: block
27+
allowed-endpoints: >
28+
api.github.com:443
29+
github.com:443
30+
proxy.golang.org:443
31+
sum.golang.org:443
32+
objects.githubusercontent.com:443
33+
1434
- uses: actions/checkout@v4
1535

1636
- name: Set up Go
@@ -24,9 +44,77 @@ jobs:
2444
- name: Test
2545
run: make test
2646

47+
go-analyse:
48+
needs: go-build-test
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Harden Runner
52+
uses: step-security/harden-runner@v2
53+
with:
54+
disable-sudo: true
55+
egress-policy: block
56+
allowed-endpoints: >
57+
api.github.com:443
58+
github.com:443
59+
proxy.golang.org:443
60+
sum.golang.org:443
61+
objects.githubusercontent.com:443
62+
registry-1.docker.io:443
63+
auth.docker.io:443
64+
production.cloudflare.docker.com:443
65+
vuln.go.dev:443
66+
storage.googleapis.com:443
67+
68+
- uses: actions/checkout@v4
69+
70+
- name: Set up Go
71+
uses: actions/setup-go@v5
72+
with:
73+
go-version: 'stable'
74+
75+
- name: Docker cache
76+
uses: ScribeMD/[email protected]
77+
with:
78+
key: docker-${{ runner.os }}-${{ hashFiles('Makefile') }}}
79+
80+
- name: Lint
81+
run: make lint
82+
83+
- name: Gosec
84+
run: make gosec
85+
86+
- name: Vulncheck
87+
run: make vulncheck
88+
89+
- name: Nilcheck
90+
run: make nilcheck
91+
2792
docker-build:
2893
runs-on: ubuntu-latest
2994
steps:
95+
- name: Harden Runner
96+
uses: step-security/harden-runner@v2
97+
with:
98+
disable-sudo: true
99+
egress-policy: block
100+
allowed-endpoints: >
101+
api.github.com:443
102+
github.com:443
103+
proxy.golang.org:443
104+
sum.golang.org:443
105+
objects.githubusercontent.com:443
106+
registry-1.docker.io:443
107+
auth.docker.io:443
108+
production.cloudflare.docker.com:443
109+
gcr.io:443
110+
storage.googleapis.com:443
111+
30112
- uses: actions/checkout@v4
113+
114+
- name: Docker cache
115+
uses: ScribeMD/[email protected]
116+
with:
117+
key: docker-${{ runner.os }}-${{ hashFiles('Dockerfile') }}
118+
31119
- name: Build the Docker image
32120
run: make docker-build

.github/workflows/codeql.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
# The branches below must be a subset of the branches above
8+
branches: [ "main" ]
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: codeql-${{ github.ref }}-1
15+
cancel-in-progress: true
16+
17+
jobs:
18+
analyze:
19+
name: Analyze
20+
runs-on: ubuntu-latest
21+
permissions:
22+
actions: read
23+
contents: read
24+
security-events: write
25+
26+
strategy:
27+
fail-fast: false
28+
29+
steps:
30+
- name: Harden Runner
31+
uses: step-security/harden-runner@v2
32+
with:
33+
disable-sudo: true
34+
egress-policy: block
35+
allowed-endpoints: >
36+
api.github.com:443
37+
github.com:443
38+
proxy.golang.org:443
39+
sum.golang.org:443
40+
objects.githubusercontent.com:443
41+
42+
- name: Checkout repository
43+
uses: actions/checkout@v4
44+
45+
- name: Set up Go
46+
uses: actions/setup-go@v5
47+
with:
48+
go-version: 'stable'
49+
50+
# Initializes the CodeQL tools for scanning.
51+
- name: Initialize CodeQL
52+
uses: github/codeql-action/init@v2
53+
with:
54+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
55+
languages: go
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+
# Details on CodeQL's query packs refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
61+
# queries: security-extended,security-and-quality
62+
63+
- name: Build
64+
run: make build
65+
66+
- name: Perform CodeQL Analysis
67+
uses: github/codeql-action/analyze@v2
68+
with:
69+
category: "/language:go"

0 commit comments

Comments
 (0)