Skip to content
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(query): serverless_function_without_unique_iam_role #6292

Merged
merged 3 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import data.generic.serverlessfw as sfw_lib
CxPolicy[result] {
document := input.document[i]
functions := document.functions
is_object(functions)
function := functions[fname]

not common_lib.valid_key(function, "role")
Expand All @@ -21,3 +22,23 @@ CxPolicy[result] {
"searchLine": common_lib.build_search_line(["functions", fname], []),
}
}

CxPolicy[result] {
document := input.document[i]
functions := document.functions
is_array(functions)
function := functions[k][fname]

not common_lib.valid_key(function, "role")

result := {
"documentId": input.document[i].id,
"resourceType": sfw_lib.resourceTypeMapping("function", document.provider.name),
"resourceName": fname,
"searchKey": sprintf("functions[%s].%s", [k,fname]),
"issueType": "MissingAttribute",
"keyExpectedValue": "'role' should be defined inside the function",
"keyActualValue": "'role' is not defined",
"searchLine": common_lib.build_search_line(["functions",k ,fname], []),
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
service: service
frameworkVersion: '2'
provider:
name: aws
runtime: nodejs12.x

functions:
- hello:
handler: handler.hello
onError: arn:aws:sns:us-east-1:XXXXXX:test
tags:
foo: bar
role: arn:aws:iam::XXXXXX:role/role
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
service: service
frameworkVersion: '2'
provider:
name: aws
runtime: nodejs12.x

functions:
- hello:
handler: handler.hello
onError: arn:aws:sns:us-east-1:XXXXXX:test
tags:
foo: bar
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@
"severity": "MEDIUM",
"line": 8,
"fileName": "positive1.yml"
},
{
"queryName": "Serverless Function Without Unique IAM Role",
"severity": "MEDIUM",
"line": 8,
"fileName": "positive2.yml"
}
]