Repository navigation
feat(policy): expose scan failure reason in ScanFacts and ScannerResult - #2501
Merged
ramizpolic merged 3 commits intoNov 18, 2026
Merged
Conversation
ramizpolic
reviewed
Nov 12, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
Author
|
Added table-driven unit tests in |
meta.scan.status reports SCAN_STATUS_FAILED when all scanners fail, but previously did not expose the failure reason to policies. A policy could not distinguish local scanner infrastructure outages from defects attributable to the record or external endpoint. Add ScanFailureReason enum mirroring scanner.FailureReason, add failure_reason fields to ScannerResult and ScanFacts, project the values in server/policy, and extend scanFactsChanged in GORM policy invalidation to compare failure_reason. Closes agntcy#2481 Signed-off-by: Ravi Themore <[email protected]>
Signed-off-by: Ravi Themore <[email protected]>
Signed-off-by: Ravi Themore <[email protected]>
lgecse
force-pushed
the
gh-2481-policy-scan-failure-reason
branch
from
November 17, 2026 06:24
13b0ac8 to
cfd3f17
Compare
ramizpolic
approved these changes
Nov 18, 2026
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2481.
Previously,
meta.scan.statusreportedSCAN_STATUS_FAILEDwhen all stored scanner rows failed, but did not expose the underlying failure reason to policies. Consequently, policies could not distinguish local scanner infrastructure outages (e.g.scanner-timeout,scanner-crashed) from defects attributable to the record or external endpoint (e.g.source-unreachable,endpoint-url-invalid).Key Changes
Protobuf (
proto/agntcy/dir/policy/v1/policy_input.proto):ScanFailureReasonenum mirroring all 12scanner.FailureReasonvalues.ScanFailureReason failure_reason = 6;toScannerResult.ScanFailureReason failure_reason = 8;toScanFacts(populated when all failed scanners agree,UNSPECIFIEDotherwise).task gen.Policy Fact Projection (
server/policy/meta.go):failure_reasononto individualScannerResultentries and aggregateScanFacts.GORM Policy Invalidation (
server/database/gorm/policy_invalidation.go):scanFactsChangedto checkbefore.FailureReason != after.FailureReasonso transitioning failure reasons invalidates cached policy verdicts.Documentation & Tests:
docs/content/dir/dir-content-policy-enforcement.md.server/policy/meta_test.goandserver/database/gorm/policy_invalidation_test.go.Verification
go test -v ./policy(PASS)go test -v -run "TestUpsertScanReport|TestFactGettersAreAccountedFor" ./database/gorm(PASS)go vet ./policy ./database/gorm(PASS)