From ba727391dbaf356d85e5bcaef452b3caa020e573 Mon Sep 17 00:00:00 2001 From: Sergio Garcia <38561120+sergargar@users.noreply.github.com> Date: Thu, 2 Jun 2022 13:14:22 +0200 Subject: [PATCH] fix(runtimes_extra762): Detect nodejs versions correctly. (#1177) Co-authored-by: sergargar --- checks/check_extra762 | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/checks/check_extra762 b/checks/check_extra762 index efe60a2fe5..e576675f2a 100644 --- a/checks/check_extra762 +++ b/checks/check_extra762 @@ -27,24 +27,22 @@ extra762(){ # regex to match OBSOLETE runtimes in string functionName%runtime # https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html - OBSOLETE='%(nodejs4.3|nodejs4.3-edge|nodejs6.10|nodejs8.10|dotnetcore1.0|dotnetcore2.0|dotnetcore2.1|python3.6|python2.7|ruby2.5|nodejs10.x|nodejs)' + OBSOLETE='nodejs4.3|nodejs4.3-edge|nodejs6.10|nodejs8.10|dotnetcore1.0|dotnetcore2.0|dotnetcore2.1|python3.6|python2.7|ruby2.5|nodejs10.x|nodejs' for regx in $REGIONS; do - LIST_OF_FUNCTIONS=$($AWSCLI lambda list-functions $PROFILE_OPT --region $regx --output text --query 'Functions[*].{R:Runtime,N:FunctionName}' 2>&1| tr "\t" "%" ) - if [[ $(echo "$LIST_OF_FUNCTIONS" | grep -E 'AccessDenied|UnauthorizedOperation|AuthorizationError') ]]; then + LIST_OF_FUNCTIONS=$("$AWSCLI" lambda list-functions $PROFILE_OPT --region "$regx" --query 'Functions[*].[Runtime,FunctionName]' --output text 2>&1) + if grep -q -E 'AccessDenied|UnauthorizedOperation|AuthorizationError' <<< "$LIST_OF_FUNCTIONS"; then textInfo "$regx: Access Denied trying to list functions" "$regx" continue fi if [[ $LIST_OF_FUNCTIONS ]]; then - for lambdafunction in $LIST_OF_FUNCTIONS;do - fname=$(echo "$lambdafunction" | cut -d'%' -f1) - runtime=$(echo "$lambdafunction" | cut -d'%' -f2) - if echo "$lambdafunction" | grep -Eq $OBSOLETE ; then - textFail "$regx: Obsolete runtime: ${runtime} used by: ${fname}" "$regx" "${fname}" + while read -r FUNCTION_RUNTIME FUNCTION_NAME; do + if grep -wEq $OBSOLETE <<< "${FUNCTION_RUNTIME}" ; then + textFail "$regx: Obsolete runtime: ${FUNCTION_RUNTIME} used by: ${FUNCTION_NAME}" "$regx" "${FUNCTION_NAME}" else - textPass "$regx: Supported runtime: ${runtime} used by: ${fname}" "$regx" "${fname}" + textPass "$regx: Supported runtime: ${FUNCTION_RUNTIME} used by: ${FUNCTION_NAME}" "$regx" "${FUNCTION_NAME}" fi - done + done<<<"${LIST_OF_FUNCTIONS}" else textInfo "$regx: No Lambda functions found" "$regx" fi