refactor: deep review pass — DB pool split, watchdog surface, security (26.06)#6
Merged
Merged
Conversation
…y (26.06) Lands Planning items #4, #10, #12, #14, #17, #18, #23, #24, #25, #27, #30, #32, #33, #34, #35, #36, #37, #38, #39, and #40. DB + scanner correctness: - sqlite.DB opens separate writer (pinned at 1 conn) and reader (2*GOMAXPROCS) pools, so dashboard queries no longer queue behind the scanner's upserts. :memory: collapses to one pool because that storage is per-connection (#4). - IPv6 size guard computes 1<<(bits-ones) up front so a /64 doesn't allocate 2^64 entries before the check trips (#33). - Global semaphore moved into the Scanner struct: cfg.Workers now caps total dials across all subnets, not per-subnet (#34). Security: - Bearer-token auth on /health and /status; off-loopback bind refuses to boot without health.auth_token (or INVENTORY_AUTH_TOKEN); health.NewAuthedClient sends the matching peer_token (#12). - Config-file permission check refuses to boot when a config with secrets is group/other-readable (#18). - CSRF middleware on admin server — per-process random token, constant-time compare, gates state-changing methods, propagated to forms via {{.CSRFToken}} (#17). - Docker base images pinned to sha256 digests (#14). New features: - /watchdog admin page + Status.Peer surfaces watchdog findings (reachable, drift, staleness, last error) on /status (#10). - POST /scan trigger button on dashboard, plumbed through agent.Trigger() (#23). - scanner.host_ttl pruning at cycle end (off by default) (#24). - /export.json and /export.csv endpoints (#25). - scanner.probe_ports configurable; default unchanged (#27). - Reverse-DNS lookup (500ms timeout) populates Hostname (#30). - Best-effort SSH/HTTP banner grab populates OSFingerprint (#32). Code quality: - cmd/internal/runtime collapses the 95%-identical agent/wintermute/ neuromancer main.go files behind runtime.Run(opts) (#35). - internal/admin split into server.go, handlers.go, render.go, and middleware.go (#36). - Dropped footgun string funcMap; templates use eq .Protocol "tcp" directly via reflective string-kind compare (#37). - TUI plumbs a signal-cancelled context through every store load, replacing context.Background() (#38). - New internal/agent tests covering Trigger coalescing, the Healthy flip on Count failure, and host pruning (#39). - .golangci.yml with errcheck/staticcheck/govet/ineffassign/bodyclose/ errorlint/gocritic/revive; Makefile `make lint` + CI step (#40). Notes / breaking changes: - scanner.New gained a trailing probePorts []int (pass nil for default). - health.NewServer gained a trailing authToken string. - health.NewClient preserved; use health.NewAuthedClient(addr, token). - watchdog.New gained a publish func(health.PeerStatus) parameter. - admin.NewServer gained a trailing trigger admin.Trigger. - Off-loopback health.addr without an auth_token refuses to boot. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1.
Lands Planning items #4, #10, #12, #14, #17, #18, #23, #24, #25, #27, #30, #32, #33, #34, #35, #36, #37, #38, #39, and #40.
Summary
DB + scanner correctness:
Security:
New features:
Code quality:
Breaking changes
scanner.Newgained a trailingprobePorts []int(pass nil for default)health.NewServergained a trailingauthToken stringhealth.NewClientpreserved; usehealth.NewAuthedClient(addr, token)for off-loopback peerswatchdog.Newgained apublish func(health.PeerStatus)parameteradmin.NewServergained a trailingtrigger admin.Triggerhealth.addrwithout anauth_tokenrefuses to bootTest plan
Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/