Public report — headscale, published 6 Aug 2026.
Concrete security findings (CVE IDs, secret matches, dependency versions) are hidden in this version;
ask the repo owner for the full report.
239findings with an exact file:lineof 249 — the remainder are repo-wide signals (a dimension-level measurement, not a single line); open any file:line and verify
30/102dimensions across the health lenses53914 LoC — wide & deep
Executive summary
Read through the Preview lens: this repo is pre-1.0 / in development, so the colour bands are relaxed to what a preview needs — *green* means good enough for a preview, not yet production-stable. Code correctness and security stay near-strict even here; the score itself is absolute and comparable across repos.
juanfont/headscale is sound in substance but carries real gaps (64%). It is not in crisis, but the issues below raise the cost of changing it — friction its consumers ultimately inherit.
It is strongest in Architecture (100%) — the structure is clean and changes stay contained. Domain Modelling (82%) is solid too.
The area that most needs attention is Security (61%) — exposure to security and compliance incidents is elevated. Readiness (63%) is the next concern — releases are harder to depend on — versioning, release notes and dependency hygiene are thin, so consumers can't easily tell what changed or trust an upgrade.
Leadership focus, highest impact first: Document RTO/RPO and a tested restore procedure (a backup… (DR & Backup); Stamp a version in your build/package manifest (e.g. csproj <Version> (Release Hygiene); Record significant decisions one document per decision (Architecture documentation).
For scale: Medium (~53,914 production lines); rebuilding it from scratch would take roughly ~1.3 person-years (~1–3 engineers). Approximate, ±~30%.
It builds on a genuinely strong Architecture foundation (100%); the priorities above are the highest-leverage way to bring the rest up to that level.
How the score is built — each lens's share of the headlineWidth is the lens's weight in the worst-heaviest fold (the weakest area pulls hardest); colour is that lens's own band. A lens fixes the score in proportion to its width.
A full-fidelity diff against the previous run's complete recorded findings — line-move tolerant: a finding that only shifted line counts as unchanged, only genuinely new titles/files surface here.
0.9× (at 64% quality) — the last 20% of quality is most of the work
Size & shape
Medium · effort split not classified (source measured from disk; the effort-tier breakdown is a C#-only syntax walk)
This codebase represents roughly ~1.3 person-years of build effort (about ~€190,000 to rebuild). Its weakest lens is Security at 61% — the part of that asset most exposed by the findings below.
How we model this: boilerplate at a scaffolding rate + logic × domain Standard (×1.2) — domain model × a 0.9× quality factor, at €60–95/h; indicative, ±~30% · size measured directly from source · effort from total production LoC as straight-line logic (the tier split is a C#-only syntax walk), a conservative lower bound. Indicative only — most sensitive to the hourly rate and the domain tier (both tunable in config).
Top priorities
The highest-leverage moves; the full ranked list is in the Roadmap below.
1
Resolve the 1 Off-boarding risk finding(s) in Bus Factor.
The top-ranked fix costs roughly 1–3 engineer-days once. Not doing it costs about 1848.2–11089.4 engineer-days every year, paid as drag on the ~12,888,024 lines this team changes annually — a bill that arrives whether or not anyone books it. On those figures the fix breaks even in roughly 1–2 months and is free after that. Method, stated so this is not read as a quotation: debt from the ranked task's effort band; interest = annual changed lines (measured, annualised from the 90-day window) ÷ an ASSUMED 150–400 lines per engineer-day × the 6–13% drag implied by the code-quality signals; breaking point = debt ÷ annual interest. A modelled planning range built from measured inputs and one named assumption — not a quotation, a valuation, or a certified figure.
Evidence: D15 churn: 3,177,869 line(s) changed over a 90-day window ⇒ ~12,888,024/year · D1/D2/D4 code quality: averaging 5.7/10 ⇒ a 6–13% drag on each change · top-ranked remediation: Low effort ⇒ about 1–3 engineer-day(s)
→ Do the top-ranked fix now if this code will still be yours in 2 months.
Value concentrated against a weak lens · Medium · Value at risk
This is a Medium asset (~1.3 person-years to rebuild), and its weakest lens is Security at 61%. The operational and business risk on an asset this size concentrates there — that's where remediation buys the most protection.
→ Direct remediation budget at Security first — highest risk-reduction per euro on an asset this size.
Highest-leverage move · Medium · Leverage
Of everything flagged, the best return on effort is: Document RTO/RPO and a tested restore procedure (a backup config alone isn't disaster recovery). The rest can wait behind it.
Evidence: priority ranking: top of 5 ranked by impact/effort
→ Document RTO/RPO and a tested restore procedure (a backup config alone isn't disaster recovery).
A velocity tax on every change · Medium · Economics
The code-quality signals (complexity, duplication, cohesion) average 5.7/10, which acts as a tax on every change in the weaker areas: modifications there plausibly cost on the order of 6–13% more than in clean code, and the tax compounds as the codebase grows. (A modelled estimate, not a measured fact.)
Evidence: D1/D2/D4 code quality: averaging 5.7/10 across the code-quality signals actually measured
→ Pay it down where churn is highest — the hotspots — not everywhere; that's where the tax is actually paid.
Architecture — module dependency matrix
42 modules, 59 dependencies — 1 dependency cycle, shown as the red cell(s) above the diagonal. Rows and columns are the same modules, ordered so that a module only depends on ones above it. A cell means the row depends on the column, and its number is how many type pairs create that dependency. Read one thing: is anything above the diagonal? A mark there is a dependency cycle. (A cycle is all this shows — an unusual but cycle-free dependency sits below the diagonal like any other.)
At a glance — Code Health · 65% · Adequate · gated by D2
Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).
OWASP category
Findings
Severity
A05:2021 — Security Misconfiguration
14
High / Critical
A03:2021 — Injection
13
High / Critical
A06:2021 — Vulnerable & Outdated Components
7
High / Critical
Roadmap
First, establish a tested disaster recovery plan with clear recovery time and data loss objectives. Next, implement versioning in your build manifests to ensure all releases are traceable. Then, document key architectural decisions in a single, discoverable location. Finally, address the single off-boarding risk to improve team resilience and resolve the low-severity static analysis findings in the specified files.
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Do this
Helps
Effort
Dimension
Resolve the 1 Off-boarding risk finding(s) in Bus Factor.
Stamp a version in your build/package manifest (e.g. csproj <Version>, package.json, pyproject.toml, Cargo.toml, or a VERSION file) or tag releases with semver so builds and releases are traceable.
Record significant decisions one document per decision — dated, stating the context, the decision and its consequences — and keep them together wherever your design docs already live (a conventional `docs/adr/` tree with `NNNN-title.md` names is the most discoverable form).
Watchdog is a deep, periodic assessment — run each sprint, monthly, or quarterly, taking the time to go wider and deeper than a quick check and surfacing in one coherent report what you'd otherwise piece together from a dozen separate tools. It scores deterministically: the same commit yields the same score, every run. 28 of 30 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); 2 documentation/naming judgement(s) are LLM-assisted and labelled advisory. Overall confidence is 0.6 — the weighted average across measured dimensions; it falls as more of the score leans on LLM-assisted judgement and rises when it's fully tool-backed.
Every figure here is one of three kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact; ◐ Advisory — an LLM prose judgement. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10; ◐ Sampled · advisory marks an LLM verdict over a bounded sample — advisory, never a deterministic measurement.
What we checked — 30 dimensions across the health lenses
Each chip is a dimension scored from real signals across architecture, testing, dependencies, security & compliance, documentation, git-history and code quality — in one coherent pass. A surface report typically covers a handful.
How to trust any code-health report — three questions
Can you open the finding? Real findings cite a repo-relative file and line you can open at the cited line — never an absolute scratch path. Here, 239 of 249 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
Is there a tool behind the number? Every score below names the method that produced it — Roslyn, git, a scanner, or (for a handful of documentation/naming dimensions) an LLM labelled sampled · advisory — not a narrative.
Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.
This report answers yes to all three. That's the bar to hold any assessment to.
Tools & methods
The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.
Method
Backs
Version
Evaluator
Roslyn static analysis
Complexity, cohesion, coupling, dead code, API surface, layering
What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.
D30 Dependency Vulnerabilities — scanner not present in this environment — The backing tool was not installed where this scan ran, so this dimension was not scored. Install the tool (or run in the hosted environment, where it is always present) for a graded result.
Repo exclusion declarations: 3 pattern(s) declared (.gitattributes linguist-generated/vendored, .editorconfig generated_code) excluded 0 source file(s) from code-quality scoring. Declarations are the repo's own visible statement that a tree is machine-written or vendored — auditable in any diff, honored by GitHub the same way.
Limitations & what we did not check
Watchdog assesses the repository exactly as committed, and only the repository. By design it does not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.
Per-dimension blind spots
For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.
D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
D4 Code Duplication: Duplication is token-similarity (jscpd) — it finds copy-paste, not semantic duplication expressed differently. Committed machine-written code (scaffolded migrations, designer/codegen output, protobuf/OpenAPI stubs, model snapshots) is EXCLUDED — its repetition is the tool's, not the team's — so the score reflects hand-written duplication only.
D13 Secret Scanning: Secret detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
D15 Churn × Complexity Hotspots: Churn hotspots come from git history — a freshly imported or squashed repository has no churn signal, and recent rewrites can mask a historically risky file.
D16 Bus Factor: Bus-factor is a time-decayed model of commit attribution (who has recently, repeatedly worked a file), not comprehension — pairing, review and reading-without-committing spread knowledge it can't see; bot commits and shared accounts still distort it.
D19 Documentation Quality: Documentation quality is judged by an LLM over a bounded sample of docs — it reads what is written, not whether the docs match the running system, and it is advisory, not a measurement.
D21 Naming Consistency: Naming quality is an LLM judgement over a bounded sample — it assesses clarity/consistency of the names it sees, not domain-correctness, and is advisory.
D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
D31 IaC & Container Security: IaC scanning checks Dockerfiles/Terraform/Kubernetes against best-practice rules — it cannot see the live cloud account, runtime configuration, or drift between the committed config and what is actually deployed.
D34 Knowledge Freshness: Freshness is decayed commit RECENCY, not comprehension — code read often but rarely committed reads as orphaned, and stable code that genuinely needs no changes is penalised the same as forgotten code; bot/squash commits distort it like the bus factor.
D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
DM4 Rich vs anemic model: Behaviour is detected as state mutation inside a method body — a method that enforces an invariant by validating-and-throwing without mutating reads as a query, and mutation delegated through an interface the scan can't resolve isn't credited; entities with zero public properties still drop out of the population. It detects that state changes, not whether the rule is correct.
M4 Documentation accuracy: Onboarding quality is an LLM read of the docs/setup present — it cannot run the onboarding or measure how long a real new joiner takes; the verdict is sampled and advisory.
P4 Deployment & Rollback: Approval/branch-protection rules live in repository settings the scan cannot see — only their in-repo evidence (config files, workflows) is checked, so a control enforced purely in the host's settings reads as "not evidenced".
P5 DR & Backup: Backup/restore and disaster-recovery readiness is judged from in-repo evidence — a config that exists is not a tested restore, so the absence of positive evidence is reported as "not evidenced", never scored as present.
P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.
The LLM boundary
LLM-set scores this run (3): D19, D21, M4 (model: Local LLM). For these, a model reads a bounded sample and sets the numeric score (documentation, ADR quality, naming, comment value, onboarding) — D25 sets the ADR-conformance fraction over sampled code, D22 judges API accuracy over a sample. These are sampled and advisory by design: they vary at the margins between runs and are never a deterministic measurement. Every other score in this report is tool-computed at confidence 1.0.
What it measures: How tangled the control flow is — methods with many branches are hard to test and change.
Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.
52 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was Policy.validate at 124. A further 1 method(s) were over the threshold but excluded as flat dispatchers (a long switch/match over independent cases: many branches, almost no nesting), the largest being Protocol.toIANAProtocolNumbers at 16 — they are counted neither in the figure above nor in this dimension's score.
+ 47 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 1 Policy.validate (cyclomatic 124) finding(s) in Cyclomatic Complexity — start with types.go. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 db.NewHeadscaleDatabase (cyclomatic 100) finding(s) in Cyclomatic Complexity — start with db.go. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 State.HandleNodeFromPreAuthKey (cyclomatic 60) finding(s) in Cyclomatic Complexity — start with state.go. — One of this dimension's main actionable groups (1 warning-level).
Enforce Cyclomatic Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: How hard the code is for a person to follow, beyond raw branching.
Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.
+ 93 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 1 Policy.validate (cognitive 284) finding(s) in Cognitive Complexity — start with types.go. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 db.NewHeadscaleDatabase (cognitive 147) finding(s) in Cognitive Complexity — start with db.go. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 PolicyManager.ViaRoutesForPeer (cognitive 124) finding(s) in Cognitive Complexity — start with policy.go. — One of this dimension's main actionable groups (1 warning-level).
Enforce Cognitive Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D3 · God Classes8.8 / 10Strong✓ Tool-verified
What it measures: Over-large classes that try to do too much ("god classes").
Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.
TooManyMethods: State · ×7hscontrol/state/state.go:140
What to do
Resolve the 13 FileTooLong finding(s) in God Classes — start with types.go, state.go, hsic.go. — One of this dimension's main actionable groups (13 warning-level).
Resolve the 7 TooManyMethods finding(s) in God Classes — start with state.go, db.go, hsic.go. — One of this dimension's main actionable groups (7 warning-level).
Enforce God Classes in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Copy-pasted code that should be shared instead.
Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), density-scored per KLoC of production code. Deterministic.
What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.
Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.
What it measures: Files that change often and are also complex — the riskiest hotspots.
Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.
Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D16 · Bus Factor2.5 / 10Critical✓ Tool-verified
What it measures: Whether knowledge is concentrated in too few people (the "bus factor").
Method: Living knowledge per author via time-decayed commit attribution (6-month half-life, focus weighting) across largest source files. Deterministic, avoids blame's mechanical-refactor false positives.
85 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is hscontrol/state/state.go.
Off-boarding risk: anonymized user #1
What to do
Resolve the 1 Off-boarding risk finding(s) in Bus Factor. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d16_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the project's documentation is clear, complete, and useful.
Method: Judged by language model at low temperature (0.0-0.1) on a deterministic doc sample (READMEs plus first 25 architecture docs), with two-pass stability filtering. Advisory, sampled.
This project is well documented with a strong README for each major component (e.g. the stable and development documentation sites, packaging, NixOS module, integration test runner, local dev environment), plus architecture/design docs covering API conventions, auth, scope requirements, and the Tailscale wire-shape porting policy. The open-source self-hosted control server is described with a clear What-is-Tailscale section, a Design goal that limits to one single tailnet for personal use, and detailed integration-testing coverage (how to write tests, framework layers, required scaffolding like `IntegrationSkip(t)`).
What it measures: Whether names — types, methods, variables — are clear and consistent.
Method: Judged by language model at low temperature (0.0-0.1) on a deterministic random symbol sample (fixed size, not exhaustive), with disclosed confidence band. Advisory, sampled.
What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.
Method: Git-history secret scan via gitleaks detect over full history in an isolated checkout; each match flagged High. Exhaustive; degrades cleanly when tool absent.
What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.
Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.
Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).
High: run-shell-injection.github/workflows/gc.yml:37detected by semgrep finding
Medium: math-random-used · ×5hscontrol/derp/derp.go:9detected by semgrep finding
Low: missing-ssl-minversion · ×7cmd/headscale/cli/oauth_client.go:213detected by semgrep finding
What to do
Resolve the 7 Low finding(s) in Static Analysis (SAST) — start with oidc.go (2), oauth_client.go, utils.go. — One of this dimension's main actionable groups (7 recommendation-level).
Resolve the 1 High finding(s) in Static Analysis (SAST) — start with gc.yml. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 5 Medium finding(s) in Static Analysis (SAST) — start with hsic.go (2), derp.go, poll.go. — One of this dimension's main actionable groups (5 warning-level).
Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.
High IaC: DS-0002 · ×6Dockerfile.derperdetected by trivy finding
Medium IaC: CKV_DOCKER_3 · ×6Dockerfile.integration-ci:1detected by trivy finding
Low IaC: DS-0026 · ×2Dockerfile.integrationdetected by trivy finding
What to do
Resolve the 6 High IaC finding(s) in IaC & Container Security — start with Dockerfile.derper, Dockerfile.integration, Dockerfile.integration-ci. — One of this dimension's main actionable groups (6 issue-level).
Resolve the 6 Medium IaC finding(s) in IaC & Container Security — start with Dockerfile.integration-ci, Dockerfile.tailscale-rs, Dockerfile.tailscale-HEAD. — One of this dimension's main actionable groups (6 warning-level).
Resolve the 2 Low IaC finding(s) in IaC & Container Security — start with Dockerfile.integration, Dockerfile.integration-ci. — One of this dimension's main actionable groups (2 recommendation-level).
Detailed fixes: d31_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.
Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.
What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.
Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.
Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling; coupling through a build step, config, or non-source file isn't seen.
What it measures: Whether the build pipeline provides supply-chain integrity — generated provenance/attestation, signed artifacts (cosign/sigstore), an SBOM, and pinned build actions. Presence of the configuration, not a runtime guarantee.
Method: Supply-chain provenance/signing read deterministically from CI/build config (.github/workflows, .gitlab-ci.yml, azure-pipelines, Jenkinsfile, .circleci) + the release surface: four signals — generated provenance/attestation (SLSA/in-toto/actions-attest), artifact signing (cosign/sigstore/gitsign), an SBOM (syft/sbom-action/*.spdx.json/*.cdx.json), and SHA-pinned build actions — scored 10·present/denom. NotApplicable without a build pipeline. Detects configuration presence, not runtime enforcement.
Resolve the 1 Unpinned build actions finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 PR-triggered workflow without a permissions block finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 No build provenance finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d36_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether dependencies have known published vulnerabilities (CVEs) per the OSV database — read natively from whatever lockfile the repository ships (Cargo, npm, Go, Python, Maven, RubyGems, …). D33 and D30 add ecosystem-specific scanners on top for npm and .NET.
Method: Multi-ecosystem dependency-CVE scan via osv-scanner --recursive (queries the osv.dev database + parses lockfiles natively across ecosystems: npm package-lock/yarn/pnpm/bun, Go go.mod, Rust Cargo.lock, Maven/Gradle pom.xml/gradle.lockfile, PyPI requirements.txt/poetry.lock/Pipfile.lock, Composer composer.lock, RubyGems Gemfile.lock, Hex mix.lock, pub pubspec.lock, Swift Package.resolved); severity tally (Critical/High/Medium/Low) to 0-10 tight normalizer (8.0). NotApplicable only when the repo declares no supported non-.NET dependency lockfile (a NuGet-only repo stays NotApplicable — .NET CVEs are D30's domain); coverage needs a resolved lockfile. Additive to D33 (trivy fs); exhaustive + deterministic, DB kept fresh.
High CVE: [GHSA redacted] · ×2go.moddetected by osv-scanner finding
High vulnerability: [GHSA redacted]go.moddetected by osv-scanner finding
Medium vulnerability: GO-2026-5841 · ×2go.moddetected by osv-scanner finding
Medium CVE: GO-2026-4961 · ×2go.moddetected by osv-scanner finding
What to do
Resolve the 2 High CVE finding(s) in OSV Dependency Vulnerabilities — start with go.mod (2). — One of this dimension's main actionable groups (2 issue-level).
Resolve the 1 High vulnerability finding(s) in OSV Dependency Vulnerabilities — start with go.mod. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 2 Medium vulnerability finding(s) in OSV Dependency Vulnerabilities — start with go.mod (2). — One of this dimension's main actionable groups (2 warning-level).
Detailed fixes: d38_recommendation.md · top locations in Appendix A, every location in findings.md.
Other · Domain Modelling — Whether aggregates reference each other by identity (id) rather than by direct object reference — the core DDD consistency-boundary rule.
Method: Roslyn (DDD-gated): aggregate roots identified by convention; each aggregate field checked for direct references to other aggregates versus id-only. Deterministic, DDD-native.
Coverage: Population: aggregate roots identified by AggregateRoot/IAggregateRoot base/interface NAME convention; reference-by-identity then checked exhaustively within that set — a root not using those names is invisible.
Do you agree with this assessment?
DM4 · Rich vs anemic model5.0 / 10Adequate✓ Tool-verified
Other · Domain Modelling — Whether aggregates/entities carry the behaviour that protects their invariants, rather than being data bags driven by external services.
Method: Roslyn (DDD-gated): entity method BODIES classified mutator-vs-query — only methods that mutate the entity's own declared state count as invariant-protecting behaviour, so a getter/passthrough doesn't rescue an anemic class. Deterministic, exhaustive over domain-layer entities.
Coverage: Population: entities by name/base convention; rich-vs-anemic judged by classifying each method body mutator-vs-query — logic-bearing domain types outside the convention are invisible.
`APIKey` is an aggregate/entity with 7 data propert(ies) but no state-changing behaviour (only data and queries) — the business logic lives in a service. — api_key.go:15
`OAuthClient` is an aggregate/entity with 9 data propert(ies) but no state-changing behaviour (only data and queries) — the business logic lives in a service. — oauth.go:32
`OAuthAccessToken` is an aggregate/entity with 8 data propert(ies) but no state-changing behaviour (only data and queries) — the business logic lives in a service. — oauth.go:61
`PreAuthKey` is an aggregate/entity with 14 data propert(ies) but no state-changing behaviour (only data and queries) — the business logic lives in a service. — preauth_key.go:38
`PreAuthKeyNew` is an aggregate/entity with 8 data propert(ies) but no state-changing behaviour (only data and queries) — the business logic lives in a service. — preauth_key.go:77
What to do
Move business rules onto the aggregates/entities they govern so invariants are enforced at the source, not in anemic services.
Other · Domain Modelling — Whether entities protect their state (private/init-only setters) instead of exposing public setters that bypass invariants. Softened when a rehydration framework (Marten/EF) is present.
Method: Roslyn (DDD-gated): public setters on entities detected; score softened when Marten/EF rehydration frameworks present. Deterministic, framework-aware.
Coverage: Population: entities by convention; encapsulation (setter shape) checked exhaustively within the set.
Other · Domain Modelling — Whether clusters of primitives that travel together (a missing value object) are extracted — a low-weight suggestion, LLM-confirmed when configured.
Method: Roslyn (DDD-gated): primitive parameter clusters recurring three or more times across signatures extracted, then confirmed by language model when configured. Advisory, low-weight.
Maturity · Maturity — Whether the repo and its projects have a README, and whether it's substantive and current.
Method: Filesystem scan: README presence, word count, and headings for depth; git history for staleness. Exhaustive across root and project dirs, deterministic.
Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.
Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.
No Architecture Decision Records found — no conventional ADR directory, no `NNNN-title.md` documents and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
What to do
Record significant decisions one document per decision — dated, stating the context, the decision and its consequences — and keep them together wherever your design docs already live (a conventional `docs/adr/` tree with `NNNN-title.md` names is the most discoverable form).
Maturity · Maturity — Whether the README actually describes the code that exists (LLM-judged, advisory).
Method: Judged by language model at low temperature: README accuracy versus actual projects, within a disclosed tolerance. Advisory, not a measured number.
Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).
Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.
What to do
Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
Readiness · Readiness — Whether releases are automated and safely reversible (probes, rolling updates, approval gates) — from manifests/pipeline files, not the live environment.
Method: Filesystem scan: deployment manifests/IaC (K8s YAML, Helm, Terraform) for rolling updates, probes, approval gates, migration hooks. Exhaustive, deterministic.
Do you agree with this assessment?
P5 · DR & Backup4.0 / 10Weak✓ Tool-verified
Readiness · Readiness — Whether disaster recovery is planned and codified — backups, geo-recovery, RTO/RPO, persistence guarantees — from IaC + container manifests + docs, never the live cloud.
Method: Filesystem scan: disaster recovery, backup, geo-recovery, RTO/RPO, persistence guarantees from IaC, manifests, and docs. Exhaustive, deterministic, never a live environment.
What to do
Document RTO/RPO and a tested restore procedure (a backup config alone isn't disaster recovery).
Enable purge protection / soft-delete (and prevent_destroy on critical resources) so data stores can't be lost to an accidental or malicious delete.
Readiness · Readiness — Whether releases are traceable — a maintained changelog and explicit version stamping.
Method: Filesystem scan: changelog file presence and version tags in csproj or git tags. Exhaustive, deterministic.
What to do
Stamp a version in your build/package manifest (e.g. csproj <Version>, package.json, pyproject.toml, Cargo.toml, or a VERSION file) or tag releases with semver so builds and releases are traceable.
Do you agree with this assessment?
Reference — by lens
The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.
Not included — 72 check(s) not relevant to this codebase
These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.
AC1 Text alternatives — No web markup found — accessibility is not applicable to this repository.
AC2 Forms & labels — No web markup found — accessibility is not applicable to this repository.
AC3 Page structure — No web markup found — accessibility is not applicable to this repository.
AC4 Keyboard semantics — No web markup found — accessibility is not applicable to this repository.
AC5 ARIA correctness — No web markup found — accessibility is not applicable to this repository.
AC6 Visual & motion safety — No web markup found — accessibility is not applicable to this repository.
AC7 A11y enforcement — No web markup found — accessibility is not applicable to this repository.
AX1 Captive dependencies — no DI registrations detected
AX10 Code composition — not assessed — code composition is computed by ROLE over a document set that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX2 Stateful singletons — no singleton implementations detected
AX3 Project dependency cycles — not assessed — project cycles and dependency direction are computed over a project-reference graph that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX4 Dependency direction — not assessed — project cycles and dependency direction are computed over a project-reference graph that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX6 Interface segregation — not assessed — interface segregation is computed over a type surface that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX7 Slice cohesion — not applicable — not a vertical-slice architecture
AX8 Test isolation — not assessed — test isolation is computed from a project graph (which projects are test projects, and what they reference) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX9 CQS / query purity — no CQRS query handlers detected — query purity is not applicable to this codebase
AXB2 Runtime readiness — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
C1 Data Protection — Not assessed: these personal data controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks personal data controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
C2 Access Controls — Not assessed: these authorization controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks authorization controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
C3 Audit Trail — Not assessed: these audit controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks audit controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
C4 Data Retention — Not assessed: these retention controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks retention controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
C5 Data-Subject Rights — Not assessed: these data-subject rights controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks data-subject rights controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
D10 Test Quality — ~86273 lines of test source are present (.go) but the test-quality collector reads C# only, so skipped/assertion-free tests couldn't be counted. Not scored — this is a gap in the analyzer, not a finding about this repository.
D11 Test Reliability — Test reliability not included
D12 Dependency Hygiene — Dependency hygiene not measured — dependency manifest found but not parsed for hygiene
D14 License Compliance — Not scored — this repository's package manifest is not parsed for licence data yet. A gap in the analyzer's language coverage, NOT a finding that the repository's licenses are compliant (a Go module (go.mod/go.sum) and a Python pyproject.toml/requirements.txt (pip/uv/Poetry)), which this pass does not parse yet — so this dimension asserts nothing about this repository's licensing in either direction.
D17 Explicit Debt — explicit-debt markers are read through a C# workspace today, so they were not read for this repository's language — this asserts nothing about how many markers the code carries. Not scored — this is a gap in the analyzer, not a finding about this repository
D18 Solution Shape — D18 scores the shape of a .NET solution; this repository has no .NET solution or project files, so the dimension does not apply.
D20 ADR Quality — N/A — ADRs are expected on deployable products with a user-facing host, not consumed libraries; no ADR log is required here.
D22 Internal API Consistency — No exposed public API
D23 Boundary Type-Coupling — Production source is present (.go) but bounded contexts are resolved over the C#/VB project set, which exposed none, so context scope could not be assessed. Not scored — this is a gap in the analyzer, not a verdict about this repository. Declaring the codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed — see the recommendation on this dimension for where. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
D24 Comment Value — No inline comments to assess — comment value is not applicable here.
D25 ADR Conformance — no ADRs to check
D26 Project Cohesion — Project cohesion is assessed over the .NET project set; this target exposed no projects, so project size and spread could not be assessed. Not scored — this is a gap in the analyzer's reach, not a verdict about this repository.
D27 Navigability — No calls could be sampled, so navigability was not assessed — tracing effort is measured over resolved call sites and this target exposed none. Not scored — this is a gap in the analyzer's reach, not a verdict about this repository.
D30 Dependency Vulnerabilities — Not scored — no dependency manifest in a supported ecosystem was read for this repository. A gap in the analyzer's language coverage, NOT a finding that the repository is free of vulnerable dependencies (a Go module (go.mod/go.sum) and a Python pyproject.toml/requirements.txt (pip/uv/Poetry) — not scanned yet) — where an OSV-supported manifest exists, dependency vulnerabilities for this repository are reported under D38 instead.
D32 Data Compliance (PII/GDPR) — No PII/GDPR-handling patterns detected (p/gdpr ruleset) — no data-compliance surface to assess.
D33 JS/npm Dependency Vulnerabilities — No JS/npm manifest or lockfile found outside build output (package.json, package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb); no JS dependencies to scan.
D37 Vulnerability-disclosure Policy — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
D39 IL Efficiency — D39 measures the IL emitted by a .NET build; this repository has no .NET solution or project files, so the dimension does not apply.
D40 Network Egress Confinement — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
D41 Kernel & Syscall Confinement — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
D42 Runtime Threat Enforcement — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
D5 Coupling — Inter-project coupling could not be assessed — no analyzable project graph was found for this repository. Not scored: a gap in the analyzer's reach, not a verdict about this repository. (Coupling here is Martin afferent/efferent/instability plus reference cycles across a project-reference graph, read today from .NET project files; other ecosystems' module graphs are not read yet.)
D6 Cohesion (LCOM4) — Cohesion (LCOM4) is measured over a C#/VB class graph, and this repository's production source is mostly .go, which this pass does not read, so cohesion was not assessed for this repository. Not scored — this is a gap in the analyzer, not a finding about this repository.
D7 Architectural Integrity — no checkable ADRs, and no project-reference graph for the cycle pass to read — so this dimension makes no claim about dependency cycles in either direction (where this repository's language has an import-cycle lens, cycles are reported there). Architectural integrity not assessed
D8 Code Coverage — Coverage not included — suite not readable by the collector
D9 Test Distribution — Test source is present (.go) but the test-pyramid classifier reads C# only, so its unit/integration/BDD/E2E split couldn't be counted. Not scored — this is a gap in the analyzer, not a finding about this repository.
DM2 Strongly-typed ids — no id-bearing domain types detected — strongly-typed-id adoption not assessable
DM3 Integration-event coupling — no integration events detected — coupling check not applicable
DM6 Domain ↔ infrastructure boundary — no domain-layer types detected — domain↔infrastructure boundary check not applicable
ED1 Event-Driven — not scored — this repository shows only 1 of the 3 signals this check looks for (1 event-sourced shape(s) (event folds / event-recording aggregates))
ED5 Idempotency — no mutating command handlers or message consumers detected — idempotency check not applicable
ES1 Event Sourcing — not scored — this repository shows only 1 of the 3 signals this check looks for (1 Go aggregate(s) recording domain events (own events-slice append / raise-record))
GD1 Unfinished & placeholder code — no source files
IC1 Incompleteness & stubs — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
P12 CI test-gate honesty — Reported, not scored — and nothing was matched here. The coverage check applies to any stack, but the checks for excluded tests, skipped tests and sleep-based synchronisation currently recognise only some ecosystems' test-runner idioms, so on a repository built with another stack the zeros below mean 'not checked', not 'clean'.
P2 Observability — Observability was not assessed: this check reads a source model that does not carry this repository's product — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of a logging idiom this check recognises is NOT evidence that this repo lacks structured logging (it may log through its own ecosystem's logger). This is a gap in the analyzer, not a finding about this repository.
P7 Outbound HTTP resilience — not measured — the application kind could not be determined for this repo
P8 Schema migrations — not assessed — schema-migration practice is read from a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
P9 Domain vs controller coverage — no coverage report found on disk — produce a coverage report in a standard format (`go test -coverprofile=coverage.out ./...`) into the repo working tree before the scan — a CI step is the usual place, since the artefact is commonly gitignored, or wire coverage collection into CI, to enable this cross-layer check
PF1 Benchmark discipline — Performance was not assessed: this lens reads a source model that was not loaded for this repository, because the repository is written in a language this lens does not yet model or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository — in particular it is NOT a statement that this repo is unpackaged or performance-careless.
PF2 Allocation hygiene — Performance was not assessed: this lens reads a source model that was not loaded for this repository, because the repository is written in a language this lens does not yet model or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository — in particular it is NOT a statement that this repo is unpackaged or performance-careless.
PF3 Async & latency hygiene — Performance was not assessed: this lens reads a source model that was not loaded for this repository, because the repository is written in a language this lens does not yet model or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository — in particular it is NOT a statement that this repo is unpackaged or performance-careless.
S1 Web-Security Posture — Not assessed: these web-security controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks web-security controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
SC1 Supply-chain hygiene — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X1 Async correctness — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X2 Cancellation propagation — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X3 Exception handling — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X4 Structured logging — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X5 Nullable reference types — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
Appendix A — Findings (grouped)
The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.
High IaC: DS-0002 Dockerfile.derper— Image user should not be 'root' A container that starts as root runs your process with root's capabilities inside the namespace, so a compromise of the process starts from there. The step: create an unprivileged account in the image (`RUN adduser -S -D app`), give it ownership of the paths the process writes at runtime (`COPY --chown=` on those layers, or a `RUN chown -R`), and end the final stage with `USER app` so it is the default at start. Build stages that only compile can stay root; it is the stage that RUNS that needs the account. If the process genuinely requires root — it manages the container runtime, ptraces another process or opens raw devices — say so here rather than making a change that breaks it.
High IaC: DS-0002 Dockerfile.integration— Image user should not be 'root' A container that starts as root runs your process with root's capabilities inside the namespace, so a compromise of the process starts from there. The step: create an unprivileged account in the image (`RUN adduser --system --no-create-home app`), give it ownership of the paths the process writes at runtime (`COPY --chown=` on those layers, or a `RUN chown -R`), and end the final stage with `USER app` so it is the default at start. Build stages that only compile can stay root; it is the stage that RUNS that needs the account. If the process genuinely requires root — it manages the container runtime, ptraces another process or opens raw devices — say so here rather than making a change that breaks it.
High IaC: DS-0002 Dockerfile.integration-ci— Image user should not be 'root' A container that starts as root runs your process with root's capabilities inside the namespace, so a compromise of the process starts from there. The step: create an unprivileged account in the image (`RUN adduser --system --no-create-home app`), give it ownership of the paths the process writes at runtime (`COPY --chown=` on those layers, or a `RUN chown -R`), and end the final stage with `USER app` so it is the default at start. Build stages that only compile can stay root; it is the stage that RUNS that needs the account. If the process genuinely requires root — it manages the container runtime, ptraces another process or opens raw devices — say so here rather than making a change that breaks it.
High IaC: DS-0002 Dockerfile.tailscale-HEAD— Image user should not be 'root' A container that starts as root runs your process with root's capabilities inside the namespace, so a compromise of the process starts from there. The step: create an unprivileged account in the image (`RUN adduser -S -D app`), give it ownership of the paths the process writes at runtime (`COPY --chown=` on those layers, or a `RUN chown -R`), and end the final stage with `USER app` so it is the default at start. Build stages that only compile can stay root; it is the stage that RUNS that needs the account. If the process genuinely requires root — it manages the container runtime, ptraces another process or opens raw devices — say so here rather than making a change that breaks it.
High IaC: DS-0002 Dockerfile.tailscale-rs— Image user should not be 'root' A container that starts as root runs your process with root's capabilities inside the namespace, so a compromise of the process starts from there. The step: create an unprivileged account in the image (`RUN adduser --system --no-create-home app`), give it ownership of the paths the process writes at runtime (`COPY --chown=` on those layers, or a `RUN chown -R`), and end the final stage with `USER app` so it is the default at start. Build stages that only compile can stay root; it is the stage that RUNS that needs the account. If the process genuinely requires root — it manages the container runtime, ptraces another process or opens raw devices — say so here rather than making a change that breaks it.
High IaC: DS-0002 Dockerfile.wasmclient— Image user should not be 'root' A container that starts as root runs your process with root's capabilities inside the namespace, so a compromise of the process starts from there. The step: create an unprivileged account in the image (`RUN useradd -r -M app` — or whatever this base image's account tooling is, `adduser` and `useradd` are not both present everywhere`), give it ownership of the paths the process writes at runtime (`COPY --chown=` on those layers, or a `RUN chown -R`), and end the final stage with `USER app` so it is the default at start. Build stages that only compile can stay root; it is the stage that RUNS that needs the account. If the process genuinely requires root — it manages the container runtime, ptraces another process or opens raw devices — say so here rather than making a change that breaks it.
D38 · OSV Dependency Vulnerabilities· High CVE · ×2
High CVE: [GHSA redacted] go.mod— github.com/docker/docker 28.5.2+incompatible: [GHSA redacted] — no fixed version has been published yet. Track the advisory, and remove or replace github.com/docker/docker if the exposure is not acceptable until one lands. This one row stands for the 5 advisories this scan raises against github.com/docker/docker 28.5.2+incompatible: [GHSA redacted], [GHSA redacted], [GHSA redacted], [GHSA redacted], [GHSA redacted].
High CVE: [GHSA redacted] go.mod— github.com/opencontainers/runc 1.3.2: [GHSA redacted] — github.com/opencontainers/runc is not a DIRECT requirement of this module: go.mod records it as `// indirect`, pulled in transitively, so raise it in place (run `go get github.com/opencontainers/runc@v1.3.3`, which updates the require line go.mod already holds for it). This one row stands for the 4 advisories this scan raises against github.com/opencontainers/runc 1.3.2: [GHSA redacted], [GHSA redacted], [GHSA redacted], [GHSA redacted].
High: run-shell-injection .github/workflows/gc.yml:37— Using variable interpolation `${{...}}` with a workflow input in a `run:` step could allow an attacker to inject their own code into the runner. This would allow them to steal secrets and code. A workflow input is not bounded by this step and should be treated as untrusted. Instead, use an intermediate environment variable with `env:` to store the data and use the environment variable in the `run:` script. Reference it as a shell VARIABLE rather than a `${{ }}` interpolation, using your shell's own syntax (`"$ENVVAR"` in bash, `$env:ENVVAR` in PowerShell), so the value is passed as data and never re-expanded as code.
D38 · OSV Dependency Vulnerabilities· High vulnerability · ×1
High vulnerability: [GHSA redacted] go.mod— google.golang.org/grpc 1.81.1: [GHSA redacted] — google.golang.org/grpc is not a DIRECT requirement of this module: go.mod records it as `// indirect`, pulled in transitively, so raise it in place (run `go get google.golang.org/grpc@v1.82.1`, which updates the require line go.mod already holds for it).
FileTooLong: v2/types.go hscontrol/policy/v2/types.go:0— FileTooLong — 1766 significant lines (blank, comment-only and punctuation-only lines excluded). To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: state/state.go hscontrol/state/state.go:0— FileTooLong — 1516 significant lines (blank, comment-only and punctuation-only lines excluded). To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: hsic/hsic.go integration/hsic/hsic.go:0— FileTooLong — 985 significant lines (blank, comment-only and punctuation-only lines excluded). To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: integration/scenario.go integration/scenario.go:0— FileTooLong — 933 significant lines (blank, comment-only and punctuation-only lines excluded). To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: tsic/tsic.go integration/tsic/tsic.go:0— FileTooLong — 905 significant lines (blank, comment-only and punctuation-only lines excluded). To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: v2/policy.go hscontrol/policy/v2/policy.go:0— FileTooLong — 848 significant lines (blank, comment-only and punctuation-only lines excluded). To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: types/config.go hscontrol/types/config.go:0— FileTooLong — 844 significant lines (blank, comment-only and punctuation-only lines excluded). To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: hscontrol/app.go hscontrol/app.go:0— FileTooLong — 652 significant lines (blank, comment-only and punctuation-only lines excluded). To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: db/db.go hscontrol/db/db.go:0— FileTooLong — 625 significant lines (blank, comment-only and punctuation-only lines excluded), about 71% of them inside a single declaration: NewHeadscaleDatabase (55-1052). Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: integration/helpers.go integration/helpers.go:0— FileTooLong — 593 significant lines (blank, comment-only and punctuation-only lines excluded). To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: types/node.go hscontrol/types/node.go:0— FileTooLong — 568 significant lines (blank, comment-only and punctuation-only lines excluded). To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: hscontrol/oidc.go hscontrol/oidc.go:0— FileTooLong — 529 significant lines (blank, comment-only and punctuation-only lines excluded). To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: state/node_store.go hscontrol/state/node_store.go:0— FileTooLong — 503 significant lines (blank, comment-only and punctuation-only lines excluded). To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
Hotspot: hscontrol/state/state.go hscontrol/state/state.go— hscontrol/state/state.go changed 38 times in last 90 days, max complexity 60. 1 of those changes was a fix/bug commit, and the other 37 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, cover the area it touches with tests, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time.
Hotspot: hscontrol/policy/v2/types.go hscontrol/policy/v2/types.go— hscontrol/policy/v2/types.go changed 14 times in last 90 days, max complexity 124. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, behind tests written first.
Hotspot: hscontrol/db/db.go hscontrol/db/db.go— hscontrol/db/db.go changed 8 times in last 90 days, max complexity 100. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, behind tests written first.
Hotspot: hscontrol/policy/v2/policy.go hscontrol/policy/v2/policy.go— hscontrol/policy/v2/policy.go changed 17 times in last 90 days, max complexity 46. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, behind tests written first.
Hotspot: hscontrol/app.go hscontrol/app.go— hscontrol/app.go changed 10 times in last 90 days, max complexity 37. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, behind tests written first.
Hotspot: hscontrol/types/config.go hscontrol/types/config.go— hscontrol/types/config.go changed 13 times in last 90 days, max complexity 26. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, behind tests written first.
Hotspot: integration/hsic/hsic.go integration/hsic/hsic.go— integration/hsic/hsic.go changed 8 times in last 90 days, max complexity 38. 1 of those changes was a fix/bug commit, and the other 7 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, cover the area it touches with tests, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time.
Hotspot: integration/tsic/tsic.go integration/tsic/tsic.go— integration/tsic/tsic.go changed 9 times in last 90 days, max complexity 33. 1 of those changes was a fix/bug commit, and the other 8 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, cover the area it touches with tests, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time.
Hotspot: hscontrol/oidc.go hscontrol/oidc.go— hscontrol/oidc.go changed 10 times in last 90 days, max complexity 26. 2 of those changes were fix/bug commits, and the other 8 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, cover the area it touches with tests, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time.
Hotspot: hscontrol/state/node_store.go hscontrol/state/node_store.go— hscontrol/state/node_store.go changed 8 times in last 90 days, max complexity 25. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, behind tests written first.
TooManyMethods: State hscontrol/state/state.go:140— TooManyMethods — 130 methods, declared across 4 files: state/state.go (109), state/debug.go (16), state/ping.go (3), state/node_health.go (2). That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: HSDatabase hscontrol/db/db.go:46— TooManyMethods — 58 methods, declared across 8 files: db/node.go (16), db/api_key.go (9), db/preauth_keys.go (9), db/users.go (9), +4 more file(s). That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: HeadscaleInContainer integration/hsic/hsic.go:73— TooManyMethods — 53 methods. Most of these members implement integration.ControlServer (36 of 53 members), so moving them onto a smaller type would remove them from that contract rather than reduce it. To reduce it, split the contract instead: give each cohesive group of operations its own smaller interface and its own implementing type. Where the contract has to stay whole, move the work behind these members into collaborator types, so what is left here is a forward per member rather than a responsibility per member.
TooManyMethods: TailscaleInContainer integration/tsic/tsic.go:85— TooManyMethods — 46 methods. Most of these members implement integration.TailscaleClient (39 of 46 members), so moving them onto a smaller type would remove them from that contract rather than reduce it. To reduce it, split the contract instead: give each cohesive group of operations its own smaller interface and its own implementing type. Where the contract has to stay whole, move the work behind these members into collaborator types, so what is left here is a forward per member rather than a responsibility per member.
TooManyMethods: Scenario integration/scenario.go:96— TooManyMethods — 42 methods, declared across 2 files: integration/scenario.go (40), integration/helpers.go (2). That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: Headscale hscontrol/app.go:82— TooManyMethods — 37 methods, declared across 7 files: hscontrol/app.go (14), hscontrol/auth.go (6), hscontrol/handlers.go (6), hscontrol/debug.go (5), +3 more file(s). That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: PolicyManager hscontrol/policy/v2/policy.go:31— TooManyMethods — 32 methods, declared across 3 files: v2/policy.go (30), v2/sshtest.go (1), v2/test.go (1). That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
Medium: math-random-used hscontrol/derp/derp.go:9— `math/rand` is not cryptographically secure — its stream is reproducible from its seed and predictable from observed output — so any value that must be unguessable (a token, nonce, key, salt, session id, password-reset or MFA code) has to come from `crypto/rand`. Where non-cryptographic randomness IS the intent — jitter, backoff, sampling, load spreading, simulation, test fixtures, or output that is deliberately reproducible from a seed — `math/rand` is the correct choice and no change is needed; a package that deliberately offers both should keep its security-sensitive callers on the `crypto/rand` path rather than drop the other one. This is a semgrep security-AUDIT rule: it reports that a sensitive pattern is present, not that it is exploitable here. Confirm whether the flagged value reaches a security decision — a credential, token, nonce, key, salt or session id, or an externally reachable surface — and apply the change where it does; where it provably does not (cosmetic, simulation, or deliberately reproducible use), record the review and leave the code as it is.
Medium: math-random-used hscontrol/poll.go:8— `math/rand` is not cryptographically secure — its stream is reproducible from its seed and predictable from observed output — so any value that must be unguessable (a token, nonce, key, salt, session id, password-reset or MFA code) has to come from `crypto/rand`. Where non-cryptographic randomness IS the intent — jitter, backoff, sampling, load spreading, simulation, test fixtures, or output that is deliberately reproducible from a seed — `math/rand` is the correct choice and no change is needed; a package that deliberately offers both should keep its security-sensitive callers on the `crypto/rand` path rather than drop the other one. This is a semgrep security-AUDIT rule: it reports that a sensitive pattern is present, not that it is exploitable here. Confirm whether the flagged value reaches a security decision — a credential, token, nonce, key, salt or session id, or an externally reachable surface — and apply the change where it does; where it provably does not (cosmetic, simulation, or deliberately reproducible use), record the review and leave the code as it is.
Medium: potential-dos-via-decompression-bomb integration/hsic/hsic.go:845— Detected a possible denial-of-service via a zip bomb attack. By limiting the max bytes read, you can mitigate this attack. `io.CopyN()` can specify a size. This is a semgrep security-AUDIT rule: it reports that a sensitive construct is present, not that it is exploitable here. Confirm whether this site handles untrusted input or is reachable across a trust boundary — and apply the change where it is; where the construct is required by the platform or protocol it calls into, and carries no untrusted data (a syscall/FFI shim, a build- or debug-gated tool, a fixed local surface), record the review and leave the code as it is.
Medium: potential-dos-via-decompression-bomb integration/hsic/hsic.go:951— Detected a possible denial-of-service via a zip bomb attack. By limiting the max bytes read, you can mitigate this attack. `io.CopyN()` can specify a size. This is a semgrep security-AUDIT rule: it reports that a sensitive construct is present, not that it is exploitable here. Confirm whether this site handles untrusted input or is reachable across a trust boundary — and apply the change where it is; where the construct is required by the platform or protocol it calls into, and carries no untrusted data (a syscall/FFI shim, a build- or debug-gated tool, a fixed local surface), record the review and leave the code as it is.
Medium: potential-dos-via-decompression-bomb integration/tsic/tsic.go:1674— Detected a possible denial-of-service via a zip bomb attack. By limiting the max bytes read, you can mitigate this attack. `io.CopyN()` can specify a size. This is a semgrep security-AUDIT rule: it reports that a sensitive construct is present, not that it is exploitable here. Confirm whether this site handles untrusted input or is reachable across a trust boundary — and apply the change where it is; where the construct is required by the platform or protocol it calls into, and carries no untrusted data (a syscall/FFI shim, a build- or debug-gated tool, a fixed local surface), record the review and leave the code as it is.
Duplicated block (11 lines × 2) hscontrol/api/v1/policy.go:128— hscontrol/api/v1/policy.go:128-138 | hscontrol/api/v2/acl.go:121-131 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/api/v1/policy.go:128` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11 lines × 2) hscontrol/api/v1/policy.go:139— hscontrol/api/v1/policy.go:139-151 | hscontrol/api/v2/acl.go:132-142 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/api/v1/policy.go:139` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) hscontrol/policy/v2/compiled.go:278— hscontrol/policy/v2/compiled.go:278-291 | hscontrol/policy/v2/filter.go:269-279 — the copies sit in sibling files of one directory: extract the block into a single shared function in that directory and call it from each site, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/policy/v2/compiled.go:278` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (11 lines × 2) hscontrol/policy/v2/types.go:2903— hscontrol/policy/v2/types.go:2903-2913 | hscontrol/policy/v2/types.go:2924-2934 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/policy/v2/types.go:2903` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) integration/tsic/tsic.go:599— integration/tsic/tsic.go:599-609 | integration/tsric/tsric.go:271-281 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `integration/tsic/tsic.go:599` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 2) hscontrol/api/v1/preauthkeys.go:222— hscontrol/api/v1/preauthkeys.go:222-235 | hscontrol/api/v1/preauthkeys.go:250-263 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/api/v1/preauthkeys.go:222` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) integration/dsic/dsic.go:255— integration/dsic/dsic.go:255-268 | integration/tsic/tsic.go:591-604 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `integration/dsic/dsic.go:255` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 2) integration/hsic/hsic.go:552— integration/hsic/hsic.go:552-565 | integration/tsic/tsic.go:499-512 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `integration/hsic/hsic.go:552` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (14 lines × 2) integration/tsic/tsic.go:551— integration/tsic/tsic.go:551-564 | integration/tsic/tsic.go:571-584 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `integration/tsic/tsic.go:551` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (15 lines × 2) hscontrol/api/v1/auth.go:90— hscontrol/api/v1/auth.go:90-104 | hscontrol/api/v1/nodes.go:482-497 — the copies sit in sibling files of one directory: extract the block into a single shared function in that directory and call it from each site, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/api/v1/auth.go:90` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15 lines × 2) hscontrol/policy/v2/types.go:1119— hscontrol/policy/v2/types.go:1119-1133 | hscontrol/policy/v2/types.go:2979-2993 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15 lines × 2) hscontrol/policy/v2/types.go:2385— hscontrol/policy/v2/types.go:2385-2399 | hscontrol/policy/v2/types.go:2625-2639 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/policy/v2/types.go:2385` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D38 · OSV Dependency Vulnerabilities· Medium vulnerability · ×2
Medium vulnerability: GO-2026-5841 go.mod— github.com/klauspost/compress 1.18.6 (github.com/klauspost/compress/s2): GO-2026-5841 — github.com/klauspost/compress is not a DIRECT requirement of this module: go.mod records it as `// indirect`, pulled in transitively, so raise it in place (run `go get github.com/klauspost/compress@v1.18.7`, which updates the require line go.mod already holds for it).
Medium vulnerability: GO-2026-5932 go.mod— golang.org/x/crypto 0.53.0 (golang.org/x/crypto/openpgp, golang.org/x/crypto/openpgp/packet, golang.org/x/crypto/openpgp/armor, +4 more): GO-2026-5932 — no fixed version has been published yet. Track the advisory, and remove or replace golang.org/x/crypto if the exposure is not acceptable until one lands. Before doing either, check whether any affected package above is actually linked here: `go list -deps ./... | grep -F -e golang.org/x/crypto/openpgp` lists it whether your own code imports it or a dependency pulls it in — a module can be in the build list for one sub-package while the vulnerable one is never reached, in which case there is nothing to remove and tracking the advisory is the whole action.
D38 · OSV Dependency Vulnerabilities· Medium CVE · ×2
Medium CVE: GO-2026-4961 go.mod— golang.org/x/image 0.41.0 (golang.org/x/image/webp): GO-2026-4961 — golang.org/x/image is not a DIRECT requirement of this module: go.mod records it as `// indirect`, pulled in transitively, so raise it in place (run `go get golang.org/x/image@v0.42.0`, which updates the require line go.mod already holds for it). This one row stands for the 4 advisories this scan raises against golang.org/x/image 0.41.0: GO-2026-4961, GO-2026-5061, GO-2026-5062, GO-2026-5066.
Medium CVE: GO-2026-5970 go.mod— golang.org/x/text 0.38.0 (golang.org/x/text/unicode/norm): GO-2026-5970 — golang.org/x/text is not a DIRECT requirement of this module: go.mod records it as `// indirect`, pulled in transitively, so raise it in place (run `go get golang.org/x/text@v0.39.0`, which updates the require line go.mod already holds for it).
Duplicated block (12 lines × 2) hscontrol/db/api_key.go:223— hscontrol/db/api_key.go:223-234 | hscontrol/db/api_key.go:252-263 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/db/api_key.go:223` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12 lines × 2) hscontrol/state/state.go:834— hscontrol/state/state.go:834-845 | hscontrol/state/state.go:869-880 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/state/state.go:834` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) hscontrol/app.go:642— hscontrol/app.go:642-655 | hscontrol/app.go:1012-1021 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/app.go:642` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) hscontrol/policy/v2/types.go:1196— hscontrol/policy/v2/types.go:1196-1205 | hscontrol/policy/v2/types.go:1281-1290 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) hscontrol/api/v1/nodes.go:429— hscontrol/api/v1/nodes.go:429-439 | hscontrol/api/v2/devices.go:393-401 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/api/v1/nodes.go:429` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) hscontrol/policy/v2/types.go:2617— hscontrol/policy/v2/types.go:2617-2625 | hscontrol/policy/v2/types.go:2673-2681 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/policy/v2/types.go:2617` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 2) hscontrol/state/state.go:2344— hscontrol/state/state.go:2344-2351 | hscontrol/state/state.go:2826-2833 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/state/state.go:2344` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) integration/scenario.go:371— integration/scenario.go:371-381 | integration/scenario.go:398-405 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `integration/scenario.go:371` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Policy.validate (cyclomatic 124) hscontrol/policy/v2/types.go:2328— Policy.validate has cyclomatic complexity 124 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
db.NewHeadscaleDatabase (cyclomatic 100) hscontrol/db/db.go:55— db.NewHeadscaleDatabase has cyclomatic complexity 100 (threshold 15). Most of this is not in the body itself: 9 of the 100 points are its own statements and the rest belongs to 22 function literals inside it that branch (lines 248, 606, 846, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
State.HandleNodeFromPreAuthKey (cyclomatic 60) hscontrol/state/state.go:2458— State.HandleNodeFromPreAuthKey has cyclomatic complexity 60 (threshold 15). Of this number, 45 points are the body's own statements and 15 belong to 3 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Policy.compileSSHPolicy (cyclomatic 47) hscontrol/policy/v2/filter.go:254— Policy.compileSSHPolicy has cyclomatic complexity 47 (threshold 15). Of this number, 41 points are the body's own statements and 6 belong to 2 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PolicyManager.ViaRoutesForPeer (cyclomatic 46) hscontrol/policy/v2/policy.go:1191— PolicyManager.ViaRoutesForPeer has cyclomatic complexity 46 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
main.runTestContainer (cyclomatic 40) cmd/hi/docker.go:38— main.runTestContainer has cyclomatic complexity 40 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
hsic.New (cyclomatic 38) integration/hsic/hsic.go:332— hsic.New has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Headscale.Serve (cyclomatic 37) hscontrol/app.go:516— Headscale.Serve has cyclomatic complexity 37 (threshold 15). Of this number, 26 points are the body's own statements and 11 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
tsic.New (cyclomatic 33) integration/tsic/tsic.go:326— tsic.New has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
State.UpdateNodeFromMapRequest (cyclomatic 32) hscontrol/state/state.go:3032— State.UpdateNodeFromMapRequest has cyclomatic complexity 32 (threshold 15). Most of this is not in the body itself: 10 of the 32 points are its own statements and the rest belongs to one function literal inside it that branches (line 3054). The decisions are inside the literal, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
integration.requireAllClientsOnlineWithSingleTimeout (cyclomatic 32) integration/helpers.go:197— integration.requireAllClientsOnlineWithSingleTimeout has cyclomatic complexity 32 (threshold 15). Most of this is not in the body itself: 1 of the 32 points is its own statement and the rest belongs to one function literal inside it that branches (line 204). The decisions are inside the literal, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
State.applyAuthNodeUpdate (cyclomatic 30) hscontrol/state/state.go:1688— State.applyAuthNodeUpdate has cyclomatic complexity 30 (threshold 15). Most of this is not in the body itself: 11 of the 30 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 1748, 1862). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
util.ParseTraceroute (cyclomatic 29) hscontrol/util/util.go:108— util.ParseTraceroute has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
AuthProviderOIDC.OIDCCallbackHandler (cyclomatic 26) hscontrol/oidc.go:222— AuthProviderOIDC.OIDCCallbackHandler has cyclomatic complexity 26 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
PolicyManager.SSHCheckParams (cyclomatic 26) hscontrol/policy/v2/policy.go:454— PolicyManager.SSHCheckParams has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
State.createAndSaveNewNode (cyclomatic 26) hscontrol/state/state.go:1890— State.createAndSaveNewNode has cyclomatic complexity 26 (threshold 15). Of this number, 22 points are the body's own statements and 4 belong to one function literal inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
types.validateServerConfig (cyclomatic 26) hscontrol/types/config.go:554— types.validateServerConfig has cyclomatic complexity 26 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Headscale.scheduledTasks (cyclomatic 25) hscontrol/app.go:270— Headscale.scheduledTasks has cyclomatic complexity 25 (threshold 15). Of this number, 22 points are the body's own statements and 3 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
NodeStore.applyBatch (cyclomatic 25) hscontrol/state/node_store.go:428— NodeStore.applyBatch has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
apiv2.registerKeys (cyclomatic 24) hscontrol/api/v2/keys.go:124— apiv2.registerKeys has cyclomatic complexity 24 (threshold 15). Most of this is not in the body itself: 1 of the 24 points is its own statement and the rest belongs to 4 function literals inside it that branch (lines 167, 262, 217, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
apiv2.registerDevices (cyclomatic 23) hscontrol/api/v2/devices.go:118— apiv2.registerDevices has cyclomatic complexity 23 (threshold 15). Most of this is not in the body itself: 1 of the 23 points is its own statement and the rest belongs to 9 function literals inside it that branch (lines 251, 297, 330, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
State.HandleNodeFromAuthPath (cyclomatic 23) hscontrol/state/state.go:2205— State.HandleNodeFromAuthPath has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
hscontrol.NewHeadscale (cyclomatic 22) hscontrol/app.go:111— hscontrol.NewHeadscale has cyclomatic complexity 22 (threshold 15). Of this number, 20 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
v2.validateUserReferences (cyclomatic 22) hscontrol/policy/v2/policy.go:105— v2.validateUserReferences has cyclomatic complexity 22 (threshold 15). Of this number, 16 points are the body's own statements and 6 belong to 4 function literals inside it that branch. To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
hsic.extractTarToDirectory (cyclomatic 22) integration/hsic/hsic.go:766— hsic.extractTarToDirectory has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
main.cleanupSuccessfulTestArtifacts (cyclomatic 21) cmd/hi/cleanup.go:339— main.cleanupSuccessfulTestArtifacts has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
apiv1.registerNodeWriteOps (cyclomatic 20) hscontrol/api/v1/nodes.go:247— apiv1.registerNodeWriteOps has cyclomatic complexity 20 (threshold 15). Most of this is not in the body itself: 1 of the 20 points is its own statement and the rest belongs to 4 function literals inside it that branch (lines 283, 370, 255, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
PolicyManager.BuildPeerMap (cyclomatic 20) hscontrol/policy/v2/policy.go:606— PolicyManager.BuildPeerMap has cyclomatic complexity 20 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
v2.resolveSSHTestDestNodes (cyclomatic 19) hscontrol/policy/v2/sshtest.go:411— v2.resolveSSHTestDestNodes has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
v2.validateSSHSrcDstCombination (cyclomatic 19) hscontrol/policy/v2/types.go:2146— v2.validateSSHSrcDstCombination has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PolicyManager.invalidateAutogroupSelfCache (cyclomatic 19) hscontrol/policy/v2/policy.go:1491— PolicyManager.invalidateAutogroupSelfCache has cyclomatic complexity 19 (threshold 15). Of this number, 15 points are the body's own statements and 4 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
mapSession.serveLongPoll (cyclomatic 19) hscontrol/poll.go:140— mapSession.serveLongPoll has cyclomatic complexity 19 (threshold 15). Of this number, 13 points are the body's own statements and 6 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
types.LoadServerConfig (cyclomatic 19) hscontrol/types/config.go:1110— types.LoadServerConfig has cyclomatic complexity 19 (threshold 15). Of this number, 18 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
integration.requireAllClientsOfflineStaged (cyclomatic 19) integration/helpers.go:377— integration.requireAllClientsOfflineStaged has cyclomatic complexity 19 (threshold 15). Most of this is not in the body itself: 1 of the 19 points is its own statement and the rest belongs to 3 function literals inside it that branch (lines 432, 406, 382). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
Headscale.handleRegister (cyclomatic 18) hscontrol/auth.go:38— Headscale.handleRegister has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
v2.evaluateAssertion (cyclomatic 18) hscontrol/policy/v2/sshtest.go:271— v2.evaluateAssertion has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PolicyManager.updateLocked (cyclomatic 18) hscontrol/policy/v2/policy.go:233— PolicyManager.updateLocked has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
HAHealthProber.ProbeOnce (cyclomatic 18) hscontrol/state/ha_health.go:71— HAHealthProber.ProbeOnce has cyclomatic complexity 18 (threshold 15). Of this number, 10 points are the body's own statements and 8 belong to 2 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Change.Merge (cyclomatic 18) hscontrol/types/change/change.go:68— Change.Merge has cyclomatic complexity 18 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
integration.NewScenario (cyclomatic 18) integration/scenario.go:182— integration.NewScenario has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
integration.doLoginURLWithClient (cyclomatic 18) integration/scenario.go:1154— integration.doLoginURLWithClient has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
apiv1.registerNodeAdminOps (cyclomatic 17) hscontrol/api/v1/nodes.go:410— apiv1.registerNodeAdminOps has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 1 of the 17 points is its own statement and the rest belongs to 4 function literals inside it that branch (lines 418, 468, 510, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
Batcher.worker (cyclomatic 17) hscontrol/mapper/batcher.go:469— Batcher.worker has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
main.listControlFiles (cyclomatic 16) cmd/hi/docker.go:601— main.listControlFiles has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
apiv1.registerPolicy (cyclomatic 16) hscontrol/api/v1/policy.go:55— apiv1.registerPolicy has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 1 of the 16 points is its own statement and the rest belongs to 3 function literals inside it that branch (lines 111, 63, 169). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
HSDatabase.BackfillNodeIPs (cyclomatic 16) hscontrol/db/ip.go:306— HSDatabase.BackfillNodeIPs has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 1 of the 16 points is its own statement and the rest belongs to one function literal inside it that branches (line 312). The decisions are inside the literal, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
v2.compileAutogroupSelf (cyclomatic 16) hscontrol/policy/v2/compiled.go:700— v2.compileAutogroupSelf has cyclomatic complexity 16 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Groups.UnmarshalJSON (cyclomatic 16) hscontrol/policy/v2/types.go:1314— Groups.UnmarshalJSON has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Policy.compileNodeAttrs (cyclomatic 16) hscontrol/policy/v2/compiled.go:145— Policy.compileNodeAttrs has cyclomatic complexity 16 (threshold 15). Of this number, 14 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Change.Type (cyclomatic 16) hscontrol/types/change/change.go:171— Change.Type has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
Scenario.ShutdownAssertNoPanics (cyclomatic 16) integration/scenario.go:359— Scenario.ShutdownAssertNoPanics has cyclomatic complexity 16 (threshold 15). Of this number, 14 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Scenario.createHeadscaleEnvWithTags (cyclomatic 16) integration/scenario.go:915— Scenario.createHeadscaleEnvWithTags has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Policy.validate (cognitive 284) hscontrol/policy/v2/types.go:2328— Policy.validate has cognitive complexity 284 (threshold 15). Drivers by points: if/else 205, loops 42, match/switch 35, boolean chains 2 (nesting depth added 184). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
db.NewHeadscaleDatabase (cognitive 147) hscontrol/db/db.go:55— db.NewHeadscaleDatabase has cognitive complexity 147 (threshold 15). Drivers by points: if/else 126, loops 18, boolean chains 3 (nesting depth added 47). Most of this is not in the body itself: 11 of the 147 points are its own statements and the rest belongs to 22 function literals inside it that branch (lines 606, 248, 846, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
PolicyManager.ViaRoutesForPeer (cognitive 124) hscontrol/policy/v2/policy.go:1191— PolicyManager.ViaRoutesForPeer has cognitive complexity 124 (threshold 15). Drivers by points: if/else 76, loops 41, boolean chains 7 (nesting depth added 78). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Policy.compileSSHPolicy (cognitive 114) hscontrol/policy/v2/filter.go:254— Policy.compileSSHPolicy has cognitive complexity 114 (threshold 15). Drivers by points: if/else 81, loops 23, boolean chains 8, match/switch 2 (nesting depth added 68). Of this number, 105 points are the body's own statements and 9 belong to 2 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
State.HandleNodeFromPreAuthKey (cognitive 78) hscontrol/state/state.go:2458— State.HandleNodeFromPreAuthKey has cognitive complexity 78 (threshold 15). Drivers by points: if/else 58, boolean chains 17, loops 3 (nesting depth added 28). Of this number, 52 points are the body's own statements and 26 belong to 3 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Headscale.Serve (cognitive 67) hscontrol/app.go:516— Headscale.Serve has cognitive complexity 67 (threshold 15). Drivers by points: if/else 62, loops 2, match/switch 2, boolean chains 1 (nesting depth added 28). Of this number, 36 points are the body's own statements and 31 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
util.ParseTraceroute (cognitive 64) hscontrol/util/util.go:108— util.ParseTraceroute has cognitive complexity 64 (threshold 15). Drivers by points: if/else 55, loops 7, boolean chains 2 (nesting depth added 35). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
hsic.New (cognitive 62) integration/hsic/hsic.go:332— hsic.New has cognitive complexity 62 (threshold 15). Drivers by points: if/else 51, loops 9, boolean chains 2 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
main.runTestContainer (cognitive 60) cmd/hi/docker.go:38— main.runTestContainer has cognitive complexity 60 (threshold 15). Drivers by points: if/else 49, boolean chains 8, loops 3 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
tsic.New (cognitive 60) integration/tsic/tsic.go:326— tsic.New has cognitive complexity 60 (threshold 15). Drivers by points: if/else 55, boolean chains 2, loops 2, match/switch 1 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
integration.requireAllClientsOnlineWithSingleTimeout (cognitive 58) integration/helpers.go:197— integration.requireAllClientsOnlineWithSingleTimeout has cognitive complexity 58 (threshold 15). Drivers by points: if/else 41, loops 13, boolean chains 4 (nesting depth added 25). Most of this is not in the body itself: 0 of the 58 points are its own statements and the rest belongs to one function literal inside it that branches (line 204). The decisions are inside the literal, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
main.cleanupSuccessfulTestArtifacts (cognitive 57) cmd/hi/cleanup.go:339— main.cleanupSuccessfulTestArtifacts has cognitive complexity 57 (threshold 15). Drivers by points: if/else 52, boolean chains 4, loops 1 (nesting depth added 35). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
NodeStore.applyBatch (cognitive 49) hscontrol/state/node_store.go:428— NodeStore.applyBatch has cognitive complexity 49 (threshold 15). Drivers by points: if/else 34, loops 12, match/switch 2, boolean chains 1 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Batcher.worker (cognitive 46) hscontrol/mapper/batcher.go:469— Batcher.worker has cognitive complexity 46 (threshold 15). Drivers by points: if/else 33, match/switch 6, loops 5, boolean chains 2 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
v2.resolveSSHTestDestNodes (cognitive 46) hscontrol/policy/v2/sshtest.go:411— v2.resolveSSHTestDestNodes has cognitive complexity 46 (threshold 15). Drivers by points: if/else 38, loops 6, boolean chains 2 (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
State.UpdateNodeFromMapRequest (cognitive 44) hscontrol/state/state.go:3032— State.UpdateNodeFromMapRequest has cognitive complexity 44 (threshold 15). Drivers by points: if/else 36, boolean chains 8 (nesting depth added 12). Most of this is not in the body itself: 12 of the 44 points are its own statements and the rest belongs to one function literal inside it that branches (line 3054). The decisions are inside the literal, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
v2.evaluateAssertion (cognitive 42) hscontrol/policy/v2/sshtest.go:271— v2.evaluateAssertion has cognitive complexity 42 (threshold 15). Drivers by points: if/else 31, match/switch 5, jumps 3, loops 3 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
hsic.extractTarToDirectory (cognitive 39) integration/hsic/hsic.go:766— hsic.extractTarToDirectory has cognitive complexity 39 (threshold 15). Drivers by points: if/else 33, boolean chains 2, loops 2, match/switch 2 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PolicyManager.SSHCheckParams (cognitive 38) hscontrol/policy/v2/policy.go:454— PolicyManager.SSHCheckParams has cognitive complexity 38 (threshold 15). Drivers by points: if/else 27, boolean chains 7, loops 4 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PolicyManager.invalidateAutogroupSelfCache (cognitive 37) hscontrol/policy/v2/policy.go:1491— PolicyManager.invalidateAutogroupSelfCache has cognitive complexity 37 (threshold 15). Drivers by points: if/else 34, loops 3 (nesting depth added 18). Of this number, 33 points are the body's own statements and 4 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Headscale.scheduledTasks (cognitive 36) hscontrol/app.go:270— Headscale.scheduledTasks has cognitive complexity 36 (threshold 15). Drivers by points: if/else 27, loops 5, boolean chains 2, match/switch 2 (nesting depth added 18). Of this number, 29 points are the body's own statements and 7 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Headscale.handleRegister (cognitive 36) hscontrol/auth.go:38— Headscale.handleRegister has cognitive complexity 36 (threshold 15). Drivers by points: if/else 34, boolean chains 2 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
main.waitForContainerFinalization (cognitive 35) cmd/hi/docker.go:351— main.waitForContainerFinalization has cognitive complexity 35 (threshold 15). Drivers by points: if/else 29, loops 4, match/switch 2 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
hscontrol.NewHeadscale (cognitive 35) hscontrol/app.go:111— hscontrol.NewHeadscale has cognitive complexity 35 (threshold 15). Drivers by points: if/else 32, loops 2, boolean chains 1 (nesting depth added 12). Of this number, 33 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
integration.requireAllClientsOfflineStaged (cognitive 35) integration/helpers.go:377— integration.requireAllClientsOfflineStaged has cognitive complexity 35 (threshold 15). Drivers by points: if/else 23, loops 9, boolean chains 3 (nesting depth added 16). Most of this is not in the body itself: 0 of the 35 points are its own statements and the rest belongs to 3 function literals inside it that branch (lines 432, 406, 382). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
integration.NewScenario (cognitive 34) integration/scenario.go:182— integration.NewScenario has cognitive complexity 34 (threshold 15). Drivers by points: if/else 26, loops 8 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
policyutil.reduceCapGrantRule (cognitive 32) hscontrol/policy/policyutil/reduce.go:90— policyutil.reduceCapGrantRule has cognitive complexity 32 (threshold 15). Drivers by points: if/else 20, loops 12 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
State.applyAuthNodeUpdate (cognitive 32) hscontrol/state/state.go:1688— State.applyAuthNodeUpdate has cognitive complexity 32 (threshold 15). Drivers by points: if/else 24, boolean chains 7, match/switch 1 (nesting depth added 3). Most of this is not in the body itself: 12 of the 32 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 1748, 1862). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
Scenario.createHeadscaleEnvWithTags (cognitive 32) integration/scenario.go:915— Scenario.createHeadscaleEnvWithTags has cognitive complexity 32 (threshold 15). Drivers by points: if/else 30, boolean chains 1, loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
apiv2.registerKeys (cognitive 31) hscontrol/api/v2/keys.go:124— apiv2.registerKeys has cognitive complexity 31 (threshold 15). Drivers by points: if/else 25, loops 4, boolean chains 2 (nesting depth added 8). Most of this is not in the body itself: 0 of the 31 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 167, 262, 217, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
TailscaleInContainer.WaitForPeers (cognitive 30) integration/tsic/tsic.go:1320— TailscaleInContainer.WaitForPeers has cognitive complexity 30 (threshold 15). Drivers by points: if/else 24, loops 4, match/switch 2 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ExtraRecordsMan.Run (cognitive 29) hscontrol/dns/extrarecords.go:80— ExtraRecordsMan.Run has cognitive complexity 29 (threshold 15). Drivers by points: if/else 23, match/switch 5, loops 1 (nesting depth added 19). Of this number, 25 points are the body's own statements and 4 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PolicyManager.BuildPeerMap (cognitive 29) hscontrol/policy/v2/policy.go:606— PolicyManager.BuildPeerMap has cognitive complexity 29 (threshold 15). Drivers by points: if/else 13, loops 10, boolean chains 6 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HAHealthProber.ProbeOnce (cognitive 29) hscontrol/state/ha_health.go:71— HAHealthProber.ProbeOnce has cognitive complexity 29 (threshold 15). Drivers by points: if/else 23, loops 4, match/switch 2 (nesting depth added 14). Most of this is not in the body itself: 14 of the 29 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 143, 95). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
types.validateServerConfig (cognitive 29) hscontrol/types/config.go:554— types.validateServerConfig has cognitive complexity 29 (threshold 15). Drivers by points: if/else 23, boolean chains 6 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
v2.validateUserReferences (cognitive 28) hscontrol/policy/v2/policy.go:105— v2.validateUserReferences has cognitive complexity 28 (threshold 15). Drivers by points: loops 20, if/else 6, boolean chains 2 (nesting depth added 7). Of this number, 22 points are the body's own statements and 6 belong to 4 function literals inside it that branch. To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Groups.UnmarshalJSON (cognitive 28) hscontrol/policy/v2/types.go:1314— Groups.UnmarshalJSON has cognitive complexity 28 (threshold 15). Drivers by points: if/else 14, loops 12, match/switch 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
State.createAndSaveNewNode (cognitive 28) hscontrol/state/state.go:1890— State.createAndSaveNewNode has cognitive complexity 28 (threshold 15). Drivers by points: if/else 22, boolean chains 6 (nesting depth added 4). Of this number, 23 points are the body's own statements and 5 belong to one function literal inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
State.HandleNodeFromAuthPath (cognitive 28) hscontrol/state/state.go:2205— State.HandleNodeFromAuthPath has cognitive complexity 28 (threshold 15). Drivers by points: if/else 22, boolean chains 5, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
mapSession.serveLongPoll (cognitive 27) hscontrol/poll.go:140— mapSession.serveLongPoll has cognitive complexity 27 (threshold 15). Drivers by points: if/else 22, loops 3, match/switch 2 (nesting depth added 12). Of this number, 18 points are the body's own statements and 9 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Scenario.CreateTailscaleNodesInUser (cognitive 27) integration/scenario.go:643— Scenario.CreateTailscaleNodesInUser has cognitive complexity 27 (threshold 15). Drivers by points: if/else 24, loops 2, boolean chains 1 (nesting depth added 15). Of this number, 21 points are the body's own statements and 6 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
db.runMigrations (cognitive 26) hscontrol/db/db.go:1160— db.runMigrations has cognitive complexity 26 (threshold 15). Drivers by points: if/else 21, loops 5 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HSDatabase.BackfillNodeIPs (cognitive 26) hscontrol/db/ip.go:306— HSDatabase.BackfillNodeIPs has cognitive complexity 26 (threshold 15). Drivers by points: if/else 21, boolean chains 4, loops 1 (nesting depth added 11). Most of this is not in the body itself: 0 of the 26 points are its own statements and the rest belongs to one function literal inside it that branches (line 312). The decisions are inside the literal, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
v2.compileAutogroupSelf (cognitive 26) hscontrol/policy/v2/compiled.go:700— v2.compileAutogroupSelf has cognitive complexity 26 (threshold 15). Drivers by points: loops 15, if/else 9, boolean chains 2 (nesting depth added 11). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Scenario.ShutdownAssertNoPanics (cognitive 26) integration/scenario.go:359— Scenario.ShutdownAssertNoPanics has cognitive complexity 26 (threshold 15). Drivers by points: if/else 18, loops 8 (nesting depth added 11). Of this number, 24 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StatsCollector.collectStatsForContainer (cognitive 25) cmd/hi/stats.go:231— StatsCollector.collectStatsForContainer has cognitive complexity 25 (threshold 15). Drivers by points: if/else 20, boolean chains 2, match/switch 2, loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
apiv2.registerDevices (cognitive 25) hscontrol/api/v2/devices.go:118— apiv2.registerDevices has cognitive complexity 25 (threshold 15). Drivers by points: if/else 22, loops 3 (nesting depth added 3). Most of this is not in the body itself: 0 of the 25 points are its own statements and the rest belongs to 9 function literals inside it that branch (lines 251, 297, 330, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
AuthProviderOIDC.OIDCCallbackHandler (cognitive 25) hscontrol/oidc.go:222— AuthProviderOIDC.OIDCCallbackHandler has cognitive complexity 25 (threshold 15). Drivers by points: if/else 23, boolean chains 2 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
v2.validateSSHSrcDstCombination (cognitive 25) hscontrol/policy/v2/types.go:2146— v2.validateSSHSrcDstCombination has cognitive complexity 25 (threshold 15). Drivers by points: if/else 16, match/switch 4, boolean chains 3, loops 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
cli.nodesToPtables (cognitive 24) cmd/headscale/cli/nodes.go:341— cli.nodesToPtables has cognitive complexity 24 (threshold 15). Drivers by points: if/else 19, loops 3, boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
main.listControlFiles (cognitive 24) cmd/hi/docker.go:601— main.listControlFiles has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11, loops 7, boolean chains 3, match/switch 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
main.getCurrentTestContainers (cognitive 24) cmd/hi/docker.go:709— main.getCurrentTestContainers has cognitive complexity 24 (threshold 15). Drivers by points: if/else 19, loops 4, boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Policy.compileNodeAttrs (cognitive 24) hscontrol/policy/v2/compiled.go:145— Policy.compileNodeAttrs has cognitive complexity 24 (threshold 15). Drivers by points: if/else 14, loops 9, boolean chains 1 (nesting depth added 9). Of this number, 22 points are the body's own statements and 2 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
State.RoutesForPeer (cognitive 24) hscontrol/state/state.go:1244— State.RoutesForPeer has cognitive complexity 24 (threshold 15). Drivers by points: if/else 16, loops 6, boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
policyutil.ReduceFilterRules (cognitive 23) hscontrol/policy/policyutil/reduce.go:19— policyutil.ReduceFilterRules has cognitive complexity 23 (threshold 15). Drivers by points: if/else 19, loops 3, boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
v2.parsePortRange (cognitive 23) hscontrol/policy/v2/utils.go:86— v2.parsePortRange has cognitive complexity 23 (threshold 15). Drivers by points: if/else 22, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HeadscaleInContainer.SaveDatabase (cognitive 23) integration/hsic/hsic.go:884— HeadscaleInContainer.SaveDatabase has cognitive complexity 23 (threshold 15). Drivers by points: if/else 22, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
apiv2.createAuthKey (cognitive 22) hscontrol/api/v2/keys.go:322— apiv2.createAuthKey has cognitive complexity 22 (threshold 15). Drivers by points: if/else 18, loops 3, match/switch 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
v2.groupSourcesByUser (cognitive 22) hscontrol/policy/v2/filter.go:533— v2.groupSourcesByUser has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12, loops 9, boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
tsric.New (cognitive 22) integration/tsric/tsric.go:151— tsric.New has cognitive complexity 22 (threshold 15). Drivers by points: if/else 20, loops 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
db.openDB (cognitive 21) hscontrol/db/db.go:1054— db.openDB has cognitive complexity 21 (threshold 15). Drivers by points: if/else 20, match/switch 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
v2.resolveAutoApprovers (cognitive 21) hscontrol/policy/v2/types.go:1523— v2.resolveAutoApprovers has cognitive complexity 21 (threshold 15). Drivers by points: if/else 15, loops 6 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SSHPolicyTestResults.Errors (cognitive 21) hscontrol/policy/v2/sshtest.go:47— SSHPolicyTestResults.Errors has cognitive complexity 21 (threshold 15). Drivers by points: loops 18, if/else 3 (nesting depth added 11). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
integration.doLoginURLWithClient (cognitive 21) integration/scenario.go:1154— integration.doLoginURLWithClient has cognitive complexity 21 (threshold 15). Drivers by points: if/else 18, boolean chains 3 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
apiv1.registerNodeWriteOps (cognitive 20) hscontrol/api/v1/nodes.go:247— apiv1.registerNodeWriteOps has cognitive complexity 20 (threshold 15). Drivers by points: if/else 17, boolean chains 1, loops 1, match/switch 1 (nesting depth added 2). Most of this is not in the body itself: 0 of the 20 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 283, 370, 255, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
apiv2.createOAuthClient (cognitive 20) hscontrol/api/v2/keys.go:398— apiv2.createOAuthClient has cognitive complexity 20 (threshold 15). Drivers by points: if/else 15, loops 4, boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
mapper.ReadMapResponsesFromDirectory (cognitive 20) hscontrol/mapper/mapper.go:576— mapper.ReadMapResponsesFromDirectory has cognitive complexity 20 (threshold 15). Drivers by points: if/else 16, loops 3, boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
v2.resolveTagOwners (cognitive 20) hscontrol/policy/v2/policy.go:1716— v2.resolveTagOwners has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9, loops 8, match/switch 3 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Policy.compileOtherDests (cognitive 20) hscontrol/policy/v2/compiled.go:487— Policy.compileOtherDests has cognitive complexity 20 (threshold 15). Drivers by points: if/else 13, loops 6, boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
util.ParseIPSet (cognitive 20) hscontrol/util/addr.go:26— util.ParseIPSet has cognitive complexity 20 (threshold 15). Drivers by points: if/else 17, loops 2, boolean chains 1 (nesting depth added 7). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
cli.initConfig (cognitive 19) cmd/headscale/cli/root.go:42— cli.initConfig has cognitive complexity 19 (threshold 15). Drivers by points: if/else 15, boolean chains 4 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
main.cleanOldImages (cognitive 19) cmd/hi/cleanup.go:253— main.cleanOldImages has cognitive complexity 19 (threshold 15). Drivers by points: if/else 14, loops 3, boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
apiv1.registerNodeAdminOps (cognitive 19) hscontrol/api/v1/nodes.go:410— apiv1.registerNodeAdminOps has cognitive complexity 19 (threshold 15). Drivers by points: if/else 17, boolean chains 1, loops 1 (nesting depth added 2). Most of this is not in the body itself: 0 of the 19 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 418, 468, 510, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
IPAllocator.next (cognitive 19) hscontrol/db/ip.go:184— IPAllocator.next has cognitive complexity 19 (threshold 15). Drivers by points: if/else 14, match/switch 3, boolean chains 1, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
v2.compileViaForNode (cognitive 19) hscontrol/policy/v2/compiled.go:828— v2.compileViaForNode has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10, loops 8, boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
v2.aclToGrants (cognitive 19) hscontrol/policy/v2/types.go:1900— v2.aclToGrants has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10, loops 7, boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Policy.destinationsToNetPortRange (cognitive 19) hscontrol/policy/v2/filter.go:140— Policy.destinationsToNetPortRange has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10, loops 9 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
types.LoadServerConfig (cognitive 19) hscontrol/types/config.go:1110— types.LoadServerConfig has cognitive complexity 19 (threshold 15). Drivers by points: if/else 15, boolean chains 3, match/switch 1 (nesting depth added 2). Of this number, 18 points are the body's own statements and 1 belongs to one function literal inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
Scenario.RunTailscaleUpWithURL (cognitive 19) integration/scenario.go:988— Scenario.RunTailscaleUpWithURL has cognitive complexity 19 (threshold 15). Drivers by points: if/else 15, loops 4 (nesting depth added 11). Of this number, 10 points are the body's own statements and 9 belong to one function literal inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StatsCollector.monitorDockerEvents (cognitive 18) cmd/hi/stats.go:137— StatsCollector.monitorDockerEvents has cognitive complexity 18 (threshold 15). Drivers by points: if/else 14, match/switch 2, boolean chains 1, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
apiv1.registerPolicy (cognitive 18) hscontrol/api/v1/policy.go:55— apiv1.registerPolicy has cognitive complexity 18 (threshold 15). Drivers by points: if/else 17, match/switch 1 (nesting depth added 4). Most of this is not in the body itself: 0 of the 18 points are its own statements and the rest belongs to 3 function literals inside it that branch (lines 111, 63, 169). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
Batcher.addToBatch (cognitive 18) hscontrol/mapper/batcher.go:593— Batcher.addToBatch has cognitive complexity 18 (threshold 15). Drivers by points: if/else 13, loops 4, boolean chains 1 (nesting depth added 7). Of this number, 12 points are the body's own statements and 6 belong to 2 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
v2.validateTests (cognitive 18) hscontrol/policy/v2/types.go:3197— v2.validateTests has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11, loops 5, boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PolicyManager.userMatchesOwner (cognitive 18) hscontrol/policy/v2/policy.go:1068— PolicyManager.userMatchesOwner has cognitive complexity 18 (threshold 15). Drivers by points: if/else 14, loops 2, boolean chains 1, match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
state.electPrimaryRoutes (cognitive 18) hscontrol/state/node_store.go:699— state.electPrimaryRoutes has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12, loops 4, boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
State.DebugOverviewJSON (cognitive 18) hscontrol/state/debug.go:290— State.DebugOverviewJSON has cognitive complexity 18 (threshold 15). Drivers by points: if/else 14, boolean chains 3, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
State.findExistingNodeForPAK (cognitive 18) hscontrol/state/state.go:2398— State.findExistingNodeForPAK has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11, boolean chains 3, loops 2, match/switch 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
dsic.New (cognitive 18) integration/dsic/dsic.go:140— dsic.New has cognitive complexity 18 (threshold 15). Drivers by points: if/else 15, loops 2, match/switch 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
main.createDockerClient (cognitive 17) cmd/hi/docker.go:453— main.createDockerClient has cognitive complexity 17 (threshold 15). Drivers by points: if/else 17 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
db.RegisterNodeForTest (cognitive 17) hscontrol/db/node.go:261— db.RegisterNodeForTest has cognitive complexity 17 (threshold 15). Drivers by points: if/else 16, boolean chains 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
servertest.AssertConsistentState (cognitive 17) hscontrol/servertest/assertions.go:71— servertest.AssertConsistentState has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11, loops 5, boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Node.CanAccessRoute (cognitive 17) hscontrol/types/node.go:432— Node.CanAccessRoute has cognitive complexity 17 (threshold 15). Drivers by points: if/else 12, boolean chains 4, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
apiv1.registerUsers (cognitive 16) hscontrol/api/v1/users.go:65— apiv1.registerUsers has cognitive complexity 16 (threshold 15). Drivers by points: if/else 15, loops 1 (nesting depth added 2). Most of this is not in the body itself: 0 of the 16 points are its own statements and the rest belongs to 4 function literals inside it that branch (lines 172, 73, 108, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
apiv2.registerACL (cognitive 16) hscontrol/api/v2/acl.go:53— apiv2.registerACL has cognitive complexity 16 (threshold 15). Drivers by points: if/else 16 (nesting depth added 3). Most of this is not in the body itself: 0 of the 16 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 93, 64). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
Headscale.waitForFollowup (cognitive 16) hscontrol/auth.go:302— Headscale.waitForFollowup has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11, match/switch 5 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
mapper.generateMapResponse (cognitive 16) hscontrol/mapper/batcher.go:73— mapper.generateMapResponse has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11, boolean chains 3, loops 2 (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
mapper.buildFromChange (cognitive 16) hscontrol/mapper/mapper.go:367— mapper.buildFromChange has cognitive complexity 16 (threshold 15). Drivers by points: if/else 15, boolean chains 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
PolicyManager.updateLocked (cognitive 16) hscontrol/policy/v2/policy.go:233— PolicyManager.updateLocked has cognitive complexity 16 (threshold 15). Drivers by points: if/else 13, boolean chains 3. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Unpinned build actions — CI references GitHub Actions by a floating ref (@main / @tag) rather than a pinned commit SHA, weakening build integrity. 2 floating ref(s) across 1 workflow file(s), 2 of them mutable BRANCH refs — pin those first. Each floating ref is itemized at file:line by the SAST (D29) lens.
D36 · Supply-chain Provenance & Signing· PR-triggered workflow without a permissions block · ×1
PR-triggered workflow without a permissions block — 4 workflow(s) triggered by pull_request declare no `permissions:` block (test-integration.yaml, docs-test.yml, check-tests.yaml …) and so run with the repository's default GITHUB_TOKEN scope, while 10 sibling workflows in the same repository are already scoped. Pull-request runs build the least-trusted code in the repository; give each of these workflows its own least-privilege block — `permissions: {contents: read}` at the top of the workflow, widened per job only where a job genuinely writes.
Duplicated block (18 lines × 2) hscontrol/policy/v2/types.go:2345— hscontrol/policy/v2/types.go:2345-2362 | hscontrol/policy/v2/types.go:2584-2601 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/policy/v2/types.go:2345` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) integration/integrationutil/util.go:162— integration/integrationutil/util.go:162-177 | integration/integrationutil/util.go:203-218 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (15 lines × 4) hscontrol/policy/v2/types.go:2463— hscontrol/policy/v2/types.go:2463-2477 | hscontrol/policy/v2/types.go:2734-2748 | hscontrol/policy/v2/types.go:2761-2775 | hscontrol/policy/v2/types.go:2781-2795 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/policy/v2/types.go:2463` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) hscontrol/policy/v2/types.go:274— hscontrol/policy/v2/types.go:274-280 | hscontrol/policy/v2/types.go:992-998 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/policy/v2/types.go:274` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) hscontrol/state/state.go:1833— hscontrol/state/state.go:1833-1838 | hscontrol/state/state.go:1993-1998 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `hscontrol/state/state.go:1833` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Low: missing-ssl-minversion cmd/headscale/cli/oauth_client.go:213— `MinVersion` is missing from this TLS configuration. By default, as of Go 1.22, TLS 1.2 is currently used as the minimum. Set `MinVersion` EXPLICITLY so the floor is a decision in your code rather than whatever the toolchain currently defaults to. Which version depends on who the peer is: for a server, or for a client that talks only to endpoints you control, `tls.VersionTLS13`; for a client that must reach third-party servers (a package registry, a webhook target, an on-prem service), `tls.VersionTLS12` — pinning 1.3 there refuses to connect to peers that still terminate at 1.2. This is a semgrep security-AUDIT rule: it reports that a sensitive pattern is present, not that it is exploitable here. Confirm whether the flagged value reaches a security decision — a credential, token, nonce, key, salt or session id, or an externally reachable surface — and apply the change where it does; where it provably does not (cosmetic, simulation, or deliberately reproducible use), record the review and leave the code as it is.
Low: missing-ssl-minversion cmd/headscale/cli/utils.go:262— `MinVersion` is missing from this TLS configuration. By default, as of Go 1.22, TLS 1.2 is currently used as the minimum. Set `MinVersion` EXPLICITLY so the floor is a decision in your code rather than whatever the toolchain currently defaults to. Which version depends on who the peer is: for a server, or for a client that talks only to endpoints you control, `tls.VersionTLS13`; for a client that must reach third-party servers (a package registry, a webhook target, an on-prem service), `tls.VersionTLS12` — pinning 1.3 there refuses to connect to peers that still terminate at 1.2. This is a semgrep security-AUDIT rule: it reports that a sensitive pattern is present, not that it is exploitable here. Confirm whether the flagged value reaches a security decision — a credential, token, nonce, key, salt or session id, or an externally reachable surface — and apply the change where it does; where it provably does not (cosmetic, simulation, or deliberately reproducible use), record the review and leave the code as it is.
Low: cookie-missing-httponly hscontrol/oidc.go:946— A session cookie was detected without setting the 'HttpOnly' flag. The 'HttpOnly' flag for cookies instructs the browser to forbid client-side scripts from reading the cookie which mitigates XSS attacks. Set the 'HttpOnly' flag by setting 'HttpOnly' to 'true' in the Cookie. This is a semgrep security-AUDIT rule: it reports that a sensitive construct is present, not that it is exploitable here. Confirm whether this site handles untrusted input or is reachable across a trust boundary — and apply the change where it is; where the construct is required by the platform or protocol it calls into, and carries no untrusted data (a syscall/FFI shim, a build- or debug-gated tool, a fixed local surface), record the review and leave the code as it is.
Low: cookie-missing-secure hscontrol/oidc.go:946— A session cookie was detected without setting the 'Secure' flag. The 'secure' flag for cookies prevents the client from transmitting the cookie over insecure channels such as HTTP. Set the cookie's Secure flag on the cookie value your language's API exposes — and set it to a condition, not a constant, where the same handler also serves plaintext requests. This is a semgrep security-AUDIT rule: it reports that a sensitive construct is present, not that it is exploitable here. Confirm whether this site handles untrusted input or is reachable across a trust boundary — and apply the change where it is; where the construct is required by the platform or protocol it calls into, and carries no untrusted data (a syscall/FFI shim, a build- or debug-gated tool, a fixed local surface), record the review and leave the code as it is.
Low: missing-ssl-minversion integration/dsic/dsic.go:345— `MinVersion` is missing from this TLS configuration. By default, as of Go 1.22, TLS 1.2 is currently used as the minimum. Set `MinVersion` EXPLICITLY so the floor is a decision in your code rather than whatever the toolchain currently defaults to. Which version depends on who the peer is: for a server, or for a client that talks only to endpoints you control, `tls.VersionTLS13`; for a client that must reach third-party servers (a package registry, a webhook target, an on-prem service), `tls.VersionTLS12` — pinning 1.3 there refuses to connect to peers that still terminate at 1.2. This is a semgrep security-AUDIT rule: it reports that a sensitive pattern is present, not that it is exploitable here. Confirm whether the flagged value reaches a security decision — a credential, token, nonce, key, salt or session id, or an externally reachable surface — and apply the change where it does; where it provably does not (cosmetic, simulation, or deliberately reproducible use), record the review and leave the code as it is.
Low: missing-ssl-minversion integration/hsic/hsic.go:1163— `MinVersion` is missing from this TLS configuration. By default, as of Go 1.22, TLS 1.2 is currently used as the minimum. Set `MinVersion` EXPLICITLY so the floor is a decision in your code rather than whatever the toolchain currently defaults to. Which version depends on who the peer is: for a server, or for a client that talks only to endpoints you control, `tls.VersionTLS13`; for a client that must reach third-party servers (a package registry, a webhook target, an on-prem service), `tls.VersionTLS12` — pinning 1.3 there refuses to connect to peers that still terminate at 1.2. This is a semgrep security-AUDIT rule: it reports that a sensitive pattern is present, not that it is exploitable here. Confirm whether the flagged value reaches a security decision — a credential, token, nonce, key, salt or session id, or an externally reachable surface — and apply the change where it does; where it provably does not (cosmetic, simulation, or deliberately reproducible use), record the review and leave the code as it is.
Low: missing-ssl-minversion integration/scenario.go:1380— `MinVersion` is missing from this TLS configuration. By default, as of Go 1.22, TLS 1.2 is currently used as the minimum. Set `MinVersion` EXPLICITLY so the floor is a decision in your code rather than whatever the toolchain currently defaults to. Which version depends on who the peer is: for a server, or for a client that talks only to endpoints you control, `tls.VersionTLS13`; for a client that must reach third-party servers (a package registry, a webhook target, an on-prem service), `tls.VersionTLS12` — pinning 1.3 there refuses to connect to peers that still terminate at 1.2. This is a semgrep security-AUDIT rule: it reports that a sensitive pattern is present, not that it is exploitable here. Confirm whether the flagged value reaches a security decision — a credential, token, nonce, key, salt or session id, or an externally reachable surface — and apply the change where it does; where it provably does not (cosmetic, simulation, or deliberately reproducible use), record the review and leave the code as it is.
Low IaC: DS-0026 Dockerfile.integration— No HEALTHCHECK defined Without one the runtime only knows whether the process is alive, not whether it is serving, so a wedged container is restarted by nobody. The step: add a `HEALTHCHECK` to the image that probes the service the way a client would — this image already declares `EXPOSE 8080`, so a request to `localhost:8080` on the service's own health or root route, exiting non-zero when it does not answer, is the probe — and give it an `--interval`, a `--timeout` and a `--start-period` long enough to cover startup. If the image ships no HTTP client, probe with whatever the runtime already has, or declare the check in the orchestrator instead and say so here.
Low IaC: DS-0026 Dockerfile.integration-ci— No HEALTHCHECK defined Without one the runtime only knows whether the process is alive, not whether it is serving, so a wedged container is restarted by nobody. The step: add a `HEALTHCHECK` to the image that probes the service the way a client would — this image already declares `EXPOSE 8080`, so a request to `localhost:8080` on the service's own health or root route, exiting non-zero when it does not answer, is the probe — and give it an `--interval`, a `--timeout` and a `--start-period` long enough to cover startup. If the image ships no HTTP client, probe with whatever the runtime already has, or declare the check in the orchestrator instead and say so here.
D11 · Test Reliability· Test reliability not included · ×1
Test reliability not included — Test source is present (.go) but the built-in reliability runner does not support this repository's ecosystem, so flakiness couldn't be assessed. Not scored — this is a gap in the analyzer's language coverage, not a finding about this repository.
Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 85 significant file(s) lose their only recent owner: hscontrol/state/state.go, hscontrol/policy/v2/types.go, hscontrol/policy/v2/policy.go, integration/tsic/tsic.go, integration/hsic/hsic.go, integration/scenario.go, integration/helpers.go, hscontrol/types/node.go (+77 more). Pair on, review, or document these before any departure.
No build provenance — No SLSA provenance generation or build attestation found in CI — nothing binds a released artifact to the build that produced it, so a consumer cannot tell your artifact from a substituted one. On GitHub Actions, `actions/attest-build-provenance` (or slsa-github-generator) emits one from the job's own OIDC identity; elsewhere, run `cosign attest` over the released artifact from the release pipeline and publish the attestation beside it.
No artifact signing — No artifact signing found in CI — sign your released artifacts with whatever your ecosystem ships (a GPG/minisign detached signature — or `cosign sign-blob` — over the release archives, or over a checksum file published alongside them, a `signs:` block in `.goreleaser.yml` (cosign keyless or GPG over the checksums file), which GoReleaser then runs for every release artifact, `rpmsign --addsign` for RPMs / `debsign` plus a signed apt `Release.gpg` for DEBs) so consumers can verify what you built.
D36 · Supply-chain Provenance & Signing· No SBOM · ×1
No SBOM — No SBOM generation or committed SBOM found — produce one with what your ecosystem ships (an `sboms:` block in `.goreleaser.yml`, which GoReleaser runs on the release you already cut and attaches the document beside the artifacts, `cyclonedx-gomod` over the module graph — or Go's own build info, which already records the module set in the binary, `syft` (or `anchore/sbom-action` in CI) over the source tree or released image). Publish it as a release asset (`*.spdx.json` / `*.cdx.json`) so consumers can see what they are installing.
Coverage not included — suite not readable by the collector — Coverage NOT MEASURED: test source is present (.go) but the built-in coverage collector has no runner for this repository's ecosystem — so this suite was never executed by it. Not scored — this is a gap in the analyzer's language coverage, not a defect in the repo. To have real coverage read, produce a coverage report in a standard format (`go test -coverprofile=coverage.out ./...`) into the repo working tree before the scan — a CI step is the usual place, since the artefact is commonly gitignored.
Info — 2 finding(s)
D12 · Dependency Hygiene· Dependency hygiene not measured · ×1
Dependency hygiene not measured — dependency manifest found but not parsed for hygiene — This repository's dependency manifests (a Go module (go.mod/go.sum) and a Python pyproject.toml/requirements.txt (pip/uv/Poetry)) were found, but this pass cannot parse them for hygiene, so no package was assessed. Zero packages read is NOT a clean dependency tree, so this is NOT SCORED — a gap in the analyzer, not a verdict about this repository. This row is about dependency HYGIENE — outdated, deprecated or unmaintained direct dependencies; known CVEs in the same dependency graph are a separate question, reported under D38 wherever the manifest is OSV-readable.
D22 · Internal API Consistency· No exposed public API · ×1
No exposed public API — No intentionally-exposed types (IsPackable or .Contracts) to evaluate.
Appendix B — Reproduction & audit trail
Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.
trivy: not applicable — No JS/npm manifest or lockfile found outside build output (package.json, package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb); no JS dependencies to scan.
disclosure: not applicable — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
0
—
Run 019fd5c0-71f2-7dd2-9a41-7e342acfa5f5 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Issues: 10 · Warnings: 222 · Recommendations: 15 · Info: 2 — Appendix A · all findings · full markdown report.
Generated by Watchdog — deterministic code-health analysis. 06-08-2026 @ 06:26 UTC.
Downloadable artifacts
Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.