Skip to content

[ProtoApiScrubber] Initialize and store descriptor in FilterConfig to be used later for scrubbing. - #39815

Merged
adisuissa merged 54 commits into
envoyproxy:mainfrom
sumitkmr2:descriptor
Jun 16, 2025
Merged

[ProtoApiScrubber] Initialize and store descriptor in FilterConfig to be used later for scrubbing.#39815
adisuissa merged 54 commits into
envoyproxy:mainfrom
sumitkmr2:descriptor

Conversation

@sumitkmr2

Copy link
Copy Markdown
Contributor

Commit Message: Initialize and store descriptor in FilterConfig to be used later for scrubbing.
Additional Description: N/A
Risk Level: NONE
Testing: UTs added
Docs Changes: NONE
Release Notes: N/A
Platform Specific Features: NONE
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

sumitkmr2 added 30 commits May 8, 2025 11:02
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
# Conflicts:
#	source/extensions/filters/http/proto_api_scrubber/BUILD
#	source/extensions/filters/http/proto_api_scrubber/filter_config.cc
#	source/extensions/filters/http/proto_api_scrubber/filter_config.h

Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
# Conflicts:
#	source/extensions/filters/http/proto_api_scrubber/filter_config.cc
#	source/extensions/filters/http/proto_api_scrubber/filter_config.h
#	test/extensions/filters/http/proto_api_scrubber/filter_config_test.cc

Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
sumitkmr2 added 10 commits June 9, 2025 06:37
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
# Conflicts:
#	source/extensions/filters/http/proto_api_scrubber/filter.cc
#	source/extensions/filters/http/proto_api_scrubber/filter.h

Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
# Conflicts:
#	source/extensions/filters/http/proto_api_scrubber/filter.cc
#	source/extensions/filters/http/proto_api_scrubber/filter.h

Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #39815 was opened by sumitkmr2.

see: more, trace.

Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
@sumitkmr2
sumitkmr2 marked this pull request as ready for review June 12, 2025 07:50
@sumitkmr2
sumitkmr2 requested a review from adisuissa as a code owner June 12, 2025 07:50
# Conflicts:
#	test/extensions/filters/http/proto_api_scrubber/filter_test.cc

Signed-off-by: Sumit Kumar <sumitkmr@google.com>
}
break;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style-nit: please remove empty lines in switch-case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

break;
}

default: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style-nit: remove curly brackets when not needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added those since some style-guides expect all the switch cases to be enclosed in curly braces. Removed now.

auto file_or_error = api.fileSystem().fileReadToEnd(data_source.filename());
if (!file_or_error.status().ok() || !descriptor_set.ParseFromString(file_or_error.value())) {
std::cout << "File_or_Error_Status: " << file_or_error.status() << std::endl;
std::cout << "File_or_Error_Status message: " << file_or_error.status().message()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that this doesn't capture the case where file_or_error is valid (but ParseFromString fails).
Please fix to capture the correct error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks for pointing out.

absl::Status ProtoApiScrubberFilterConfig::initializeDescriptorPool(
Api::Api& api, const ::envoy::config::core::v3::DataSource& data_source) {
Envoy::Protobuf::FileDescriptorSet descriptor_set;
auto pool = std::make_unique<Envoy::Protobuf::DescriptorPool>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: move after the switch block.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

}

for (const auto& file : descriptor_set.file()) {
pool->BuildFile(file);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this fail?
If so, should a failure be returned?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it can fail. Added the error handling. Thanks for pointing it out.

Signed-off-by: Sumit Kumar <sumitkmr@google.com>

@sumitkmr2 sumitkmr2 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed comments, thanks!

absl::Status ProtoApiScrubberFilterConfig::initializeDescriptorPool(
Api::Api& api, const ::envoy::config::core::v3::DataSource& data_source) {
Envoy::Protobuf::FileDescriptorSet descriptor_set;
auto pool = std::make_unique<Envoy::Protobuf::DescriptorPool>();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

auto file_or_error = api.fileSystem().fileReadToEnd(data_source.filename());
if (!file_or_error.status().ok() || !descriptor_set.ParseFromString(file_or_error.value())) {
std::cout << "File_or_Error_Status: " << file_or_error.status() << std::endl;
std::cout << "File_or_Error_Status message: " << file_or_error.status().message()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks for pointing out.

break;
}

default: {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added those since some style-guides expect all the switch cases to be enclosed in curly braces. Removed now.

}
break;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

for (const auto& file : descriptor_set.file()) {
pool->BuildFile(file);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it can fail. Added the error handling. Thanks for pointing it out.

Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>
Signed-off-by: Sumit Kumar <sumitkmr@google.com>

@adisuissa adisuissa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

BTW: just saw that there's a missing coverage (https://storage.googleapis.com/envoy-pr/d7f4e90/coverage/source/extensions/filters/http/proto_api_scrubber/filter.cc.html). Can you add some tests that validate that this code is WAI?

@adisuissa
adisuissa merged commit 48a242c into envoyproxy:main Jun 16, 2025
@sumitkmr2

Copy link
Copy Markdown
Contributor Author

LGTM, thanks.

BTW: just saw that there's a missing coverage (https://storage.googleapis.com/envoy-pr/d7f4e90/coverage/source/extensions/filters/http/proto_api_scrubber/filter.cc.html). Can you add some tests that validate that this code is WAI?

Yeah sure, I'll add test to cover these lines as well.

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