Skip to content

fix(scoring): clamp fraction scorers to [0, 1]#364

Open
TBX3D wants to merge 4 commits into
vmfunc:mainfrom
TBX3D:fix/scoring-fraction-clamp
Open

fix(scoring): clamp fraction scorers to [0, 1]#364
TBX3D wants to merge 4 commits into
vmfunc:mainfrom
TBX3D:fix/scoring-fraction-clamp

Conversation

@TBX3D

@TBX3D TBX3D commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

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.

@TBX3D
TBX3D requested a review from vmfunc as a code owner July 10, 2026 00:11
@codecov-commenter

codecov-commenter commented Jul 10, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 78.40000% with 27 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@7ea1cd2). Learn more about missing BASE report.

Files with missing lines Patch % Lines
internal/modules/fingerprint.go 81.91% 9 Missing and 8 partials ⚠️
internal/sifpath/sifpath.go 42.85% 2 Missing and 2 partials ⚠️
internal/httpx/httpx.go 0.00% 2 Missing ⚠️
internal/modules/loader.go 33.33% 1 Missing and 1 partial ⚠️
internal/modules/yaml.go 71.42% 1 Missing and 1 partial ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #364   +/-   ##
=======================================
  Coverage        ?   55.14%           
=======================================
  Files           ?       83           
  Lines           ?     6981           
  Branches        ?        0           
=======================================
  Hits            ?     3850           
  Misses          ?     2853           
  Partials        ?      278           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot added size/xl 500+ lines changed scan changes to scan engine modules changes to scan modules docs documentation changes tests test changes labels Jul 10, 2026
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

pr summary

16 files changed (+799 -47)

category files
go source 15
tests 5

TBX3D added 4 commits July 9, 2026 19:59
the modules loader and the framework custom-signature loader each
hand-rolled the same ~/.config/sif/<sub> (and %LocalAppData%\sif\<sub>
on windows) path. extract internal/sifpath.UserSubdir and route both
through it so the per-user layout is defined in one place.

no behavior change: the helper reproduces the existing paths exactly.
the frameworks detector and the module executor each defined their own
5 MB body cap and ran the same io.ReadAll(io.LimitReader(...)) read. move
the cap and the read into httpx.MaxBodySize / httpx.ReadCappedBody so both
scanners share one ceiling instead of two consts that can drift.

no behavior change: the cap value and read semantics are unchanged.
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.
@TBX3D
TBX3D force-pushed the fix/scoring-fraction-clamp branch from c5b01fa to 9eb7a02 Compare July 10, 2026 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs documentation changes modules changes to scan modules scan changes to scan engine size/xl 500+ lines changed tests test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants