-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6678 from Checkmarx/kics-767-pulumi
feat(query): pulumi ECS Cluster with Container Insights Disabled
- Loading branch information
Showing
7 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
assets/queries/pulumi/aws/ecs_cluster_container_insights_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": "abcefee4-a0c1-4245-9f82-a473f79a9e2f", | ||
"queryName": "ECS Cluster with Container Insights Disabled", | ||
"severity": "LOW", | ||
"category": "Observability", | ||
"descriptionText": "ECS Cluster should enable container insights", | ||
"descriptionUrl": "https://www.pulumi.com/registry/packages/aws/api-docs/ecs/cluster/#settings_yaml", | ||
"platform": "Pulumi", | ||
"descriptionID": "6fd99865", | ||
"cloudProvider": "aws" | ||
} |
45 changes: 45 additions & 0 deletions
45
assets/queries/pulumi/aws/ecs_cluster_container_insights_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,45 @@ | ||
package Cx | ||
|
||
import data.generic.common as common_lib | ||
import data.generic.pulumi as plm_lib | ||
|
||
CxPolicy[result] { | ||
resource := input.document[i].resources[name] | ||
resource.type == "aws:ecs:Cluster" | ||
|
||
not common_lib.valid_key(resource.properties, "settings") | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"resourceType": resource.type, | ||
"resourceName": plm_lib.getResourceName(resource, name), | ||
"searchKey": sprintf("resources[%s].properties", [name]), | ||
"issueType": "MissingAttribute", | ||
"keyExpectedValue": "Attribute 'settings' should be defined and have a ClusterSetting named 'containerInsights' which value is 'enabled'", | ||
"keyActualValue": "Attribute 'settings' is not defined", | ||
"searchLine": common_lib.build_search_line(["resources", name, "properties"], []), | ||
} | ||
} | ||
|
||
CxPolicy[result] { | ||
resource := input.document[i].resources[name] | ||
resource.type == "aws:ecs:Cluster" | ||
|
||
not containerInsights(resource.properties.settings) | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"resourceType": resource.type, | ||
"resourceName": plm_lib.getResourceName(resource, name), | ||
"searchKey": sprintf("resources[%s].properties.settings", [name]), | ||
"issueType": "IncorrectValue", | ||
"keyExpectedValue": "Attribute 'settings' should have a ClusterSetting named 'containerInsights' which value is 'enabled'", | ||
"keyActualValue": "Attribute 'settings' doesn't have a ClusterSetting named 'containerInsights' which value is 'enabled'", | ||
"searchLine": common_lib.build_search_line(["resources", name, "properties","settings"], []), | ||
} | ||
} | ||
|
||
containerInsights(settings){ | ||
settings[0].name == "containerInsights" | ||
settings[0].value == "enabled" | ||
} |
10 changes: 10 additions & 0 deletions
10
assets/queries/pulumi/aws/ecs_cluster_container_insights_disabled/test/negative1.yaml
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,10 @@ | ||
name: aws-eks | ||
runtime: yaml | ||
description: An EKS cluster | ||
resources: | ||
foo: | ||
type: aws:ecs:Cluster | ||
properties: | ||
settings: | ||
- name: containerInsights | ||
value: enabled |
10 changes: 10 additions & 0 deletions
10
assets/queries/pulumi/aws/ecs_cluster_container_insights_disabled/test/positive1.yaml
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,10 @@ | ||
name: aws-eks | ||
runtime: yaml | ||
description: An EKS cluster | ||
resources: | ||
foo: | ||
type: aws:ecs:Cluster | ||
properties: | ||
settings: | ||
- name: containerInsights | ||
value: disabled |
8 changes: 8 additions & 0 deletions
8
assets/queries/pulumi/aws/ecs_cluster_container_insights_disabled/test/positive2.yaml
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,8 @@ | ||
name: aws-eks | ||
runtime: yaml | ||
description: An EKS cluster | ||
resources: | ||
foo: | ||
type: aws:ecs:Cluster | ||
properties: | ||
settings: [] |
8 changes: 8 additions & 0 deletions
8
assets/queries/pulumi/aws/ecs_cluster_container_insights_disabled/test/positive3.yaml
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,8 @@ | ||
name: aws-eks | ||
runtime: yaml | ||
description: An EKS cluster | ||
resources: | ||
foo: | ||
type: aws:ecs:Cluster | ||
properties: | ||
description: example |
20 changes: 20 additions & 0 deletions
20
...ies/pulumi/aws/ecs_cluster_container_insights_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": "ECS Cluster with Container Insights Disabled", | ||
"severity": "LOW", | ||
"line": 8, | ||
"fileName": "positive1.yaml" | ||
}, | ||
{ | ||
"queryName": "ECS Cluster with Container Insights Disabled", | ||
"severity": "LOW", | ||
"line": 8, | ||
"fileName": "positive2.yaml" | ||
}, | ||
{ | ||
"queryName": "ECS Cluster with Container Insights Disabled", | ||
"severity": "LOW", | ||
"line": 7, | ||
"fileName": "positive3.yaml" | ||
} | ||
] |