Add S3 GetBucketPolicyStatus support - #10214
Open
OmniNomadLLC wants to merge 1 commit into
Open
Conversation
GetBucketPolicyStatus previously fell through to a generic empty response,
returning PolicyStatus: {} regardless of the bucket's policy. This
implements the action: it returns NoSuchBucketPolicy when the bucket has
no policy, and computes IsPublic based on Allow statements with a
wildcard principal and no Condition block (statements carrying a
Condition are treated as non-public, matching AWS's treatment of
access-restricting condition keys).
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (81.25%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #10214 +/- ##
==========================================
- Coverage 93.32% 93.31% -0.01%
==========================================
Files 1342 1342
Lines 122702 122734 +32
==========================================
+ Hits 114507 114534 +27
- Misses 8195 8200 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What
Implements
GetBucketPolicyStatusfor S3.Why
Currently the call falls through to a generic empty response:
get_bucket_policy_statusreturnsPolicyStatus: {}regardless of whether the bucket has a policy, and never raisesNoSuchBucketPolicy. We ran into this while testing a security-audit tool against moto (a tool that checks whether buckets are public), where the empty response is indistinguishable from a private bucket.How
NoSuchBucketPolicywhen the bucket has no policy (matches AWS).IsPublicis computed from the stored policy: an Allow statement with a wildcard principal ("*",{"AWS": "*"}or a list containing"*") and noConditionblock makes the policy public. Statements carrying anyConditionare treated as non-public, which matches how AWS treats access-restricting condition keys; the full AWS evaluation of which condition keys still count as public is intentionally out of scope and documented as such in the helper.ACTION_MAPentries follow the existingGetBucketPolicy/GetPublicAccessBlockpatterns; the response uses theActionResultserializer.Tests
Four new tests in
tests/test_s3/test_s3_bucket_policy.py: no policy raisesNoSuchBucketPolicy; wildcard-principal policy reportsIsPublic: True; scoped principal reportsFalse; wildcard with aConditionreportsFalse. Full-k "policy or public_access"subset passes (25 tests),ruff checkandruff formatclean.