From 541e2a99034f8227a6215d827cbd22c91226dc34 Mon Sep 17 00:00:00 2001 From: muzzamilinovaqo Date: Wed, 20 Mar 2024 16:00:13 +0500 Subject: [PATCH 01/12] lambda function url not in use --- exports.js | 1 + helpers/aws/api.js | 6 + helpers/aws/api_multipart.js | 6 + plugins/aws/lambda/lambdaFuncUrlNotInUse.js | 54 +++++++++ .../aws/lambda/lambdaFuncUrlNotInUse.spec.js | 110 ++++++++++++++++++ 5 files changed, 177 insertions(+) create mode 100644 plugins/aws/lambda/lambdaFuncUrlNotInUse.js create mode 100644 plugins/aws/lambda/lambdaFuncUrlNotInUse.spec.js diff --git a/exports.js b/exports.js index 5f3172e125..1c8c58b62f 100644 --- a/exports.js +++ b/exports.js @@ -495,6 +495,7 @@ module.exports = { 'lambdaLogGroups' : require(__dirname + '/plugins/aws/lambda/lambdaLogGroups.js'), 'lambdaTracingEnabled' : require(__dirname + '/plugins/aws/lambda/lambdaTracingEnabled.js'), 'lambdaHasTags' : require(__dirname + '/plugins/aws/lambda/lambdaHasTags.js'), + 'lambdaFuncUrlNotInUse' : require(__dirname + '/plugins/aws/lambda/lambdaFuncUrlNotInUse.js'), 'lambdaUniqueExecutionRole' : require(__dirname + '/plugins/aws/lambda/lambdaUniqueExecutionRole.js'), 'webServerPublicAccess' : require(__dirname + '/plugins/aws/mwaa/webServerPublicAccess.js'), diff --git a/helpers/aws/api.js b/helpers/aws/api.js index 2b6402a1af..fc2c98de8d 100644 --- a/helpers/aws/api.js +++ b/helpers/aws/api.js @@ -2621,6 +2621,12 @@ var postcalls = [ filterKey: 'FunctionName', filterValue: 'FunctionName', }, + listFunctionUrlConfigs : { + reliesOnService: 'lambda', + reliesOnCall: 'listFunctions', + filterKey: 'FunctionName', + filterValue: 'FunctionName', + }, sendIntegration: { enabled: true } diff --git a/helpers/aws/api_multipart.js b/helpers/aws/api_multipart.js index 8249da0f0e..443b363ec8 100644 --- a/helpers/aws/api_multipart.js +++ b/helpers/aws/api_multipart.js @@ -1984,6 +1984,12 @@ var postcalls = [ filterKey: 'FunctionName', filterValue: 'FunctionName', }, + listFunctionUrlConfigs : { + reliesOnService: 'lambda', + reliesOnCall: 'listFunctions', + filterKey: 'FunctionName', + filterValue: 'FunctionName', + }, sendIntegration: { enabled: true } diff --git a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js new file mode 100644 index 0000000000..c40ea3e6cc --- /dev/null +++ b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js @@ -0,0 +1,54 @@ +var async = require('async'); +var helpers = require('../../../helpers/aws'); + +module.exports = { + title: 'Lambda Function URL Not in Use', + category: 'Lambda', + domain: 'Serverless', + severity: 'Low', + description: 'Ensure that AWS Lambda functions are not configured with function URLs for HTTP(S) endpoints.', + more_info: 'A function URL creates a direct HTTP(S) endpoint to your function and this may pose a security risk depending on the security configuration and intention of the function.', + link: 'https://docs.aws.amazon.com/lambda/latest/dg/urls-configuration.html', + recommended_action: 'Modify Lambda function configurations and delete function url', + apis: ['Lambda:listFunctions','Lambda:listFunctionUrlConfigs'], + realtime_triggers: ['lambda:CreateFunction','lambda:UpdateFunctionConfiguration','lambda:DeleteFunction'], + + run: function(cache, settings, callback) { + var results = []; + var source = {}; + var regions = helpers.regions(settings); + + async.each(regions.lambda, function(region, rcb){ + var listFunctions = helpers.addSource(cache, source, + ['lambda', 'listFunctions', region]); + + if (!listFunctions) return rcb(); + + if (listFunctions.err || !listFunctions.data) { + helpers.addResult(results, 3, + `Unable to query for Lambda functions: ${helpers.addError(listFunctions)}`, region); + return rcb(); + } + + if (!listFunctions.data.length) { + helpers.addResult(results, 0, 'No Lambda functions found', region); + return rcb(); + } + for (var lambdaFunc of listFunctions.data) { + if (!lambdaFunc.FunctionName) continue; + var resource = lambdaFunc.FunctionName; + var urlConfigs = helpers.addSource(cache, source, ['lambda', 'listFunctionUrlConfigs', region, resource]); + + if (urlConfigs && urlConfigs.data && urlConfigs.data.FunctionUrlConfigs && urlConfigs.data.FunctionUrlConfigs.length){ + helpers.addResult(results, 2, 'Lambda function Url is configured', region, resource); + } else { + helpers.addResult(results, 0, 'Lambda function Url is not configured', region, resource); + } + } + + rcb(); + }, function(){ + callback(null, results, source); + }); + } +}; diff --git a/plugins/aws/lambda/lambdaFuncUrlNotInUse.spec.js b/plugins/aws/lambda/lambdaFuncUrlNotInUse.spec.js new file mode 100644 index 0000000000..2a7cb7c771 --- /dev/null +++ b/plugins/aws/lambda/lambdaFuncUrlNotInUse.spec.js @@ -0,0 +1,110 @@ +var expect = require('chai').expect; +var lambdaFunctionURLNotInUse = require('./lambdaFuncUrlNotInUse'); + +const createCache = (lambdaData, functionUrlConfigs) => { + return { + lambda: { + listFunctions: { + 'us-east-1': { + err: null, + data: lambdaData + } + }, + listFunctionUrlConfigs: functionUrlConfigs + } + }; +}; + +describe('Lambda Function URL Not in Use', function () { + describe('run', function () { + it('should return unknown result if unable to list the lambda functions', function (done) { + const callback = (err, results) => { + expect(results.length).to.equal(1); + expect(results[0].status).to.equal(3); + expect(results[0].message).to.include('Unable to query for Lambda functions'); + done(); + }; + + const cache = createCache(null, {}); + + lambdaFunctionURLNotInUse.run(cache, {}, callback); + }); + + it('should return passing result if no lambda function found in region', function (done) { + const callback = (err, results) => { + expect(results.length).to.equal(1); + expect(results[0].status).to.equal(0); + expect(results[0].message).to.include('No Lambda functions found'); + done(); + }; + + const cache = createCache([], {}); + + lambdaFunctionURLNotInUse.run(cache, {}, callback); + }); + + it('should return passing result if lambda function URL is not configured', function (done) { + const lambdaData = [ + { + "FunctionName": "test-lambda", + "FunctionArn": "arn:aws:lambda:us-east-1:000011112222:function:test-lambda" + } + ]; + + const functionUrlConfigs = { + 'us-east-1': { + 'test-lambda': { + 'err': null, + 'data': { + 'FunctionUrlConfigs': [] + } + } + } + }; + + const callback = (err, results) => { + expect(results.length).to.equal(1); + expect(results[0].status).to.equal(0); + expect(results[0].message).to.include('Lambda function Url is not configured'); + done(); + }; + + const cache = createCache(lambdaData, functionUrlConfigs); + + lambdaFunctionURLNotInUse.run(cache, {}, callback); + }); + + it('should return failing result if lambda function URL is configured', function (done) { + const lambdaData = [ + { + "FunctionName": "test-lambda", + "FunctionArn": "arn:aws:lambda:us-east-1:000011112222:function:test-lambda" + } + ]; + + const functionUrlConfigs = { + 'us-east-1': { + 'test-lambda': { + 'err': null, + 'data': { + 'FunctionUrlConfigs': [{ + FunctionUrl: "https://tetsuewfebwfweffesvvs.lambda-url.us-east-1.on.aws/", + }] + } + } + } + }; + + const callback = (err, results) => { + expect(results.length).to.equal(1); + expect(results[0].status).to.equal(2); + expect(results[0].message).to.include('Lambda function Url is configured'); + done(); + }; + + const cache = createCache(lambdaData, functionUrlConfigs); + + lambdaFunctionURLNotInUse.run(cache, {}, callback); + }); + }); +}); From e805cbf96f47dd16c02798e4a56502aaf9885205 Mon Sep 17 00:00:00 2001 From: muzzamilinovaqo Date: Tue, 26 Mar 2024 15:12:51 +0500 Subject: [PATCH 02/12] lambda func url not in use --- plugins/aws/lambda/lambdaFuncUrlNotInUse.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js index c40ea3e6cc..155faf9d0a 100644 --- a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js +++ b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js @@ -5,11 +5,11 @@ module.exports = { title: 'Lambda Function URL Not in Use', category: 'Lambda', domain: 'Serverless', - severity: 'Low', + severity: 'Medium', description: 'Ensure that AWS Lambda functions are not configured with function URLs for HTTP(S) endpoints.', more_info: 'A function URL creates a direct HTTP(S) endpoint to your function and this may pose a security risk depending on the security configuration and intention of the function.', link: 'https://docs.aws.amazon.com/lambda/latest/dg/urls-configuration.html', - recommended_action: 'Modify Lambda function configurations and delete function url', + recommended_action: 'Modify Lambda function configurations and delete function url.', apis: ['Lambda:listFunctions','Lambda:listFunctionUrlConfigs'], realtime_triggers: ['lambda:CreateFunction','lambda:UpdateFunctionConfiguration','lambda:DeleteFunction'], @@ -39,7 +39,9 @@ module.exports = { var resource = lambdaFunc.FunctionName; var urlConfigs = helpers.addSource(cache, source, ['lambda', 'listFunctionUrlConfigs', region, resource]); - if (urlConfigs && urlConfigs.data && urlConfigs.data.FunctionUrlConfigs && urlConfigs.data.FunctionUrlConfigs.length){ + if (urlConfigs && urlConfigs.data && + urlConfigs.data.FunctionUrlConfigs && + urlConfigs.data.FunctionUrlConfigs.length){ helpers.addResult(results, 2, 'Lambda function Url is configured', region, resource); } else { helpers.addResult(results, 0, 'Lambda function Url is not configured', region, resource); From a8b262f8efcaee5922ba2bd90cb69ba5663b4ce8 Mon Sep 17 00:00:00 2001 From: muzzamil <140418718+muzzamilinovaqo@users.noreply.github.com> Date: Thu, 28 Mar 2024 14:57:36 +0500 Subject: [PATCH 03/12] Update helpers/aws/api.js Co-authored-by: Fatima <66124862+fatima99s@users.noreply.github.com> --- helpers/aws/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers/aws/api.js b/helpers/aws/api.js index fc2c98de8d..c133f9c23c 100644 --- a/helpers/aws/api.js +++ b/helpers/aws/api.js @@ -2621,7 +2621,7 @@ var postcalls = [ filterKey: 'FunctionName', filterValue: 'FunctionName', }, - listFunctionUrlConfigs : { + listFunctionUrlConfigs: { reliesOnService: 'lambda', reliesOnCall: 'listFunctions', filterKey: 'FunctionName', From de89b84ee1227e74269a244d346c9d1c601ff1db Mon Sep 17 00:00:00 2001 From: muzzamil <140418718+muzzamilinovaqo@users.noreply.github.com> Date: Thu, 28 Mar 2024 14:57:42 +0500 Subject: [PATCH 04/12] Update helpers/aws/api_multipart.js Co-authored-by: Fatima <66124862+fatima99s@users.noreply.github.com> --- helpers/aws/api_multipart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers/aws/api_multipart.js b/helpers/aws/api_multipart.js index 443b363ec8..231c8a4ecc 100644 --- a/helpers/aws/api_multipart.js +++ b/helpers/aws/api_multipart.js @@ -1984,7 +1984,7 @@ var postcalls = [ filterKey: 'FunctionName', filterValue: 'FunctionName', }, - listFunctionUrlConfigs : { + listFunctionUrlConfigs: { reliesOnService: 'lambda', reliesOnCall: 'listFunctions', filterKey: 'FunctionName', From 5caaf9dc151680a75190a7de038358972d0c3365 Mon Sep 17 00:00:00 2001 From: muzzamil <140418718+muzzamilinovaqo@users.noreply.github.com> Date: Thu, 28 Mar 2024 14:58:03 +0500 Subject: [PATCH 05/12] Update plugins/aws/lambda/lambdaFuncUrlNotInUse.js Co-authored-by: Fatima <66124862+fatima99s@users.noreply.github.com> --- plugins/aws/lambda/lambdaFuncUrlNotInUse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js index 155faf9d0a..c074b78bb1 100644 --- a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js +++ b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js @@ -2,7 +2,7 @@ var async = require('async'); var helpers = require('../../../helpers/aws'); module.exports = { - title: 'Lambda Function URL Not in Use', + title: 'Lambda Function URL Not In Use', category: 'Lambda', domain: 'Serverless', severity: 'Medium', From 41564dc151c7e0c5abf9bbf9dcbe2fc0f2975cb9 Mon Sep 17 00:00:00 2001 From: muzzamilinovaqo Date: Thu, 28 Mar 2024 15:08:15 +0500 Subject: [PATCH 06/12] update file --- plugins/aws/lambda/lambdaFuncUrlNotInUse.js | 17 ++++++++++++---- .../aws/lambda/lambdaFuncUrlNotInUse.spec.js | 20 +++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js index c074b78bb1..66a7600597 100644 --- a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js +++ b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js @@ -7,7 +7,7 @@ module.exports = { domain: 'Serverless', severity: 'Medium', description: 'Ensure that AWS Lambda functions are not configured with function URLs for HTTP(S) endpoints.', - more_info: 'A function URL creates a direct HTTP(S) endpoint to your function and this may pose a security risk depending on the security configuration and intention of the function.', + more_info: 'A function URL is a dedicated HTTP(S) endpoint created for your Amazon Lambda function. You can use a function URL to invoke your Lambda function. But it can lead to some security risks depending on the security configuration and intention of the function.', link: 'https://docs.aws.amazon.com/lambda/latest/dg/urls-configuration.html', recommended_action: 'Modify Lambda function configurations and delete function url.', apis: ['Lambda:listFunctions','Lambda:listFunctionUrlConfigs'], @@ -34,10 +34,19 @@ module.exports = { helpers.addResult(results, 0, 'No Lambda functions found', region); return rcb(); } + for (var lambdaFunc of listFunctions.data) { - if (!lambdaFunc.FunctionName) continue; - var resource = lambdaFunc.FunctionName; - var urlConfigs = helpers.addSource(cache, source, ['lambda', 'listFunctionUrlConfigs', region, resource]); + + if (!lambdaFunc.FunctionArn) continue; + var resource = lambdaFunc.FunctionArn; + + var urlConfigs = helpers.addSource(cache, source, ['lambda', 'listFunctionUrlConfigs', region, lambdaFunc.FunctionName]); + + if (!urlConfigs || urlConfigs.err || !urlConfigs.data) { + helpers.addResult(results, 3, + `Unable to query for Lambda function URL Configs: ${helpers.addError(urlConfigs)}`, region, resource); + return rcb(); + } if (urlConfigs && urlConfigs.data && urlConfigs.data.FunctionUrlConfigs && diff --git a/plugins/aws/lambda/lambdaFuncUrlNotInUse.spec.js b/plugins/aws/lambda/lambdaFuncUrlNotInUse.spec.js index 2a7cb7c771..bafc71c50b 100644 --- a/plugins/aws/lambda/lambdaFuncUrlNotInUse.spec.js +++ b/plugins/aws/lambda/lambdaFuncUrlNotInUse.spec.js @@ -106,5 +106,25 @@ describe('Lambda Function URL Not in Use', function () { lambdaFunctionURLNotInUse.run(cache, {}, callback); }); + + it('should return unknown result if unable to list the lambda function url config', function (done) { + const lambdaData = [ + { + "FunctionName": "test-lambda", + "FunctionArn": "arn:aws:lambda:us-east-1:000011112222:function:test-lambda" + } + ]; + + const callback = (err, results) => { + expect(results.length).to.equal(1); + expect(results[0].status).to.equal(3); + expect(results[0].message).to.include('Unable to query for Lambda function URL Configs'); + done(); + }; + + const cache = createCache(lambdaData, null); + + lambdaFunctionURLNotInUse.run(cache, {}, callback); + }); }); }); From a0fee6434db4920d7d96162e4daca49c2312d7a1 Mon Sep 17 00:00:00 2001 From: muzzamil <140418718+muzzamilinovaqo@users.noreply.github.com> Date: Thu, 18 Apr 2024 12:55:16 +0500 Subject: [PATCH 07/12] Update plugins/aws/lambda/lambdaFuncUrlNotInUse.js Co-authored-by: Fatima <66124862+fatima99s@users.noreply.github.com> --- plugins/aws/lambda/lambdaFuncUrlNotInUse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js index 66a7600597..b0aafb2424 100644 --- a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js +++ b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js @@ -37,7 +37,7 @@ module.exports = { for (var lambdaFunc of listFunctions.data) { - if (!lambdaFunc.FunctionArn) continue; + if (!lambdaFunc.FunctionArn || !lambdaFunc.FunctionName) continue; var resource = lambdaFunc.FunctionArn; var urlConfigs = helpers.addSource(cache, source, ['lambda', 'listFunctionUrlConfigs', region, lambdaFunc.FunctionName]); From 37c5bb638a82e59b2ad96f984868cf7f32557e68 Mon Sep 17 00:00:00 2001 From: muzzamil <140418718+muzzamilinovaqo@users.noreply.github.com> Date: Thu, 18 Apr 2024 12:55:32 +0500 Subject: [PATCH 08/12] Update plugins/aws/lambda/lambdaFuncUrlNotInUse.js Co-authored-by: Fatima <66124862+fatima99s@users.noreply.github.com> --- plugins/aws/lambda/lambdaFuncUrlNotInUse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js index b0aafb2424..2b61b494aa 100644 --- a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js +++ b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js @@ -45,7 +45,7 @@ module.exports = { if (!urlConfigs || urlConfigs.err || !urlConfigs.data) { helpers.addResult(results, 3, `Unable to query for Lambda function URL Configs: ${helpers.addError(urlConfigs)}`, region, resource); - return rcb(); + continue; } if (urlConfigs && urlConfigs.data && From af25ad48f6b29f2fe7376844821498d85a0183b5 Mon Sep 17 00:00:00 2001 From: muzzamil <140418718+muzzamilinovaqo@users.noreply.github.com> Date: Thu, 18 Apr 2024 12:55:47 +0500 Subject: [PATCH 09/12] Update plugins/aws/lambda/lambdaFuncUrlNotInUse.js Co-authored-by: Fatima <66124862+fatima99s@users.noreply.github.com> --- plugins/aws/lambda/lambdaFuncUrlNotInUse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js index 2b61b494aa..8ce8ab57e4 100644 --- a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js +++ b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js @@ -44,7 +44,7 @@ module.exports = { if (!urlConfigs || urlConfigs.err || !urlConfigs.data) { helpers.addResult(results, 3, - `Unable to query for Lambda function URL Configs: ${helpers.addError(urlConfigs)}`, region, resource); + `Unable to query for Lambda function URL configs: ${helpers.addError(urlConfigs)}`, region, resource); continue; } From c02ec4aed589d442e72188554a03f0bb9cac01a5 Mon Sep 17 00:00:00 2001 From: muzzamil <140418718+muzzamilinovaqo@users.noreply.github.com> Date: Thu, 18 Apr 2024 12:56:10 +0500 Subject: [PATCH 10/12] Update plugins/aws/lambda/lambdaFuncUrlNotInUse.js Co-authored-by: Fatima <66124862+fatima99s@users.noreply.github.com> --- plugins/aws/lambda/lambdaFuncUrlNotInUse.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js index 8ce8ab57e4..9453e74d08 100644 --- a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js +++ b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js @@ -48,8 +48,7 @@ module.exports = { continue; } - if (urlConfigs && urlConfigs.data && - urlConfigs.data.FunctionUrlConfigs && + if (urlConfigs.data.FunctionUrlConfigs && urlConfigs.data.FunctionUrlConfigs.length){ helpers.addResult(results, 2, 'Lambda function Url is configured', region, resource); } else { From 5779c4e0dfc8929c59402f32358ebdc68bdbdac9 Mon Sep 17 00:00:00 2001 From: muzzamil <140418718+muzzamilinovaqo@users.noreply.github.com> Date: Thu, 18 Apr 2024 12:56:19 +0500 Subject: [PATCH 11/12] Update plugins/aws/lambda/lambdaFuncUrlNotInUse.js Co-authored-by: Fatima <66124862+fatima99s@users.noreply.github.com> --- plugins/aws/lambda/lambdaFuncUrlNotInUse.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js index 9453e74d08..cb5ef9e75a 100644 --- a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js +++ b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js @@ -40,7 +40,8 @@ module.exports = { if (!lambdaFunc.FunctionArn || !lambdaFunc.FunctionName) continue; var resource = lambdaFunc.FunctionArn; - var urlConfigs = helpers.addSource(cache, source, ['lambda', 'listFunctionUrlConfigs', region, lambdaFunc.FunctionName]); + var urlConfigs = helpers.addSource(cache, source, + ['lambda', 'listFunctionUrlConfigs', region, lambdaFunc.FunctionName]); if (!urlConfigs || urlConfigs.err || !urlConfigs.data) { helpers.addResult(results, 3, From 6029db2525d57a1238a29c5b496d0db85b045ffc Mon Sep 17 00:00:00 2001 From: muzzamilinovaqo Date: Thu, 18 Apr 2024 13:12:11 +0500 Subject: [PATCH 12/12] update spec --- plugins/aws/lambda/lambdaFuncUrlNotInUse.js | 2 +- plugins/aws/lambda/lambdaFuncUrlNotInUse.spec.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js index cb5ef9e75a..9a433e14c6 100644 --- a/plugins/aws/lambda/lambdaFuncUrlNotInUse.js +++ b/plugins/aws/lambda/lambdaFuncUrlNotInUse.js @@ -41,7 +41,7 @@ module.exports = { var resource = lambdaFunc.FunctionArn; var urlConfigs = helpers.addSource(cache, source, - ['lambda', 'listFunctionUrlConfigs', region, lambdaFunc.FunctionName]); + ['lambda', 'listFunctionUrlConfigs', region, lambdaFunc.FunctionName]); if (!urlConfigs || urlConfigs.err || !urlConfigs.data) { helpers.addResult(results, 3, diff --git a/plugins/aws/lambda/lambdaFuncUrlNotInUse.spec.js b/plugins/aws/lambda/lambdaFuncUrlNotInUse.spec.js index bafc71c50b..5664228c0f 100644 --- a/plugins/aws/lambda/lambdaFuncUrlNotInUse.spec.js +++ b/plugins/aws/lambda/lambdaFuncUrlNotInUse.spec.js @@ -21,6 +21,7 @@ describe('Lambda Function URL Not in Use', function () { const callback = (err, results) => { expect(results.length).to.equal(1); expect(results[0].status).to.equal(3); + expect(results[0].region).to.equal('us-east-1'); expect(results[0].message).to.include('Unable to query for Lambda functions'); done(); }; @@ -34,6 +35,7 @@ describe('Lambda Function URL Not in Use', function () { const callback = (err, results) => { expect(results.length).to.equal(1); expect(results[0].status).to.equal(0); + expect(results[0].region).to.equal('us-east-1'); expect(results[0].message).to.include('No Lambda functions found'); done(); }; @@ -65,6 +67,7 @@ describe('Lambda Function URL Not in Use', function () { const callback = (err, results) => { expect(results.length).to.equal(1); expect(results[0].status).to.equal(0); + expect(results[0].region).to.equal('us-east-1'); expect(results[0].message).to.include('Lambda function Url is not configured'); done(); }; @@ -98,6 +101,7 @@ describe('Lambda Function URL Not in Use', function () { const callback = (err, results) => { expect(results.length).to.equal(1); expect(results[0].status).to.equal(2); + expect(results[0].region).to.equal('us-east-1'); expect(results[0].message).to.include('Lambda function Url is configured'); done(); }; @@ -118,7 +122,8 @@ describe('Lambda Function URL Not in Use', function () { const callback = (err, results) => { expect(results.length).to.equal(1); expect(results[0].status).to.equal(3); - expect(results[0].message).to.include('Unable to query for Lambda function URL Configs'); + expect(results[0].region).to.equal('us-east-1'); + expect(results[0].message).to.include('Unable to query for Lambda function URL configs: Unable to obtain data'); done(); };