From deb7fe4dd9f305eeaef11dc54b7bce0fbe1679a8 Mon Sep 17 00:00:00 2001 From: gioroddev Date: Mon, 2 Dec 2024 13:22:56 -0500 Subject: [PATCH] updating logic --- helpers/aws/functions.js | 5 +++++ plugins/aws/lambda/lambdaNetworkExposure.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/helpers/aws/functions.js b/helpers/aws/functions.js index e6f26551d6..c46b46eac4 100644 --- a/helpers/aws/functions.js +++ b/helpers/aws/functions.js @@ -1239,6 +1239,11 @@ var getAttachedELBs = function(cache, source, region, resourceId, lbField, lbAt return elbs; }; +var getApiIdFromArn = function(arn) { + if (!arn) return null; + const matches = arn.match(/arn:aws:execute-api:[^:]+:[^:]+:([^/]+)/); + return matches ? matches[1] : null; +} var checkNetworkExposure = function(cache, source, subnets, securityGroups, elbs, region, results, resource) { var internetExposed = ''; var isSubnetPrivate = false; diff --git a/plugins/aws/lambda/lambdaNetworkExposure.js b/plugins/aws/lambda/lambdaNetworkExposure.js index 2d041133ea..7d2dfe4b23 100644 --- a/plugins/aws/lambda/lambdaNetworkExposure.js +++ b/plugins/aws/lambda/lambdaNetworkExposure.js @@ -49,12 +49,12 @@ module.exports = { var getPolicy = helpers.addSource(cache, source, ['lambda', 'getPolicy', region, lambda.FunctionName]); - let lambda = { + let lambdaResource = { functionUrlConfig: getFunctionUrlConfig, functionPolicy: getPolicy } - let internetExposed = helpers.checkNetworkExposure(cache, source, [], [], [], region, results, lambda); + let internetExposed = helpers.checkNetworkExposure(cache, source, [], [], [], region, results, lambdaResource); if (internetExposed && internetExposed.length) { helpers.addResult(results, 2,