-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(extra730): Handle invalid date formats checking ACM certificates #1033
fix(extra730): Handle invalid date formats checking ACM certificates #1033
Conversation
if [[ $1 = 20* ]];then | ||
echo $1 | cut -f1 -d"T" | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've deleted this date parsing because it allows something like 20wathever
# "Check if ACM Certificates are about to expire in $DAYS_TO_EXPIRE_THRESHOLD days or less" | ||
for regx in $REGIONS; do | ||
LIST_OF_ACM_CERTS=$($AWSCLI acm list-certificates $PROFILE_OPT --region $regx --query 'CertificateSummaryList[].CertificateArn' --output text) | ||
if [[ $LIST_OF_ACM_CERTS ]];then | ||
LIST_OF_ACM_CERTS=$("${AWSCLI}" acm list-certificates ${PROFILE_OPT} --region "${regx}" --include keyTypes="${ACM_KEY_TYPES}" --certificate-statuses "${ACM_CERTIFICATE_STATUSES}" --query 'CertificateSummaryList[].CertificateArn' --output text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about imported certificates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It checks every ACM certificate whether it is Amazon Issued, Imported or comes from a Private PKI.
For that reason we have included two filters:
ACM_KEY_TYPES
: to set the algorithms that can be used to generate key pairs.ACM_CERTIFICATE_STATUSES
: to only check ACM Certificates whose status isISSUED
. The following statuses are not checked:
PENDING_VALIDATION
INACTIVE
EXPIRED
VALIDATION_TIMED_OUT
REVOKED
FAILED
if [[ $1 = 20* ]];then | ||
echo $1 | cut -f1 -d"T" | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've deleted this date parsing because it allows something like 20wathever
# remove fractions of a second | ||
TIMESTAMP_TO_CONVERT=$(cut -f1 -d"." <<< "${1}") | ||
OUTPUT_DATE=$("${DATE_CMD}" -d @"${TIMESTAMP_TO_CONVERT}" +'%Y-%m-%d') | ||
echo "${OUTPUT_DATE}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this echo really needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's the way to return the OUTPUT_DATE
value
Context
extra730 checks if ACM Certificates are about to expire in
$DAYS_TO_EXPIRE_THRESHOLD
days or lessDescription
This PR addresses the following:
bsd_timestamp_to_date
andgnu_timestamp_to_date
in order to perform date validation properly.License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.