Repository navigation
🔒 fix(collect): keep field values out of extraction errors - #391
Merged
Merged
Conversation
CEL and JSONPath evaluation errors interpolate the operands they were evaluating: `no such key: <key>`, `invalid RFC 3339 timestamp "<value>"`, `map[...] is not array or slice`. The extractor wrapped them verbatim, and the result fed KollectTarget status.lastExtractionError, the Degraded condition, the Warning event, the engine log line and the pipeline ExtractionFailure reason. A profile over Secrets could therefore publish Secret data to anyone allowed to get the target. Evaluation errors are now reduced at the extractor to the attribute name plus a fixed error class; the raw error is not wrapped, so no caller can recover it by unwrapping. The Helm accessor and JSON decode errors get the same treatment because they quote release payload. CEL compile and JSONPath parse errors depend only on the expression and keep their detail.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
JSONPath `incompatible types for comparison` and CEL `unsupported index type` are static and data-free, but they fell through to the unclassified fallback; give them their own class so users can act on them. Also pin the Helm JSON decode message with a non-JSON release payload: wrapping the encoding/json error again would quote a payload byte.
|
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.



Summary
CEL and JSONPath evaluation errors echo the values they evaluate, and the extractor passed them through verbatim into
KollectTarget.status.lastExtractionError, theDegradedcondition, theExtractionFailedWarning event, the engine log line and the pipelineExtractionFailurereason. With a Secret holdingdata.pw=SUPERSECRETVALUE:cel:timestamp(object.data.pw)invalid RFC 3339 timestamp "SUPERSECRETVALUE"cel:object.data[object.data.pw]no such key: SUPERSECRETVALUE{.data[?(@.x>1)]}map[pw:SUPERSECRETVALUE] is not array or slice…Anyone with
geton the target could read it. Regex redaction downstream can't catch this, so the fix is at the source:internal/collect/extractor.goreduces every evaluation error to the attribute name plus a fixed class (attribute "pw": eval CEL: evaluation error: no such key). It does not wrap the raw error, so unwrapping can't recover it either. The Helm accessor error (which quoted release values) and the Helm JSON decode error get the same treatment. CEL compile and JSONPath parse errors depend only on the expression, so they keep their full detail.The extractor is the only producer, so this one change covers every sink: status, condition, event, both log paths and the pipeline exit error. Metrics labels were already fixed constants, and
matchPolicyeval errors are swallowed.Risk
Low. Users lose the operand detail in evaluation errors, which was the leak. For debugging they get the attribute name and the class, and can test the expression against the object themselves. Errors that don't match a known class show as
unclassified (details withheld…), so a new upstream message format fails closed. This doesn't touchinternal/redact.Testing
internal/collect/extraction_error_leak_test.gocovers the extractor (the 3 reported probes plus regex, duration, index and the Helm accessor), the unwrap chain, engineExtractFailuresplus the captured log output, and the runner reason.internal/controller/kollecttarget_extraction_leak_test.gochecks status, the Degraded message and events.go build ./...,task lint,task verify,task scrubpass, and so doesgo test -race ./cmd/... ./internal/....internal/sinkhit the knownResetBreakersForTestrace once and passed on rerun.