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.
Merge branch 'master' of https://github.com/Checkmarx/kics into kics/892
- Loading branch information
Showing
9 changed files
with
372 additions
and
209 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
assets/queries/pulumi/aws/docdb_logging_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": "2ca87964-fe7e-4cdc-899c-427f0f3525f8", | ||
"queryName": "DocDB Logging Is Disabled", | ||
"severity": "LOW", | ||
"category": "Observability", | ||
"descriptionText": "DocDB logging should be enabled", | ||
"descriptionUrl": "https://www.pulumi.com/registry/packages/aws/api-docs/docdb/cluster/#enabledcloudwatchlogsexports_yaml", | ||
"platform": "Pulumi", | ||
"descriptionID": "c5bd58cd", | ||
"cloudProvider": "aws" | ||
} |
49 changes: 49 additions & 0 deletions
49
assets/queries/pulumi/aws/docdb_logging_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,49 @@ | ||
package Cx | ||
|
||
import data.generic.common as common_lib | ||
|
||
validTypes := {"profiler", "audit"} | ||
|
||
validTypeConcat := concat(", ", validTypes) | ||
|
||
CxPolicy[result] { | ||
resource := input.document[i].resources[name] | ||
resource.type == "aws:docdb:Cluster" | ||
properties := resource.properties | ||
not common_lib.valid_key(properties, "enabledCloudwatchLogsExports") | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"resourceType": resource.type, | ||
"resourceName": name, | ||
"searchKey": sprintf("resources[%s].properties", [name]), | ||
"searchLine": common_lib.build_search_line(["resources", name, "properties"],[]), | ||
"issueType": "MissingAttribute", | ||
"keyExpectedValue": "aws:docdb:Cluster.enabledCloudwatchLogsExports should be defined", | ||
"keyActualValue": "aws:docdb:Cluster.enabledCloudwatchLogsExports is undefined", | ||
} | ||
} | ||
|
||
|
||
CxPolicy[result] { | ||
resource := input.document[i].resources[name] | ||
resource.type == "aws:docdb:Cluster" | ||
properties := resource.properties | ||
logs := properties.enabledCloudwatchLogsExports | ||
|
||
logsSet := {log | log := logs[_]} | ||
missingTypes := validTypes - logsSet | ||
|
||
count(missingTypes) > 0 | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"resourceType": resource.type, | ||
"resourceName": name, | ||
"searchKey": sprintf("resources[%s].properties.enabledCloudwatchLogsExports", [name]), | ||
"searchLine": common_lib.build_search_line(["resources", name, "properties", "enabledCloudwatchLogsExports"],[]), | ||
"issueType": "IncorrectValue", | ||
"keyExpectedValue": sprintf("aws:docdb:Cluster.enabledCloudwatchLogsExports should have all following values: %s", [validTypeConcat]), | ||
"keyActualValue": sprintf("aws:docdb:Cluster.enabledCloudwatchLogsExports has the following missing values: %s", [concat(", ", missingTypes)]), | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
assets/queries/pulumi/aws/docdb_logging_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,20 @@ | ||
name: my-pulumi-project | ||
runtime: nodejs | ||
|
||
config: | ||
aws:region: us-east-1 | ||
|
||
resources: | ||
aws:docdb/cluster: | ||
type: aws:docdb:Cluster | ||
properties: | ||
backupRetentionPeriod: 5 | ||
clusterIdentifier: my-docdb-cluster | ||
engine: docdb | ||
masterPassword: mustbeeightchars | ||
masterUsername: foo | ||
preferredBackupWindow: 07:00-09:00 | ||
skipFinalSnapshot: true | ||
enabledCloudwatchLogsExports: | ||
- audit | ||
- profiler |
17 changes: 17 additions & 0 deletions
17
assets/queries/pulumi/aws/docdb_logging_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,17 @@ | ||
name: my-pulumi-project | ||
runtime: nodejs | ||
|
||
config: | ||
aws:region: us-east-1 | ||
|
||
resources: | ||
aws:docdb/cluster: | ||
type: aws:docdb:Cluster | ||
properties: | ||
backupRetentionPeriod: 5 | ||
clusterIdentifier: my-docdb-cluster | ||
engine: docdb | ||
masterPassword: mustbeeightchars | ||
masterUsername: foo | ||
preferredBackupWindow: 07:00-09:00 | ||
skipFinalSnapshot: true |
18 changes: 18 additions & 0 deletions
18
assets/queries/pulumi/aws/docdb_logging_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,18 @@ | ||
name: my-pulumi-project | ||
runtime: nodejs | ||
|
||
config: | ||
aws:region: us-east-1 | ||
|
||
resources: | ||
aws:docdb/cluster: | ||
type: aws:docdb:Cluster | ||
properties: | ||
backupRetentionPeriod: 5 | ||
clusterIdentifier: my-docdb-cluster | ||
engine: docdb | ||
masterPassword: mustbeeightchars | ||
masterUsername: foo | ||
preferredBackupWindow: 07:00-09:00 | ||
skipFinalSnapshot: true | ||
enabledCloudwatchLogsExports: [] |
19 changes: 19 additions & 0 deletions
19
assets/queries/pulumi/aws/docdb_logging_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,19 @@ | ||
name: my-pulumi-project | ||
runtime: nodejs | ||
|
||
config: | ||
aws:region: us-east-1 | ||
|
||
resources: | ||
aws:docdb/cluster: | ||
type: aws:docdb:Cluster | ||
properties: | ||
backupRetentionPeriod: 5 | ||
clusterIdentifier: my-docdb-cluster | ||
engine: docdb | ||
masterPassword: mustbeeightchars | ||
masterUsername: foo | ||
preferredBackupWindow: 07:00-09:00 | ||
skipFinalSnapshot: true | ||
enabledCloudwatchLogsExports: | ||
- audit |
20 changes: 20 additions & 0 deletions
20
assets/queries/pulumi/aws/docdb_logging_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": "DocDB Logging Is Disabled", | ||
"severity": "LOW", | ||
"line": 10, | ||
"filename": "positive1.yaml" | ||
}, | ||
{ | ||
"queryName": "DocDB Logging Is Disabled", | ||
"severity": "LOW", | ||
"line": 18, | ||
"filename": "positive2.yaml" | ||
}, | ||
{ | ||
"queryName": "DocDB Logging Is Disabled", | ||
"severity": "LOW", | ||
"line": 18, | ||
"filename": "positive3.yaml" | ||
} | ||
] |
Oops, something went wrong.