Skip to content
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

Fix s3_get_bucket_policy_status #7926

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

nadavMiz
Copy link
Contributor

@nadavMiz nadavMiz commented Mar 26, 2024

Explain the changes

  1. change s3_get_bucket_policy_status to work with the new bucket policy schema
  2. change the function to comply more closely with public policy definition by:
  • removing resource check since it's not validated for public policy
  • always return true for Principal: '*'
  1. added unit tests

Issues: Fixed #xxx / Gap #xxx

  1. Fixes: NSFS | NC | get-bucket-policy-status fails with internal error (TypeError: policy.statement is not iterable) #7924

Testing Instructions:

  1. run make run-single-test-postgres testname=test_s3_bucket_policy.js
  • Doc added/updated
  • Tests added

@nadavMiz nadavMiz requested a review from jackyalbo March 26, 2024 07:21
@nadavMiz nadavMiz self-assigned this Mar 26, 2024
for (const statement of policy.Statement) {
if (statement.Effect === 'Allow' && statement.Principal) {
const statement_principal = statement.Principal.AWS ? statement.Principal.AWS : statement.Principal;
for (const principal of _.flatten([statement_principal])) {
Copy link
Contributor

@jackyalbo jackyalbo Mar 26, 2024

Choose a reason for hiding this comment

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

is this something possible? that we will have more than one principle, and one of them be '*'? (seems redundant no?) Anyway, if it does, add a comment about what you checking here

Copy link
Contributor Author

@nadavMiz nadavMiz Mar 26, 2024

Choose a reason for hiding this comment

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

it is redundant but possible both in our code and AWS. when checking on AWS if at least one of the principles is * it returned true for public policy. so we might as well do the same

principal_wildcard = true;
}
}
for (const resource of statement.resource) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this something you checked with AWS? because in all the examples they have the resource is *

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I checked it. when adding a policy with specific principles and resources with a wildcard it returns 'false' for this function. it did return true for specific resource and wildcard principals. Also looking at the definition of public it doesn't seem to list resources as one of the things evaluated for public policy. I am not sure why in their examples the resource is always *

@nadavMiz nadavMiz force-pushed the fix-bucket-poilcy-status branch from 2607524 to 427fc5a Compare March 26, 2024 10:26
@nadavMiz nadavMiz requested a review from jackyalbo March 26, 2024 10:27
Signed-off-by: nadav mizrahi <nadav.mizrahi16@gmail.com>
@nadavMiz nadavMiz force-pushed the fix-bucket-poilcy-status branch from 427fc5a to 45b34f4 Compare March 26, 2024 13:00
@nadavMiz nadavMiz merged commit 35a73a9 into noobaa:master Mar 26, 2024
10 checks passed
@guymguym guymguym added this to the 5.15.3 milestone Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NSFS | NC | get-bucket-policy-status fails with internal error (TypeError: policy.statement is not iterable)
3 participants