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): ALB Listening on HTTP for AWS CloudFormation #5212

Merged
merged 4 commits into from
Apr 26, 2022
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
@@ -1,17 +1,20 @@
package Cx

import data.generic.common as common_lib

CxPolicy[result] {
resource := input.document[i].Resources[name]
resource.Type == "AWS::ElasticLoadBalancing::LoadBalancer"

resource.Properties.Listeners[_].Protocol == "HTTP"
resource.Properties.Listeners[l].Protocol == "HTTP"

result := {
"documentId": input.document[i].id,
"searchKey": sprintf("Resources.%s.Properties.Listeners.Protocol=HTTP", [name]),
"issueType": "IncorrectValue",
"keyExpectedValue": sprintf("'Resources.%s.Listeners.Protocol' not equal to 'HTTP'", [name]),
"keyActualValue": sprintf("'Resources.%s.Listeners.Protocol' equals to 'HTTP'", [name]),
"searchLine": common_lib.build_search_line(["Resources", name, "Properties","Listeners",l,"Protocol"], []),
}
}

Expand All @@ -28,5 +31,6 @@ CxPolicy[result] {
"issueType": "IncorrectValue",
"keyExpectedValue": sprintf("'Resources.%s.Protocol' not equal to 'HTTP'", [name]),
"keyActualValue": sprintf("'Resources.%s.Protocol' equals to 'HTTP'", [name]),
"searchLine": common_lib.build_search_line(["Resources", name, "Properties","Protocol"], []),
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Resources:
HTTPlistener:
Type: "AWS::ElasticLoadBalancingV2::Listener"
Properties:
DefaultActions:
- Type: "redirect"
RedirectConfig:
Protocol: "HTTPS"
Port: "443"
Host: "#{host}"
Path: "/#{path}"
Query: "#{query}"
StatusCode: "HTTP_301"
LoadBalancerArn: !Ref myLoadBalancer
Port: 80
Protocol: "HTTP"
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,30 @@
"fileName": "positive1.yaml",
"queryName": "ALB Listening on HTTP",
"severity": "HIGH",
"line": 13
"line": 25
},
{
"fileName": "positive1.yaml",
"queryName": "ALB Listening on HTTP",
"severity": "HIGH",
"line": 25
"line": 13
},
{
"queryName": "ALB Listening on HTTP",
"severity": "HIGH",
"line": 35,
"fileName": "positive2.json"
"fileName": "positive2.json",
"queryName": "ALB Listening on HTTP",
"severity": "HIGH"
},
{
"line": 35,
"line": 9,
"fileName": "positive2.json",
"queryName": "ALB Listening on HTTP",
"severity": "HIGH"
},
{
"queryName": "ALB Listening on HTTP",
"severity": "HIGH",
"line": 16,
"fileName": "positive3.yaml"
}
]
2 changes: 1 addition & 1 deletion e2e/fixtures/E2E_CLI_032_RESULT.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"files": [
{
"file_name": "/path/e2e/fixtures/samples/positive.yaml",
"similarity_id": "f9c0a2aed39f325f242beed63be5c53d938d2c02f243366523b2984fd10243de",
"similarity_id": "7d59e0095d8eda260b02394f129910d70d01b55dffb356780166354f9360d848",
"line": 104,
"issue_type": "IncorrectValue",
"search_key": "Resources.ALBListener.Properties.Protocol",
Expand Down
2 changes: 1 addition & 1 deletion e2e/fixtures/E2E_CLI_036_RESULT.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"files": [
{
"file_name": "fixtures\\samples\\positive.yaml",
"similarity_id": "f9c0a2aed39f325f242beed63be5c53d938d2c02f243366523b2984fd10243de",
"similarity_id": "7d59e0095d8eda260b02394f129910d70d01b55dffb356780166354f9360d848",
"line": 104,
"issue_type": "IncorrectValue",
"search_key": "Resources.ALBListener.Properties.Protocol",
Expand Down