-
Notifications
You must be signed in to change notification settings - Fork 706
aws lambda func url not in use #1970
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
Open
muzzamilinovaqo
wants to merge
12
commits into
aquasecurity:master
Choose a base branch
from
muzzamilinovaqo:feature/plugin-aws-lambda-func-url-in-use
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
541e2a9
lambda function url not in use
muzzamilinovaqo e805cbf
lambda func url not in use
muzzamilinovaqo a8b262f
Update helpers/aws/api.js
muzzamilinovaqo de89b84
Update helpers/aws/api_multipart.js
muzzamilinovaqo 5caaf9d
Update plugins/aws/lambda/lambdaFuncUrlNotInUse.js
muzzamilinovaqo 41564dc
update file
muzzamilinovaqo a0fee64
Update plugins/aws/lambda/lambdaFuncUrlNotInUse.js
muzzamilinovaqo 37c5bb6
Update plugins/aws/lambda/lambdaFuncUrlNotInUse.js
muzzamilinovaqo af25ad4
Update plugins/aws/lambda/lambdaFuncUrlNotInUse.js
muzzamilinovaqo c02ec4a
Update plugins/aws/lambda/lambdaFuncUrlNotInUse.js
muzzamilinovaqo 5779c4e
Update plugins/aws/lambda/lambdaFuncUrlNotInUse.js
muzzamilinovaqo 6029db2
update spec
muzzamilinovaqo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,56 @@ | ||||||
var async = require('async'); | ||||||
var helpers = require('../../../helpers/aws'); | ||||||
|
||||||
module.exports = { | ||||||
title: 'Lambda Function URL Not in Use', | ||||||
muzzamilinovaqo marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
category: 'Lambda', | ||||||
domain: 'Serverless', | ||||||
severity: 'Medium', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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.', | ||||||
alphadev4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
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; | ||||||
alphadev4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
var urlConfigs = helpers.addSource(cache, source, ['lambda', 'listFunctionUrlConfigs', region, resource]); | ||||||
|
||||||
if (urlConfigs && urlConfigs.data && | ||||||
urlConfigs.data.FunctionUrlConfigs && | ||||||
urlConfigs.data.FunctionUrlConfigs.length){ | ||||||
muzzamilinovaqo marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
helpers.addResult(results, 2, 'Lambda function Url is configured', region, resource); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} else { | ||||||
helpers.addResult(results, 0, 'Lambda function Url is not configured', region, resource); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
} | ||||||
|
||||||
rcb(); | ||||||
}, function(){ | ||||||
callback(null, results, source); | ||||||
}); | ||||||
} | ||||||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 () { | ||
alphadev4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.