Static safety/lint runner for the BlockNinja codebase. ~25 invariant
checks across Go and frontend sources. Was at git.dev.alexdunmow.com:block/ninja
in backend/cmd/check-safety/ until the 2026-06-06 consolidation moved
the BlockNinja repos under a shared ~/src/blockninja/ parent.
This repo is the standalone extraction:
- Own go.mod (git.dev.alexdunmow.com/block/check-safety, go 1.26.4)
- Vendored internal/{helpers,theme} from CMS (Go's internal/ rule
blocks cross-module imports; vendoring is the workaround)
- CLI contract unchanged: `check-safety <target-dir> [--flags]`
- CMS Makefile shells into ../check-safety for safety-check /
install-safety-checker targets
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
111 lines
4.9 KiB
Plaintext
111 lines
4.9 KiB
Plaintext
(running checks in FIXTURE_DIR)
|
|
|
|
=== Check 1: Secret env var reads outside config.Load() ===
|
|
FAIL: internal/service/handler.go:17 — os.Getenv("JWT_SECRET")
|
|
|
|
1 violation(s). Secrets must flow through Config → DI.
|
|
|
|
=== Check 2: RPC methods registered in RBAC interceptor ===
|
|
SKIP: no proto-backed RPC procedures found in scanned target(s)
|
|
|
|
=== Check 2b: Plugin proto ownership ===
|
|
OK: Plugin proto ownership is clean
|
|
|
|
=== Check 2c: Standalone plugin SDK import boundaries ===
|
|
FAIL: 1 CMS backend go.mod violation(s):
|
|
FIXTURE_DIR/go.mod [missing-go-mod] missing go.mod
|
|
|
|
Fix: CMS backend must not replace git.dev.alexdunmow.com/block/core locally, and standalone plugins must use git.dev.alexdunmow.com/block/core imports, require git.dev.alexdunmow.com/block/core <SDK_VERSION>, and declare no replace directives.
|
|
|
|
=== Check 2d: sqlc UUID overrides in plugins and cmd ===
|
|
SKIP: no plugin or cmd sqlc configs found
|
|
|
|
=== Check 2e: Warn on any usage in Go and TypeScript ===
|
|
OK: No any usage found in scanned Go or TypeScript sources
|
|
|
|
=== Check 2f: sqlc compile and buf generate ===
|
|
SKIP: no sqlc or buf codegen targets found
|
|
|
|
=== Check 3: Go code compiles and passes go fix, golangci-lint --fix, go vet, and strict lint ===
|
|
SKIP: . (no go.mod found)
|
|
SKIP: no Go modules found
|
|
|
|
=== Check 3b: Orchestrator backend tests ===
|
|
SKIP: orchestrator backend not found or not part of this scan
|
|
|
|
=== Check 4: Frontend auto-format, lint, and typecheck ===
|
|
SKIP: no frontend sources found
|
|
|
|
=== Check 5: Frontend uses generated ConnectRPC hooks ===
|
|
SKIP: no frontend sources found
|
|
|
|
=== Check 6: No hardcoded colors in frontend (use theme tokens) ===
|
|
OK: No hardcoded colors in .templ files
|
|
|
|
=== Check 7: No useState for tab state in routes (use URL ?tab= params) ===
|
|
SKIP: no frontend sources found
|
|
|
|
=== Check 8: Import @block-ninja/api from subpaths only ===
|
|
SKIP: no frontend sources found
|
|
|
|
=== Check 9: No npm/yarn lockfiles (pnpm only) ===
|
|
OK: Only pnpm lockfiles present
|
|
|
|
=== Check 10: Button automation attributes ===
|
|
SKIP: no frontend sources found
|
|
|
|
=== Check 10b: No eslint-disable-next-line comments ===
|
|
SKIP: no frontend sources found
|
|
|
|
=== Check 11: No placeholder code; only shipped features ===
|
|
OK: No placeholder code found
|
|
|
|
=== Check 12: No reinvented utilities (use helpers) ===
|
|
OK: No reinvented utilities detected
|
|
|
|
=== Check 13: RPC query/mutation error handling ===
|
|
SKIP: no frontend sources found
|
|
|
|
=== Check 14: No raw SQL outside sqlc/Bob ===
|
|
FAIL: 1 raw SQL statement(s) found outside sqlc/Bob:
|
|
internal/service/handler.go:22 SELECT id, name FROM users WHERE active = true
|
|
|
|
Use sqlc for static queries or Bob for dynamic queries:
|
|
┌───────────────────┬─────────────────────────────────────────────────────┐
|
|
│ Need │ Use │
|
|
├───────────────────┼─────────────────────────────────────────────────────┤
|
|
│ Static queries │ sqlc (sql/queries/*.sql → internal/db/*.go) │
|
|
│ Dynamic queries │ Bob (github.com/stephenafamo/bob) │
|
|
└───────────────────┴─────────────────────────────────────────────────────┘
|
|
Raw SQL causes bugs when schema changes. sqlc catches these at compile time.
|
|
|
|
=== Check 15: No err.Error() leaked to HTTP clients ===
|
|
FAIL: 1 err.Error() leak(s) to HTTP clients:
|
|
internal/service/handler.go:27 http.Error(w, err.Error(), ...) — leaks internal error
|
|
|
|
Fix: Log the error with slog.Error() and return a user-friendly message: http.Error(w, "failed to open repository", status)
|
|
|
|
=== Check 16: Services and handlers in correct directories ===
|
|
OK: All services and handlers in correct directories
|
|
|
|
=== Check 17: No TODO markers in production code ===
|
|
FAIL: 1 TODO marker(s) found:
|
|
internal/service/handler.go:14 // TODO: add proper initialisation
|
|
|
|
Fix: Remove TODO markers and ship explicit behavior instead of placeholders.
|
|
|
|
=== Check 18: Plugin segmentation (safety-rules.yml) ===
|
|
OK: No plugins define safety-rules.yml segmentation rules
|
|
|
|
=== Check 19: Bearer token precedence over cookies in auth middleware ===
|
|
OK: Bearer token takes precedence over cookies in all auth extraction
|
|
|
|
=== Check 20: Tailwind v4 configuration (PostCSS, CSS directives, @config) ===
|
|
SKIP: no frontend sources found
|
|
|
|
=== Check 21: Plugin presets.json validation ===
|
|
OK: No presets.json files found in scanned targets
|
|
|
|
=== Check 22: No hand-rolled HTML sanitization (use bluemonday) ===
|
|
OK: No hand-rolled HTML sanitization detected
|