Skip to content

Commit 9ac4afc

Browse files
fabriziosalmiclaude
andcommitted
fix: comprehensive audit — 20 issues across all components
Backend (Go): - Remove dead `decode()` function from helpers.go - Replace HasPrefix+slice with strings.TrimPrefix in db.go - Fix unchecked fmt.Sscanf returns with strconv.Atoi - Explicitly discard tx.Rollback() and SetReadDeadline() errors WAF (Go): - Add error handling for os.MkdirAll, json.Encode, w.Write - Remove unused ftpSig variable from heuristics.go - Explicitly discard os.Rename return Frontend: - Move CopyBtn and Btn components to module scope (react-hooks/static-components) - Fix setState-in-effect in GlobalSearch.tsx - Fix unused catch variables and let→const in Blacklists/Settings - Fix Dashboard.test.tsx: skeleton class + mock useAnimatedNumber - Fix npm vulnerabilities (axios SSRF, vite path traversal) Infrastructure: - Fix docker-compose.test.yml: update stale ./backend → ./backend-go - Secure proxy startup.sh: add safe_source() to validate /config files - Sanitize GUI_IP_WHITELIST before sed interpolation CI/Docs: - Pin actions/checkout SHA in docs.yml and multi-arch.yml - Change npm install → npm ci in docs.yml - Remove invalid G704 gosec exclusion from ci.yml - Add INTEGRATION_ARCHITECTURE.md to docs sidebar - Fix cron→bash code block language in blacklists.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d0fc174 commit 9ac4afc

24 files changed

Lines changed: 239 additions & 176 deletions

File tree

.claude/launch.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": "0.0.1",
3+
"configurations": [
4+
{
5+
"name": "docs",
6+
"runtimeExecutable": "npx",
7+
"runtimeArgs": ["vitepress", "dev", "docs"],
8+
"port": 5173
9+
}
10+
]
11+
}

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107

108108
- name: Run gosec on waf-go
109109
working-directory: waf-go
110-
run: gosec -severity medium -confidence medium -exclude=G104,G114,G301,G302,G304,G704 ./...
110+
run: gosec -severity medium -confidence medium -exclude=G104,G114,G301,G302,G304 ./...
111111

112112
- name: npm audit (UI)
113113
working-directory: ui

.github/workflows/docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ jobs:
2323
runs-on: ubuntu-latest
2424
steps:
2525
- name: Checkout
26-
uses: actions/checkout@v4
26+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
2727

2828
- name: Setup Node.js
29-
uses: actions/setup-node@v4
29+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
3030
with:
3131
node-version: 20
3232
cache: npm
3333
cache-dependency-path: docs/package-lock.json
3434

3535
- name: Install dependencies
36-
run: npm install
36+
run: npm ci
3737
working-directory: docs
3838

3939
- name: Build VitePress

.github/workflows/multi-arch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
dockerfile: ./dns/Dockerfile
3737

3838
steps:
39-
- uses: actions/checkout@v4
39+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
4040

4141
- name: Set up QEMU (for ARM64 emulation)
4242
uses: docker/setup-qemu-action@v3

backend-go/internal/database/db.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,7 @@ func writeDnsmasqBlocklist(db *sql.DB, path string, exclusions map[string]struct
329329
var domain string
330330
if rows.Scan(&domain) == nil && domain != "" {
331331
if _, excluded := exclusions[domain]; !excluded {
332-
d := domain
333-
if strings.HasPrefix(d, "*.") {
334-
d = d[2:]
335-
}
332+
d := strings.TrimPrefix(domain, "*.")
336333
entries = append(entries, entry{d})
337334
}
338335
}

backend-go/internal/handlers/analytics.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ func parseDuration(s string) time.Duration {
203203
return 24 * time.Hour
204204
}
205205
n := 1
206-
fmt.Sscanf(parts[0], "%d", &n)
206+
if v, err := strconv.Atoi(parts[0]); err == nil {
207+
n = v
208+
}
207209
if n < 1 {
208210
n = 1
209211
}

backend-go/internal/handlers/blacklists.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ func (h *BlacklistHandlers) Import(w http.ResponseWriter, r *http.Request) {
406406
}
407407
stmt, err := tx.Prepare(fmt.Sprintf("INSERT OR IGNORE INTO %s (%s, description) VALUES(?,?)", table, col))
408408
if err != nil {
409-
tx.Rollback()
409+
_ = tx.Rollback()
410410
log.Error().Err(err).Msg("batch insert prepare failed")
411411
break
412412
}
@@ -415,7 +415,7 @@ func (h *BlacklistHandlers) Import(w http.ResponseWriter, r *http.Request) {
415415
}
416416
stmt.Close()
417417
if err := tx.Commit(); err != nil {
418-
tx.Rollback()
418+
_ = tx.Rollback()
419419
log.Error().Err(err).Msg("batch insert commit failed")
420420
}
421421
}

backend-go/internal/handlers/helpers.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ func writeOK(w http.ResponseWriter, data any) {
3232
writeJSON(w, http.StatusOK, map[string]any{"status": "success", "data": data})
3333
}
3434

35-
// decode reads and JSON-decodes the request body into dst.
36-
func decode(r *http.Request, dst any) error {
37-
r.Body = http.MaxBytesReader(nil, r.Body, 55*1024*1024)
38-
return json.NewDecoder(r.Body).Decode(dst)
39-
}
40-
4135
// isValidCIDR returns true if s is a valid IP address or CIDR prefix.
4236
func isValidCIDR(s string) bool {
4337
if _, err := netip.ParsePrefix(s); err == nil {

backend-go/internal/websocket/hub.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ func (c *Client) writePump() {
9393
// readPump reads pings/pongs and detects disconnects.
9494
func (c *Client) readPump() {
9595
defer c.hub.Unregister(c)
96-
c.conn.SetReadDeadline(time.Now().Add(90 * time.Second))
96+
_ = c.conn.SetReadDeadline(time.Now().Add(90 * time.Second))
9797
c.conn.SetPongHandler(func(string) error {
98-
c.conn.SetReadDeadline(time.Now().Add(90 * time.Second))
98+
_ = c.conn.SetReadDeadline(time.Now().Add(90 * time.Second))
9999
return nil
100100
})
101101
for {

backend-go/internal/workers/update_checker.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package workers
33
import (
44
"context"
55
"encoding/json"
6-
"fmt"
76
"net/http"
7+
"strconv"
88
"strings"
99
"sync"
1010
"time"
@@ -73,10 +73,10 @@ func semverGreater(a, b string) bool {
7373
for i := 0; i < len(aParts) || i < len(bParts); i++ {
7474
var av, bv int
7575
if i < len(aParts) {
76-
fmt.Sscanf(aParts[i], "%d", &av)
76+
av, _ = strconv.Atoi(aParts[i])
7777
}
7878
if i < len(bParts) {
79-
fmt.Sscanf(bParts[i], "%d", &bv)
79+
bv, _ = strconv.Atoi(bParts[i])
8080
}
8181
if av > bv {
8282
return true

0 commit comments

Comments
 (0)