-
Notifications
You must be signed in to change notification settings - Fork 744
Fix access to public S3 buckets form restricted Intance/Job Roles #6553
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,11 +202,28 @@ class AwsBatchFileCopyStrategyTest extends Specification { | |
| local source=$1 | ||
| local target=$2 | ||
| local file_name=$(basename $1) | ||
| local is_dir=$(aws s3 ls $source | grep -F "PRE ${file_name}/" -c) | ||
| local is_dir=$(nxf_s3_fallback s3 ls $source | grep -F "PRE ${file_name}/" -c) | ||
| local opts=(--only-show-errors) | ||
| if [[ $is_dir == 1 ]]; then | ||
| aws s3 cp --only-show-errors --recursive "$source" "$target" | ||
| else | ||
| aws s3 cp --only-show-errors "$source" "$target" | ||
| opts+=(--recursive) | ||
| fi | ||
| nxf_s3_fallback s3 cp "${opts[@]}" "$source" "$target" | ||
| } | ||
|
|
||
| nxf_s3_fallback() { | ||
| local args=("$@") | ||
| local output | ||
|
|
||
| if ! output=$(aws "${args[@]}" 2>&1); then | ||
| if echo "$output" | grep -Eq "(AccessDenied|Forbidden|403)"; then | ||
| echo "Access denied, retrying unsigned request..." | ||
| aws --no-sign-request "${args[@]}" | ||
| else | ||
| echo "$output" | ||
| return 1 | ||
| fi | ||
| else | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Theres' no way to avoid the fallback logic and make this predictable?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is tricky, the only way to check if it is public in this condition is just try to access. We could reduce the number of fallbacks by using the try we do in the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be the alternative only falling back for |
||
| echo "$output" | ||
| fi | ||
| } | ||
| '''.stripIndent(true) | ||
|
|
@@ -293,11 +310,28 @@ class AwsBatchFileCopyStrategyTest extends Specification { | |
| local source=$1 | ||
| local target=$2 | ||
| local file_name=$(basename $1) | ||
| local is_dir=$(/foo/aws s3 ls $source | grep -F "PRE ${file_name}/" -c) | ||
| local is_dir=$(nxf_s3_fallback s3 ls $source | grep -F "PRE ${file_name}/" -c) | ||
| local opts=(--only-show-errors) | ||
| if [[ $is_dir == 1 ]]; then | ||
| /foo/aws s3 cp --only-show-errors --recursive "$source" "$target" | ||
| else | ||
| /foo/aws s3 cp --only-show-errors "$source" "$target" | ||
| opts+=(--recursive) | ||
| fi | ||
| nxf_s3_fallback s3 cp "${opts[@]}" "$source" "$target" | ||
| } | ||
|
|
||
| nxf_s3_fallback() { | ||
| local args=("$@") | ||
| local output | ||
|
|
||
| if ! output=$(/foo/aws "${args[@]}" 2>&1); then | ||
| if echo "$output" | grep -Eq "(AccessDenied|Forbidden|403)"; then | ||
| echo "Access denied, retrying unsigned request..." | ||
| /foo/aws --no-sign-request "${args[@]}" | ||
| else | ||
| echo "$output" | ||
| return 1 | ||
| fi | ||
| else | ||
| echo "$output" | ||
| fi | ||
| } | ||
| '''.stripIndent(true) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.