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

Clean up S3 Buckets in integration test #1603

Merged
merged 9 commits into from
Oct 8, 2024

Conversation

dlpzx
Copy link
Contributor

@dlpzx dlpzx commented Oct 2, 2024

Feature or Bugfix

  • Feature

Detail

Environment and Dataset stacks leave S3 Buckets to be deleted even when the CloudFormation stack is deleted.
This PR deletes the S3 Buckets when the session and temp fixtures for datasets and environments are deleted.

Testing

Tested that environment and dataset buckets are all deleted - in real AWS CICD pipeline with NOT-empty buckets.
Tested that dataset buckets with some manually created access points succeed.

Relates

Security

Please answer the questions below briefly where applicable, or write N/A. Based on
OWASP 10.

  • Does this PR introduce or modify any input fields or queries - this includes
    fetching data from storage outside the application (e.g. a database, an S3 bucket)?
    • Is the input sanitized?
    • What precautions are you taking before deserializing the data you consume?
    • Is injection prevented by parametrizing queries?
    • Have you ensured no eval or similar functions are used?
  • Does this PR introduce any functionality or component that requires authorization?
    • How have you ensured it respects the existing AuthN/AuthZ mechanisms?
    • Are you logging failed auth attempts?
  • Are you using or adding any cryptographic features?
    • Do you use a standard proven implementations?
    • Are the used keys controlled by the customer? Where are they stored?
  • Are you introducing any new policies/roles/users?
    • Have you used the least-privilege principle? How?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@dlpzx dlpzx requested a review from petrkalos October 2, 2024 08:24
self._resource = session.resource('s3', region_name=region)
self._region = region

def delete_bucket(self, bucket_name):
Copy link
Contributor

Choose a reason for hiding this comment

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

you need to account for access points as well (if bucket have them it will fail)

Copy link
Contributor Author

@dlpzx dlpzx Oct 6, 2024

Choose a reason for hiding this comment

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

In a happy path world, we should not run into that situation because a dataset can only be deleted if all shares are revoked and if shares are revoked the access points are deleted. However, if the tests for revoking access points fail, then we would face this situation when tearing down resources. It is easy enough to implement, so I am adding it to the PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested! Now it is ready to be merged. Do you want to have a final look @petrkalos ?

@dlpzx dlpzx self-assigned this Oct 3, 2024
@dlpzx dlpzx marked this pull request as ready for review October 7, 2024 08:37
@dlpzx
Copy link
Contributor Author

dlpzx commented Oct 8, 2024

Not merging yet because while testing the code for access points a small error appeared. Wait for updates on this PR

@dlpzx dlpzx force-pushed the fix/clean-up-buckets-integration-test branch from 5421146 to e014991 Compare October 8, 2024 10:16
@SofiaSazonova SofiaSazonova merged commit 4957f5b into main Oct 8, 2024
9 checks passed
dlpzx added a commit that referenced this pull request Oct 9, 2024
### Feature or Bugfix
- Bugfix

### Detail
This PR fixes a mismatch between the #1607 and #1603 where
get_environment_aws_session is no longer used. In this PR we obtain the
session from the new STSClient refreshable token functions introduced in
#1607

### Relates
- #1603 
- #1607 

### Security
Please answer the questions below briefly where applicable, or write
`N/A`. Based on
[OWASP 10](https://owasp.org/Top10/en/).

- Does this PR introduce or modify any input fields or queries - this
includes
fetching data from storage outside the application (e.g. a database, an
S3 bucket)?
  - Is the input sanitized?
- What precautions are you taking before deserializing the data you
consume?
  - Is injection prevented by parametrizing queries?
  - Have you ensured no `eval` or similar functions are used?
- Does this PR introduce any functionality or component that requires
authorization?
- How have you ensured it respects the existing AuthN/AuthZ mechanisms?
  - Are you logging failed auth attempts?
- Are you using or adding any cryptographic features?
  - Do you use a standard proven implementations?
  - Are the used keys controlled by the customer? Where are they stored?
- Are you introducing any new policies/roles/users?
  - Have you used the least-privilege principle? How?


By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants