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

Test NotPrincipal, NotAction, NotResource policies #9676

Closed
wants to merge 2 commits into from

Conversation

mashetty330
Copy link
Contributor

No description provided.

@pull-request-size pull-request-size bot added the size/L PR that changes 100-499 lines label Apr 15, 2024
Copy link

openshift-ci bot commented Apr 15, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mashetty330

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Signed-off-by: Mahesh Shetty <[email protected]>
@mashetty330 mashetty330 marked this pull request as ready for review April 16, 2024 07:35
@mashetty330 mashetty330 requested a review from a team as a code owner April 16, 2024 07:35
Copy link
Contributor

@sagihirshfeld sagihirshfeld left a comment

Choose a reason for hiding this comment

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

  1. Looks like you're covering "standard" bucket policies here. The NotPrincipal, NotAction, and NotResource are properties with different behaviors of their own.

For example the following NotPrincipal AWS S3 bucket policy (generated by ChatGPT) denies all access to the bucket except for the specified user:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Deny",
            "NotPrincipal": {
                "AWS": "arn:aws:iam::ACCOUNT-ID-WITHOUT-ACCESS:root"
            },
            "Action": "s3:*",
            "Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*"
        }
    ]
}

To test this you would need to make adjustments to gen_bucket_policy, and probably change the flow of the test cases themselves. Please check the AWS documentation to be sure about the expected behaviors.

  1. Please separate this to three different test functions - there's little to no shared logic between the three since each param is basically handled in its own if-else block. I think you should be able to reuse the same polarion and bz decorators on each of them.

@mashetty330
Copy link
Contributor Author

mashetty330 commented Apr 17, 2024

  1. Looks like you're covering "standard" bucket policies here. The NotPrincipal, NotAction, and NotResource are properties with different behaviors of their own.

For example the following NotPrincipal AWS S3 bucket policy (generated by ChatGPT) denies all access to the bucket except for the specified user:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Deny",
            "NotPrincipal": {
                "AWS": "arn:aws:iam::ACCOUNT-ID-WITHOUT-ACCESS:root"
            },
            "Action": "s3:*",
            "Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*"
        }
    ]
}

To test this you would need to make adjustments to gen_bucket_policy, and probably change the flow of the test cases themselves. Please check the AWS documentation to be sure about the expected behaviors.

  1. Please separate this to three different test functions - there's little to no shared logic between the three since each param is basically handled in its own if-else block. I think you should be able to reuse the same polarion and bz decorators on each of them.

@sagihirshfeld the point 1, is you are correct absolutely about the functionality of NotPrincipal, NotAction and NotResource. but then my test covers the exact mentioned scenario right? For example, in case of NotPrincipal accesss should be denied to every user except the one mentioned under NotPrincipal. What is wrong there? am i missing something?

@mashetty330
Copy link
Contributor Author

closing this PR because its been part of https://issues.redhat.com/browse/RHSTOR-5151 and covered here #9688

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L PR that changes 100-499 lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants