Skip to content

Conversation

@pranavrautgoogle
Copy link
Contributor

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

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>
Copy link
Contributor

@adisuissa adisuissa left a 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,
Copy link
Contributor

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);
Copy link
Contributor

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());
Copy link
Contributor

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())?

@adisuissa adisuissa self-assigned this Dec 4, 2025
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.

2 participants