Skip to content

fix: add strict parsers, FailOn zero-value fix, Finding validation, scorecard - #27

Merged
Patel230 merged 6 commits into
mainfrom
fix/audit-sweep-2026-08
Aug 16, 2026
Merged

fix: add strict parsers, FailOn zero-value fix, Finding validation, scorecard#27
Patel230 merged 6 commits into
mainfrom
fix/audit-sweep-2026-08

Conversation

@Patel230

Copy link
Copy Markdown
Contributor

Summary

Deep code-quality audit fixes for hawk-core-contracts:

  • Strict severity/phase parsersParseSeverityStrict and ParsePhaseStrict reject unknown values with a descriptive error; existing ParseSeverity/ParsePhase are deprecated (fail-open to lowest severity)
  • FailOn zero-value trapreview.Result.Failed() and verify.Report.Failed() no longer treat an unset FailOn (zero = SeverityInfo) as "fail on any finding"; the effective default is now SeverityCritical. Add SetFailOn()/FailOnSet to both structs
  • Finding validationtypes.Finding.Validate() and review.Finding.Validate() enforce non-blank Message, non-negative Line, Confidence ∈ [0,1]
  • Stats.LLMErrors — additive field on review.Stats for non-fatal provider errors
  • Scorecard workflow — OSSF scorecard CI, matching yaad/sight/inspect

All workspace consumers grep-checked — no caller relied on zero-value fail-on-info semantics.

Test plan

  • go build ./...
  • go test ./... (59 PASS, 0 FAIL)
  • make boundaries

ParseSeverity and ParsePhase fail open: unknown input silently maps to
SeverityInfo / PhaseUnknown, so a typo like "critcal" is indistinguishable
from a legitimate value when the input is untrusted.

Add ParseSeverityStrict and ParsePhaseStrict (same matching rules, but a
descriptive error for unknown input) and mark the lenient parsers
Deprecated so callers handling untrusted input migrate.
Result.Failed treated an unset FailOn (zero value SeverityInfo) as
"fail on any finding", so a review result assembled without an explicit
threshold failed on informational findings. Add a FailOnSet field plus a
SetFailOn method, and make Failed use SeverityCritical as the effective
threshold when the threshold was never set — matching the sight and
inspect engine defaults. Explicit thresholds (including Info) keep their
meaning when set via SetFailOn.

BREAKING CHANGE: FailOn assigned by direct field assignment without
SetFailOn now falls back to the critical effective threshold.
Add Stats.LLMErrors so providers can report non-fatal errors encountered
during analysis; a non-empty list signals that findings may be partial.
Additive field, no behavior change — engines populate it in follow-up
changes.
Add Finding.Validate to both the types and review packages, enforcing the
minimum contract invariants: non-blank Message, non-negative Line, and
Confidence within [0, 1]. Returns a descriptive error naming the first
violated field so producers can reject malformed findings before they
reach consumers.
Weekly OSSF Scorecard analysis publishing SARIF to code scanning, pinned
to the same action SHAs as the other hawk-eco repos (yaad, sight,
inspect).
Mirror the review.Result fix: Report.Failed now treats a threshold that
was never set via SetFailOn as SeverityCritical instead of the
SeverityInfo zero value, so a zero-value Report no longer fails on
informational findings.
@Patel230
Patel230 merged commit 16ebcfd into main Aug 16, 2026
13 checks passed
@Patel230
Patel230 deleted the fix/audit-sweep-2026-08 branch August 17, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant