feat(storage): add support for bucket ip filter by ddelgrosso1 · Pull Request #15250 · googleapis/google-cloud-cpp · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

feat(storage): add support for bucket ip filter #15250

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ddelgrosso1
Copy link
Contributor

@ddelgrosso1 ddelgrosso1 commented Jul 2, 2025

This change is Reviewable

@product-auto-label product-auto-label bot added the api: storage Issues related to the Cloud Storage API. label Jul 2, 2025
Copy link

codecov bot commented Jul 2, 2025

Codecov Report

Attention: Patch coverage is 97.85203% with 9 lines in your changes missing coverage. Please review.

Project coverage is 92.94%. Comparing base (81c1d01) to head (1d58a67).

Files with missing lines Patch % Lines
...ud/storage/internal/grpc/bucket_metadata_parser.cc 94.23% 3 Missing ⚠️
google/cloud/storage/bucket_ip_filter.cc 98.11% 1 Missing ⚠️
google/cloud/storage/bucket_ip_filter_test.cc 96.96% 1 Missing ⚠️
google/cloud/storage/bucket_metadata_test.cc 97.56% 1 Missing ⚠️
...gle/cloud/storage/internal/bucket_requests_test.cc 96.55% 1 Missing ⚠️
...torage/internal/grpc/bucket_request_parser_test.cc 96.00% 1 Missing ⚠️
...gle/cloud/storage/tests/bucket_integration_test.cc 95.65% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15250      +/-   ##
==========================================
+ Coverage   92.93%   92.94%   +0.01%     
==========================================
  Files        2394     2396       +2     
  Lines      215384   215803     +419     
==========================================
+ Hits       200163   200574     +411     
- Misses      15221    15229       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ddelgrosso1 ddelgrosso1 marked this pull request as ready for review July 2, 2025 17:40
@ddelgrosso1 ddelgrosso1 requested review from a team as code owners July 2, 2025 17:40

std::ostream& operator<<(std::ostream& os,
BucketIpFilterPublicNetworkSource const& rhs) {
os << "BucketIpFilterPublicNetworkSource={allowed_ip_cidr_ranges=[";
Copy link

@rajeevpodar rajeevpodar Jul 3, 2025

Choose a reason for hiding this comment

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

return os << "BucketIpFilterPublicNetworkSource={allowed_ip_cidr_ranges=["
            << absl::StrJoin(rhs.allowed_ip_cidr_ranges, ", ")
            << "]}";


std::ostream& operator<<(std::ostream& os,
BucketIpFilterVpcNetworkSource const& rhs) {
os << "BucketIpFilterVpcNetworkSource={network=" << rhs.network
Copy link

@rajeevpodar rajeevpodar Jul 3, 2025

Choose a reason for hiding this comment

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

return os << "BucketIpFilterVpcNetworkSource={"
            << "network=" << rhs.network
            << ", allowed_ip_cidr_ranges=["
            << absl::StrJoin(rhs.allowed_ip_cidr_ranges, ", ")
            << "]}";

}
if (rhs.vpc_network_sources) {
os << "vpc_network_sources=[";
char const* sep = "";

Choose a reason for hiding this comment

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

absl::StrJoin(*rhs.vpc_network_sources, ", ")

std::ostream& operator<<(std::ostream& os, BucketIpFilter const& rhs) {
google::cloud::internal::IosFlagsSaver save_format(os);
os << "BucketIpFilter={";
os << "mode=" << rhs.mode.value_or("") << ", ";

Choose a reason for hiding this comment

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

nit: This , can be trailing in the output, if no if condition is true underneath.

copy.allowed_ip_cidr_ranges.pop_back();
EXPECT_NE(source, copy);
}

Choose a reason for hiding this comment

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

Another test should be added to ensure that underline structure is ordered strcuture.

TEST(BucketIpFilterTest, PublicNetworkSourceOrderMatters) {
  BucketIpFilterPublicNetworkSource const source1{{"1.2.3.4/32", "5.6.7.8/32"}};
  BucketIpFilterPublicNetworkSource const source2{{"5.6.7.8/32", "1.2.3.4/32"}};

  // The two sources have the same elements but in a different order.
  // They should NOT be equal.
  EXPECT_NE(source1, source2);
}

@@ -192,6 +192,49 @@ Status ParseIamConfiguration(BucketMetadata& meta, nlohmann::json const& json) {
return Status{};
}

Status ParseIpFilter(BucketMetadata& meta, nlohmann::json const& json) {

Choose a reason for hiding this comment

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

This code can be made more readable by using from_json semantics.

@@ -402,6 +445,38 @@ void ToJsonIamConfiguration(nlohmann::json& json, BucketMetadata const& meta) {
json["iamConfiguration"] = std::move(value);
}

void ToJsonIpFilter(nlohmann::json& json, BucketMetadata const& meta) {

Choose a reason for hiding this comment

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

Ditto, to_json semantics seems to be potential candidate here.

},
"vpcNetworkSources": [{
"network": "projects/p/global/networks/n",
"allowedIpCidrRanges": ["5.6.7.8/32"]

Choose a reason for hiding this comment

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

Add more testcase for multiple IpCidrRanges in same network.

@@ -209,6 +209,45 @@ Status PatchIamConfig(Bucket& b, nlohmann::json const& i) {
return Status{};
}

Status PatchIpFilter(Bucket& b, nlohmann::json const& p) {
if (p.is_null()) {

Choose a reason for hiding this comment

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

from_json seems more suitable

},
"vpcNetworkSources": [{
"network": "projects/p/global/networks/n",
"allowedIpCidrRanges": ["5.6.7.8/32"]

Choose a reason for hiding this comment

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

would be good to add testcase which handles multiple ipCidrRanges for same vpcNetwork instead of only one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.