Repository navigation
feat(dir): add record metadata to evaluations - #2416
Conversation
54ee2b4 to
68053cd
Compare
1d685bb to
46f4b34
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
6792504 to
6af3d4a
Compare
Signed-off-by: Bendegúz Csirmaz <[email protected]>
6af3d4a to
ed6a982
Compare
| func scanFacts(rows []types.ScanReportObject) *policyv1.ScanFacts { | ||
| facts := &policyv1.ScanFacts{ | ||
| Status: policyv1.ScanStatus_SCAN_STATUS_UNSCANNED, | ||
| MaxSeverity: securityv1.Severity_SEVERITY_UNSPECIFIED, | ||
| } |
There was a problem hiding this comment.
meta.scan.source is never set, so an imported report is indistinguishable from a local one
scanFacts builds its ScanFacts without ever assigning Source, so meta.scan.source is FACT_SOURCE_UNSPECIFIED for every record. The field is declared in policy_input.proto and the typed CEL environment compiles it, so meta.scan.source == FactSource.FACT_SOURCE_LOCAL loads cleanly and is simply never true. A policy can't express the rule, and gets no signal that it can't.
That matters here specifically because the import path is live: autosync's syncReferrers allows ScanReportReferrerType and calls ImportReferrer, which upserts the peer's report into the same scan_reports table the local scanner writes to, with the status hardcoded to completed (server/ingest/ingest.go:147 and :174). So after a sync, meta.scan.is_safe and meta.scan.max_severity can be the publisher's own assertion about its own record, and nothing in meta says so.
This is #2342's acceptance criterion verbatim ("FactSource distinguishes an imported scan report from a local one"), and #2128 frames it as the central question for this layer — "how an evaluation policy tells an imported fact from an observed one" — with "whether FactSource is surfaced in the first increment" still listed as open.
What makes it bite now rather than before: prior to this PR state.Meta was uniformly nil and documented as a stub, so nothing in it could be trusted. After this PR everything in it can be trusted except this one field, with nothing to distinguish them.
Either resolution works, but the current in-between is the one state #2419's own reasoning rejects ("declaring them before they can be answered truthfully would compile policies that silently decide on nothing"):
- Surface it — add a
sourcecolumn toscan_reports, setIMPORTEDat the ingest site andLOCALin the scan task, and project it here. - Defer it explicitly — if the epic's open question lands on "not this increment", then it shouldn't be reachable from a compiled expression in the meantime.
There was a problem hiding this comment.
Thanks, yes I'm aware. We need store additional data in the database table for this, which is why I wanted to do that in a separate PR. I think it's ok to merge this and address that in a follow-up
|
Found only this issue above. Otherwise LGTM. Nice job! |
I will do a follow-up PR for this. Thanks! |
Refs #2342
This PR fills
RecordState.metafor evaluations.It loads:
For a record, and passes the data to the CEL and OPA policies.