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

Added -D option to copy to S3 with the initial AWS credentials instead of the assumed as with -B option @sectoramen #974

Merged
merged 5 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions include/assume_role
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# specific language governing permissions and limitations under the License.

assume_role(){
MY_AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
MY_AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
MY_SESSION_TOKEN=$AWS_SESSION_TOKEN
PROFILE_OPT=$PROFILE_OPT_BAK
# Both variables are mandatory to be set together
if [[ -z $ROLE_TO_ASSUME || -z $ACCOUNT_TO_ASSUME ]]; then
Expand Down Expand Up @@ -84,3 +87,12 @@ cleanSTSAssumeFile() {
rm -fr "${TEMP_STS_ASSUMED_FILE}"
rm -fr "${TEMP_STS_ASSUMED_ERROR}"
}

restoreAWSCredentials() {
AWS_ACCESS_KEY_ID=$MY_AWS_ACCESS_KEY_ID
export AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY=$MY_AWS_SECRET_ACCESS_KEY
export AWS_SECRET_ACCESS_KEY
SESSION_TOKEN=$MY_AWS_SESSION_TOKEN
export SESSION_TOKEN
}
14 changes: 8 additions & 6 deletions prowler
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,9 @@ if [[ $GROUP_ID_READ ]];then
fi
cleanTemp
scoring
if [[ $ACCOUNT_TO_ASSUME ]]; then
restoreAWSCredentials
fi
copyToS3
exit $EXITCODE
else
Expand Down Expand Up @@ -690,6 +693,9 @@ if [[ $CHECK_ID ]];then
if [[ "${MODES[@]}" =~ "html" ]]; then
addHtmlFooter >> ${OUTPUT_FILE_NAME}.$EXTENSION_HTML
fi
if [[ $ACCOUNT_TO_ASSUME ]]; then
restoreAWSCredentials
fi
copyToS3
scoring
cleanTemp
Expand All @@ -704,13 +710,9 @@ fi

scoring
cleanTemp
copyToS3

if [[ $ACCOUNT_TO_ASSUME ]]; then
# unset env variables with assumed role credentials
unset AWS_ACCESS_KEY_ID
unset AWS_SECRET_ACCESS_KEY
unset AWS_SESSION_TOKEN
restoreAWSCredentials
fi
copyToS3

exit $EXITCODE