-
Notifications
You must be signed in to change notification settings - Fork 5.2k
proto_api_scrubber: Implement message-level restrictions. #42411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
proto_api_scrubber: Implement message-level restrictions. #42411
Conversation
Implements the configuration and evaluation logic for message-level restrictions as per the design. When a message-level matcher evaluates to true, the filter now prevents further field-level scrubbing within that message instance by returning kExclude from CheckType. Note: Currently, this does not clear the existing fields of the message. Full message content erasure will require enhancements in the upstream proto-processing-lib. tests for this new feature. Signed-off-by: pranavrautgoogle <pranavraut@google.com>
adisuissa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, overall LGTM.
It is unclear to me if this filter is ready to be used. If it is, then please update the release notes at: changelogs/current.yaml.
| } else { | ||
| // Preserve the field (i.e., kInclude) if there's a match and the matched action is not | ||
| // `envoy.extensions.filters.http.proto_api_scrubber.v3.RemoveFieldAction`. | ||
| ENVOY_LOG(warn, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to reject a wrong configuration (rather than handling edge cases during the dataplane runtime)?
| field_to_scrub, // {3} | ||
| matcher_proto.DebugString() // {4} Inject the Generic Matcher | ||
| ); | ||
| xds::type::matcher::v3::Matcher matcher_proto = buildMatcher(match_predicate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for cleaning this!
| "Error encountered while matching the field `{}`. This field would be preserved. " | ||
| "Error details: {}", | ||
| field_mask, match_result.status().message()); | ||
| field_mask, match_result.status().ToString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOC, why is this needed (I think most of the codebase just uses message())?
Commit Message: feat(proto_api_scrubber): add message-level restrictions
Additional Description:
This commit introduces the configuration and evaluation logic for message-level restrictions to the Proto API Scrubber, as outlined in the design document. The filter can now evaluate matcher rules defined against specific Protobuf message types.
When a message-level matcher evaluates to true for a given message type, FieldChecker::CheckType returns FieldCheckResults::kExclude. In the current version of the proto-processing-lib, this prevents the scrubber from descending into the fields of that message instance for any further field-level checks.
Known Limitation:
This implementation does not clear the fields of the message when the message-level rule matches and CheckType returns kExclude. The message remains intact, but its fields are not scrubbed. True message content clearing upon a message-level match will require enhancements in the upstream proto-processing-lib repository, which will be handled separately.
Risk Level:
Low. This adds new functionality and does not alter the existing field-level or method-level restriction behavior.
Testing:
Unit tests have been added in test/extensions/filters/http/proto_api_scrubber/scrubbing_util_lib/field_checker_test.cc to validate the behavior of FieldChecker::CheckType with different matcher outcomes.
Integration tests have been added in test/extensions/filters/http/proto_api_scrubber/integration_test.cc (e.g., ScrubMessageLevel_MatcherTrue, ScrubMessageLevel_HeaderMatch, MessageScrubPrecedence) to demonstrate the current end-to-end behavior of message-level restrictions, confirming that field traversal is halted but content is not cleared.
Docs Changes:
N/A (No documentation files were modified in this change).
Release Notes:
feat(proto_api_scrubber): Added support for message-level restrictions. Matchers can be configured against fully qualified message names. When a message-level matcher evaluates to true, field-level scrubbing is skipped for the fields within that message instance.
Platform Specific Features:
None.
[Optional Runtime guard:]
N/A
[Optional Fixes #Issue]
N/A
[Optional Fixes commit #PR or SHA]
N/A
[Optional Deprecated:]
N/A
[Optional API Considerations:]
N/A