Skip to content

Commit 53bc446

Browse files
committed
fix: pre-commit
Signed-off-by: Julio Jimenez <julio@clickhouse.com>
1 parent 5cbfff3 commit 53bc446

36 files changed

Lines changed: 2490 additions & 7659 deletions

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ updates:
88
directory: "/"
99
schedule:
1010
interval: "weekly"
11+
- package-ecosystem: "gomod"
12+
directory: "/"
13+
schedule:
14+
interval: "weekly"

.github/workflows/docker-security.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
docker_security_scan:
1212
name: 🔍 Container Security Scan
1313
runs-on: ubuntu-latest
14-
14+
1515
permissions:
1616
contents: read
1717
security-events: write
@@ -53,23 +53,23 @@ jobs:
5353
echo "# 🐳 Container Security Report" > security-report.md
5454
echo "Generated on: $(date)" >> security-report.md
5555
echo "" >> security-report.md
56-
56+
5757
# Trivy Results Summary
5858
echo "## 🛡️ Trivy Scan Results" >> security-report.md
5959
if [ -f "trivy-results.json" ]; then
6060
CRITICAL=$(jq '[.Results[]?.Vulnerabilities[]? | select(.Severity == "CRITICAL")] | length' trivy-results.json 2>/dev/null || echo "0")
6161
HIGH=$(jq '[.Results[]?.Vulnerabilities[]? | select(.Severity == "HIGH")] | length' trivy-results.json 2>/dev/null || echo "0")
6262
MEDIUM=$(jq '[.Results[]?.Vulnerabilities[]? | select(.Severity == "MEDIUM")] | length' trivy-results.json 2>/dev/null || echo "0")
6363
LOW=$(jq '[.Results[]?.Vulnerabilities[]? | select(.Severity == "LOW")] | length' trivy-results.json 2>/dev/null || echo "0")
64-
64+
6565
echo "- 🔴 Critical: $CRITICAL" >> security-report.md
6666
echo "- 🟠 High: $HIGH" >> security-report.md
6767
echo "- 🟡 Medium: $MEDIUM" >> security-report.md
6868
echo "- 🟢 Low: $LOW" >> security-report.md
6969
else
7070
echo "- No Trivy results found" >> security-report.md
7171
fi
72-
72+
7373
echo "" >> security-report.md
7474
echo "## 📋 Recommendations" >> security-report.md
7575
echo "1. Review critical and high severity vulnerabilities" >> security-report.md
@@ -93,7 +93,7 @@ jobs:
9393
if [ -f "trivy-results.json" ]; then
9494
CRITICAL=$(jq '[.Results[]?.Vulnerabilities[]? | select(.Severity == "CRITICAL")] | length' trivy-results.json 2>/dev/null || echo "0")
9595
echo "Critical vulnerabilities found: $CRITICAL"
96-
96+
9797
if [ "$CRITICAL" -gt 0 ]; then
9898
echo "::error::Found $CRITICAL critical vulnerabilities in the container image"
9999
echo "::error::Please review and fix critical vulnerabilities before deploying"
@@ -110,7 +110,7 @@ jobs:
110110

111111
name: 🐋 Dockerfile Security Scan
112112
runs-on: ubuntu-latest
113-
113+
114114
steps:
115115
- name: 🧾 Checkout
116116
uses: actions/checkout@v5
@@ -164,7 +164,7 @@ jobs:
164164
name: 📋 Generate Container SBOM
165165
runs-on: ubuntu-latest
166166
needs: docker_security_scan
167-
167+
168168
steps:
169169
- name: 🧾 Checkout
170170
uses: actions/checkout@v5
@@ -184,7 +184,7 @@ jobs:
184184
run: |
185185
# Install Docker Scout CLI
186186
curl -sSfL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh | sh -s --
187-
187+
188188
# Generate SBOM
189189
docker scout sbom clickbom:latest --format spdx --output container-sbom-scout.spdx.json || echo "Docker Scout SBOM generation failed"
190190
@@ -202,7 +202,7 @@ jobs:
202202
runs-on: ubuntu-latest
203203
needs: [docker_security_scan, dockerfile_security_scan, container_sbom]
204204
if: always()
205-
205+
206206
steps:
207207
- name: 📥 Download Security Artifacts
208208
uses: actions/download-artifact@v5
@@ -221,29 +221,29 @@ jobs:
221221
echo "# 🔒 ClickBOM Container Security Summary" >> $GITHUB_STEP_SUMMARY
222222
echo "**Scan Date:** $(date)" >> $GITHUB_STEP_SUMMARY
223223
echo "" >> $GITHUB_STEP_SUMMARY
224-
224+
225225
if [ -f "security-results/trivy-results.json" ]; then
226226
echo "## 🛡️ Vulnerability Scan Results" >> $GITHUB_STEP_SUMMARY
227227
CRITICAL=$(jq '[.Results[]?.Vulnerabilities[]? | select(.Severity == "CRITICAL")] | length' security-results/trivy-results.json 2>/dev/null || echo "0")
228228
HIGH=$(jq '[.Results[]?.Vulnerabilities[]? | select(.Severity == "HIGH")] | length' security-results/trivy-results.json 2>/dev/null || echo "0")
229229
MEDIUM=$(jq '[.Results[]?.Vulnerabilities[]? | select(.Severity == "MEDIUM")] | length' security-results/trivy-results.json 2>/dev/null || echo "0")
230230
LOW=$(jq '[.Results[]?.Vulnerabilities[]? | select(.Severity == "LOW")] | length' security-results/trivy-results.json 2>/dev/null || echo "0")
231-
231+
232232
echo "| Severity | Count |" >> $GITHUB_STEP_SUMMARY
233233
echo "|----------|-------|" >> $GITHUB_STEP_SUMMARY
234234
echo "| 🔴 Critical | $CRITICAL |" >> $GITHUB_STEP_SUMMARY
235235
echo "| 🟠 High | $HIGH |" >> $GITHUB_STEP_SUMMARY
236236
echo "| 🟡 Medium | $MEDIUM |" >> $GITHUB_STEP_SUMMARY
237237
echo "| 🟢 Low | $LOW |" >> $GITHUB_STEP_SUMMARY
238238
echo "" >> $GITHUB_STEP_SUMMARY
239-
239+
240240
if [ "$CRITICAL" -gt 0 ] || [ "$HIGH" -gt 0 ]; then
241241
echo "⚠️ **Action Required:** Critical or High severity vulnerabilities found!" >> $GITHUB_STEP_SUMMARY
242242
else
243243
echo "✅ **Good News:** No critical or high severity vulnerabilities found!" >> $GITHUB_STEP_SUMMARY
244244
fi
245245
fi
246-
246+
247247
echo "" >> $GITHUB_STEP_SUMMARY
248248
echo "## 📋 Artifacts Generated" >> $GITHUB_STEP_SUMMARY
249249
echo "- Container vulnerability scan results (SARIF format)" >> $GITHUB_STEP_SUMMARY

.github/workflows/tests.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
test_unit:
77
name: 🧪 Unit Tests
88
runs-on: ubuntu-latest
9-
9+
1010
steps:
1111
- name: 🧾 Checkout
1212
uses: actions/checkout@v5
@@ -34,7 +34,7 @@ jobs:
3434
test_integration:
3535
name: 🔗 Integration Tests
3636
runs-on: ubuntu-latest
37-
37+
3838
services:
3939
# Mock S3 using LocalStack
4040
localstack:
@@ -105,7 +105,7 @@ jobs:
105105
test_lint:
106106
name: 🔍 Lint & Format
107107
runs-on: ubuntu-latest
108-
108+
109109
steps:
110110
- name: 🧾 Checkout
111111
uses: actions/checkout@v5
@@ -151,7 +151,7 @@ jobs:
151151
exclude:
152152
- goos: windows
153153
goarch: arm64
154-
154+
155155
steps:
156156
- name: 🧾 Checkout
157157
uses: actions/checkout@v5
@@ -178,7 +178,7 @@ jobs:
178178
test_docker:
179179
name: 🐳 Docker Build
180180
runs-on: ubuntu-latest
181-
181+
182182
steps:
183183
- name: 🧾 Checkout
184184
uses: actions/checkout@v5
@@ -209,7 +209,7 @@ jobs:
209209
name: 🎯 E2E Tests
210210
runs-on: ubuntu-latest
211211
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
212-
212+
213213
steps:
214214
- name: 🧾 Checkout
215215
uses: actions/checkout@v5
@@ -249,7 +249,7 @@ jobs:
249249
name: ⚡ Benchmarks
250250
runs-on: ubuntu-latest
251251
if: github.event_name == 'push'
252-
252+
253253
steps:
254254
- name: 🧾 Checkout
255255
uses: actions/checkout@v5
@@ -275,7 +275,7 @@ jobs:
275275
test_security:
276276
name: 🔒 Security Scan
277277
runs-on: ubuntu-latest
278-
278+
279279
steps:
280280
- name: 🧾 Checkout
281281
uses: actions/checkout@v5
@@ -302,4 +302,4 @@ jobs:
302302
- name: 🔍 Run govulncheck
303303
run: |
304304
go install golang.org/x/vuln/cmd/govulncheck@latest
305-
govulncheck ./...
305+
govulncheck ./...

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.DS_Store
1+
.DS_Store

.golangci.yml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,26 @@ version: "2"
22
linters:
33
enable:
44
- errcheck
5-
- gosimple
65
- govet
76
- ineffassign
87
- staticcheck
98
- unused
10-
- gofmt
11-
- goimports
129
- misspell
1310
- unconvert
1411
- unparam
1512
- goconst
1613
- gocyclo
1714
- gosec
1815
- revive
19-
20-
linters-settings:
21-
errcheck:
22-
check-type-assertions: true
23-
check-blank: true
24-
25-
govet:
26-
check-shadowing: true
27-
28-
gocyclo:
29-
min-complexity: 15
30-
31-
gosec:
32-
excludes:
33-
- G304 # File path provided as taint input
16+
settings:
17+
gosec:
18+
severity: high
19+
confidence: high
3420

3521
run:
3622
timeout: 5m
3723
tests: true
3824

3925
issues:
40-
exclude-use-default: false
4126
max-issues-per-linter: 0
4227
max-same-issues: 0

.pre-commit-config.yaml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
# General file checks
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v6.0.0
7+
hooks:
8+
- id: trailing-whitespace
9+
args: [--markdown-linebreak-ext=md]
10+
- id: end-of-file-fixer
11+
- id: check-yaml
12+
args: [--unsafe] # Allow custom YAML tags
13+
- id: check-json
14+
- id: check-toml
15+
- id: check-added-large-files
16+
args: [--maxkb=1000]
17+
- id: check-case-conflict
18+
- id: check-merge-conflict
19+
- id: detect-private-key
20+
- id: mixed-line-ending
21+
- id: no-commit-to-branch
22+
args: [--branch, main, --branch, master]
23+
24+
# Go formatting
25+
- repo: https://github.com/dnephin/pre-commit-golang
26+
rev: v0.5.1
27+
hooks:
28+
- id: go-fmt
29+
name: Format Go code with gofmt
30+
description: Runs `gofmt -s -w` on all Go files
31+
32+
- id: go-imports
33+
name: Format Go imports with goimports
34+
description: Runs `goimports -w` on all Go files
35+
args: [-local, github.com/ClickHouse/ClickBOM]
36+
37+
- id: go-unit-tests
38+
name: Go unit tests
39+
description: Runs `go test` on all packages
40+
args: [-short, -race]
41+
42+
- id: go-build
43+
name: Go build
44+
description: Runs `go build` to ensure code compiles
45+
46+
- id: go-mod-tidy
47+
name: Tidy Go modules
48+
description: Runs `go mod tidy` to clean up go.mod and go.sum
49+
50+
# Additional Go checks
51+
- repo: local
52+
hooks:
53+
- id: go-no-replacement
54+
name: Check for replace directives in go.mod
55+
entry: "bash -c 'if grep -q \"^replace \" go.mod; then echo \"Error: go.mod contains replace directives\"; exit 1; fi'"
56+
language: system
57+
files: go\.mod$
58+
59+
- id: go-critic
60+
name: Go critic
61+
entry: gocritic check ./...
62+
language: system
63+
pass_filenames: false
64+
files: \.go$
65+
66+
- id: go-cyclo
67+
name: Check cyclomatic complexity
68+
entry: gocyclo -over 25 .
69+
language: system
70+
pass_filenames: false
71+
files: \.go$
72+
73+
- id: golangci-lint
74+
name: golangci-lint
75+
entry: golangci-lint run --fix
76+
language: system
77+
pass_filenames: false
78+
files: \.go$
79+
80+
# YAML linting
81+
- repo: https://github.com/adrienverge/yamllint
82+
rev: v1.37.1
83+
hooks:
84+
- id: yamllint
85+
args: [-d, relaxed]
86+
87+
# Dockerfile linting
88+
- repo: https://github.com/hadolint/hadolint
89+
rev: v2.14.0
90+
hooks:
91+
- id: hadolint-docker
92+
args: [--ignore, DL3018] # Ignore pinning versions in apk add
93+
94+
# Commit message linting
95+
- repo: https://github.com/compilerla/conventional-pre-commit
96+
rev: v4.3.0
97+
hooks:
98+
- id: conventional-pre-commit
99+
stages: [commit-msg]

0 commit comments

Comments
 (0)