Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #364 +/- ##
=======================================
Coverage ? 65.11%
=======================================
Files ? 89
Lines ? 7967
Branches ? 0
=======================================
Hits ? 5188
Misses ? 2377
Partials ? 402 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
pr summary9 files changed (+669 -16)
|
c5b01fa to
9eb7a02
Compare
a `fingerprint` module identifies a technology by weighted body/header signatures scored into a confidence, with an optional version regex, rather than a boolean match. it fires one finding carrying the score once it reaches the threshold (default 0.5). this is the framework detectors' scoring in the module format, so a custom tech fingerprint lives alongside other modules. validated at load (signatures present, non-empty patterns, finite weights, confidence in [0,1], version regex compiles) and covered by yaml round-trip, validation, header, version and default-threshold tests. documented in docs/modules.md. shares the response body cap via httpx.ReadCappedBody.
scoreFingerprint and MatchSignatures divide matched weight by total weight with no bound on the result. validation rejects negative weights on real configs, but the math itself has no invariant, so any caller that skips validation gets a score outside [0, 1] used directly as reported confidence. clamp both to guard the pathological path; normal validated inputs already fall inside [0, 1] and are unaffected.
9eb7a02 to
7a4d3e1
Compare
|
rebased onto the updated #356. no content change. |
|
the clamp is exactly right - nan guard, no-op on already-valid scores, good tests. but the diff isn't a scoring fix, it's the whole fingerprint type, because it was stacked on #356 (just merged). rebase onto main and it shrinks to just the clamp + MatchSignatures bit - one-click merge. also clampUnit is copy-pasted across two packages, pull it into a shared helper before it spreads. Generated by Claude Code |
There was a problem hiding this comment.
Reviewed head 7a4d3e1. Since #356 merged, the diff against main is just the clamp (4 files, +176/-2). CI is green, and the branch merges into main without conflicts.
Correctness: the clamp works. The NaN check comes before the ordered comparisons, it's a no-op inside [0, 1], and it also covers Inf/Inf → NaN → 0. The tests cover >1, <0, NaN, and the no-op case for both scorers.
Actionable:
- Duplicated helper.
clampUnitappears twice, ininternal/modules/fingerprint.goandinternal/scan/frameworks/detector.go, with almost the same doc comments. The maintainer asked for this too. Neither package imports the other, so put it in a small shared package (e.g.internal/scoringwithfunc ClampUnit(f float32) float32) and call it from both. That also lets you merge the two NaN tests into one table-driven unit test in that package. The scorer-level tests can stay as integration checks. - Optional: in
fingerprint.go, the version branch is gated onscore > 0. After the clamp, a NaN score becomes 0 and skips version extraction. That's the right behavior, but a one-line assertion inTestScoreFingerprintClampsNaNWeightthat the returned version is""would lock it in.
Merge status: the only approval (2026-07-22) was given before the latest commit (2026-07-23), so it needs a fresh maintainer approval on the current head before merging.
| // guards a caller that feeds MatchSignatures a negative or NaN weight. NaN | ||
| // needs its own check: every ordered comparison against NaN is false, so | ||
| // the < 0 and > 1 checks below would silently let it through otherwise. | ||
| func clampUnit(f float32) float32 { |
There was a problem hiding this comment.
This is a copy of clampUnit in internal/modules/fingerprint.go. Suggest moving it to a shared package (e.g. internal/scoring.ClampUnit) and calling it from both scorers so the NaN handling can't drift between them.
a fraction scorer could return a value outside 0-1 depending on input distribution, which then propagated into downstream weighted sums. clamp at the source instead of trusting every caller to bound it.