Add S3 access validation script - #1
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| credentials = resolve_credentials(args) | ||
| session = boto3.Session(**{k: v for k, v in credentials.items() if v}) | ||
| if session_kwargs: | ||
| session = boto3.Session(**session_kwargs, **{k: v for k, v in credentials.items() if v}) |
There was a problem hiding this comment.
Honor --profile over ambient credentials
When --profile is supplied, the code still merges in credentials from flags and environment (resolve_credentials), and then passes them alongside profile_name to boto3.Session. In boto3, explicit credential arguments take precedence, so if a user has AWS_ACCESS_KEY_ID/SECRET exported (a common case in CI or local shells), the profile is silently ignored and the access check is performed against the wrong account. This defeats the purpose of --profile and can lead to false positives/negatives when validating bucket access for another profile. Consider omitting env/flag credentials when --profile is set (or explicitly erroring on conflicts).
Useful? React with 👍 / 👎.
Motivation
--prefix.Description
s3_login.pywhich implements argument parsing viaargparseand credential resolution.boto3Sessionsupporting direct credentials or aprofile_nameand construct an S3 client.head_bucketto validate bucket access and optionally calllist_objects_v2withMaxKeys=1to test prefix listing.Testing
Codex Task