forked from Checkmarx/kics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8d746d
commit d5f186a
Showing
7 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
assets/queries/terraform/azure/app_service_http2_disabled/metadata.json
This file contains 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,11 @@ | ||
{ | ||
"id": "525b53be-62ed-4244-b4df-41aecfcb4071", | ||
"queryName": "App Service HTTP2 Disabled", | ||
"severity": "LOW", | ||
"category": "Networking and Firewall", | ||
"descriptionText": "App Service should have 'http2_enabled' enabled", | ||
"descriptionUrl": "https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service#http2_enabled", | ||
"platform": "Terraform", | ||
"descriptionID": "dee0c164", | ||
"cloudProvider": "azure" | ||
} |
48 changes: 48 additions & 0 deletions
48
assets/queries/terraform/azure/app_service_http2_disabled/query.rego
This file contains 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,48 @@ | ||
package Cx | ||
|
||
import data.generic.common as common_lib | ||
|
||
CxPolicy[result] { | ||
app := input.document[i].resource.azurerm_app_service[name] | ||
|
||
not common_lib.valid_key(app, "site_config") | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"searchKey": sprintf("azurerm_app_service[%s]", [name]), | ||
"issueType": "MissingAttribute", | ||
"keyExpectedValue": sprintf("'azurerm_app_service[%s].site_config' is defined and not null", [name]), | ||
"keyActualValue": sprintf("'azurerm_app_service[%s].site_config' is undefined or null", [name]), | ||
"searchLine": common_lib.build_search_line(["resource", "azurerm_app_service", name], []), | ||
} | ||
} | ||
|
||
CxPolicy[result] { | ||
app := input.document[i].resource.azurerm_app_service[name] | ||
|
||
not common_lib.valid_key(app.site_config, "http2_enabled") | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"searchKey": sprintf("azurerm_app_service[%s].site_config", [name]), | ||
"issueType": "IncorrectValue", | ||
"keyExpectedValue": sprintf("'azurerm_app_service[%s].site_config.http2_enabled' is defined and not null", [name]), | ||
"keyActualValue": sprintf("'azurerm_app_service[%s].site_config.http2_enabled' is undefined or null", [name]), | ||
"searchLine": common_lib.build_search_line(["resource", "azurerm_app_service", name, "site_config"], []), | ||
} | ||
} | ||
|
||
CxPolicy[result] { | ||
app := input.document[i].resource.azurerm_app_service[name] | ||
|
||
app.site_config.http2_enabled == false | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"searchKey": sprintf("azurerm_app_service[%s].site_config.http2_enabled", [name]), | ||
"issueType": "IncorrectValue", | ||
"keyExpectedValue": sprintf("'azurerm_app_service[%s].site_config.http2_enabled' is set to true", [name]), | ||
"keyActualValue": sprintf("'azurerm_app_service[%s].site_config.http2_enabled' is set to false", [name]), | ||
"searchLine": common_lib.build_search_line(["resource", "azurerm_app_service", name, "site_config", "http2_enabled"], []), | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
assets/queries/terraform/azure/app_service_http2_disabled/test/negative.tf
This file contains 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,23 @@ | ||
resource "azurerm_app_service" "negative" { | ||
name = "example-app-service" | ||
location = azurerm_resource_group.example.location | ||
resource_group_name = azurerm_resource_group.example.name | ||
app_service_plan_id = azurerm_app_service_plan.example.id | ||
|
||
app_settings = { | ||
"SOME_KEY" = "some-value" | ||
} | ||
|
||
connection_string { | ||
name = "Database" | ||
type = "SQLServer" | ||
value = "Server=some-server.mydomain.com;Integrated Security=SSPI" | ||
} | ||
|
||
site_config { | ||
dotnet_framework_version = "v4.0" | ||
scm_type = "LocalGit" | ||
min_tls_version = 1.2 | ||
http2_enabled = true | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
assets/queries/terraform/azure/app_service_http2_disabled/test/positive1.tf
This file contains 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,16 @@ | ||
resource "azurerm_app_service" "positive1" { | ||
name = "example-app-service" | ||
location = azurerm_resource_group.example.location | ||
resource_group_name = azurerm_resource_group.example.name | ||
app_service_plan_id = azurerm_app_service_plan.example.id | ||
|
||
app_settings = { | ||
"SOME_KEY" = "some-value" | ||
} | ||
|
||
connection_string { | ||
name = "Database" | ||
type = "SQLServer" | ||
value = "Server=some-server.mydomain.com;Integrated Security=SSPI" | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
assets/queries/terraform/azure/app_service_http2_disabled/test/positive2.tf
This file contains 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,22 @@ | ||
resource "azurerm_app_service" "positive2" { | ||
name = "example-app-service" | ||
location = azurerm_resource_group.example.location | ||
resource_group_name = azurerm_resource_group.example.name | ||
app_service_plan_id = azurerm_app_service_plan.example.id | ||
|
||
app_settings = { | ||
"SOME_KEY" = "some-value" | ||
} | ||
|
||
connection_string { | ||
name = "Database" | ||
type = "SQLServer" | ||
value = "Server=some-server.mydomain.com;Integrated Security=SSPI" | ||
} | ||
|
||
site_config { | ||
dotnet_framework_version = "v4.0" | ||
scm_type = "LocalGit" | ||
min_tls_version = 1.2 | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
assets/queries/terraform/azure/app_service_http2_disabled/test/positive3.tf
This file contains 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,23 @@ | ||
resource "azurerm_app_service" "positive3" { | ||
name = "example-app-service" | ||
location = azurerm_resource_group.example.location | ||
resource_group_name = azurerm_resource_group.example.name | ||
app_service_plan_id = azurerm_app_service_plan.example.id | ||
|
||
app_settings = { | ||
"SOME_KEY" = "some-value" | ||
} | ||
|
||
connection_string { | ||
name = "Database" | ||
type = "SQLServer" | ||
value = "Server=some-server.mydomain.com;Integrated Security=SSPI" | ||
} | ||
|
||
site_config { | ||
dotnet_framework_version = "v4.0" | ||
scm_type = "LocalGit" | ||
min_tls_version = 1.2 | ||
http2_enabled = false | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
assets/queries/terraform/azure/app_service_http2_disabled/test/positive_expected_result.json
This file contains 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,20 @@ | ||
[ | ||
{ | ||
"queryName": "App Service HTTP2 Disabled", | ||
"severity": "LOW", | ||
"line": 1, | ||
"fileName": "positive1.tf" | ||
}, | ||
{ | ||
"queryName": "App Service HTTP2 Disabled", | ||
"severity": "LOW", | ||
"line": 17, | ||
"fileName": "positive2.tf" | ||
}, | ||
{ | ||
"queryName": "App Service HTTP2 Disabled", | ||
"severity": "LOW", | ||
"line": 21, | ||
"fileName": "positive3.tf" | ||
} | ||
] |