Skip to content

Commit 6db6d55

Browse files
author
Richard Kovacs
committed
Introduce static code analysis
1 parent 7a4b2e5 commit 6db6d55

File tree

13 files changed

+587
-104
lines changed

13 files changed

+587
-104
lines changed

.github/workflows/build_test_ci.yml

Lines changed: 91 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,79 @@ 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+
vuln.go.dev:443
64+
65+
- uses: actions/checkout@v4
66+
67+
- name: Set up Go
68+
uses: actions/setup-go@v5
69+
with:
70+
go-version: 'stable'
71+
72+
- name: Docker cache
73+
uses: ScribeMD/[email protected]
74+
with:
75+
key: docker-${{ runner.os }}-${{ hashFiles('Makefile') }}}
76+
77+
- name: Lint
78+
run: make lint
79+
80+
- name: Gosec
81+
run: make gosec
82+
83+
# Retry is a workaround, because sometimes nilaway randomly killed.
84+
- uses: nick-fields/retry@v2
85+
with:
86+
timeout_minutes: 5
87+
max_attempts: 3
88+
warning_on_retry: false
89+
command: make nilcheck
90+
91+
- name: Vulncheck
92+
run: make vulncheck
93+
2794
docker-build:
2895
runs-on: ubuntu-latest
2996
steps:
97+
- name: Harden Runner
98+
uses: step-security/harden-runner@v2
99+
with:
100+
disable-sudo: true
101+
egress-policy: block
102+
allowed-endpoints: >
103+
api.github.com:443
104+
github.com:443
105+
proxy.golang.org:443
106+
sum.golang.org:443
107+
objects.githubusercontent.com:443
108+
registry-1.docker.io:443
109+
auth.docker.io:443
110+
production.cloudflare.docker.com:443
111+
gcr.io:443
112+
storage.googleapis.com:443
113+
30114
- uses: actions/checkout@v4
115+
116+
- name: Docker cache
117+
uses: ScribeMD/[email protected]
118+
with:
119+
key: docker-${{ runner.os }}-${{ hashFiles('Dockerfile') }}
120+
31121
- name: Build the Docker image
32122
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)