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.
Add query to check if there isnt a ConfigRule for Encrypted Volumes C…
- Loading branch information
1 parent
8a701e9
commit 490ee46
Showing
12 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
package generic.cloudformation | ||
|
||
getResourcesByType(resources, type) = list { | ||
list = [resource | resources[i].Type == type; resource := resources[i]] | ||
} |
2 changes: 1 addition & 1 deletion
2
assets/queries/ansible/aws/config_rule_for_encrypted_volumes_is_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
2 changes: 1 addition & 1 deletion
2
...ible/aws/config_rule_for_encrypted_volumes_is_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
9 changes: 9 additions & 0 deletions
9
assets/queries/cloudFormation/config_rule_for_encryption_volumes_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,9 @@ | ||
{ | ||
"id": "1b6322d9-c755-4f8c-b804-32c19250f2d9", | ||
"queryName": "Config Rule For Encrypted Volumes Disabled", | ||
"severity": "MEDIUM", | ||
"category": "Encryption", | ||
"descriptionText": "Check if AWS config rules do not identify Encrypted Volumes as a source.", | ||
"descriptionUrl": "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-config-configrule.html#cfn-config-configrule-source", | ||
"platform": "CloudFormation" | ||
} |
29 changes: 29 additions & 0 deletions
29
assets/queries/cloudFormation/config_rule_for_encryption_volumes_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,29 @@ | ||
package Cx | ||
|
||
import data.generic.cloudformation as cfLib | ||
|
||
CxPolicy[result] { | ||
resources := input.document[i].Resources | ||
configRules := cfLib.getResourcesByType(resources, "AWS::Config::ConfigRule") | ||
|
||
count(configRules) > 0 | ||
not hasEncryptedVolsRule(configRules) | ||
|
||
firstRule := resources[name] | ||
firstRule.Type == "AWS::Config::ConfigRule" | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"searchKey": sprintf("Resources.%s", [name]), | ||
"issueType": "MissingAttribute", | ||
"keyExpectedValue": "There is a ConfigRule for encrypted volumes.", | ||
"keyActualValue": "There isn't a ConfigRule for encrypted volumes." | ||
} | ||
} | ||
|
||
hasEncryptedVolsRule(configRules) { | ||
configRule := configRules[_] | ||
source := configRule.Properties.Source | ||
source_id := source.SourceIdentifier | ||
source_id == "ENCRYPTED_VOLUMES" | ||
} |
12 changes: 12 additions & 0 deletions
12
...ts/queries/cloudFormation/config_rule_for_encryption_volumes_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,12 @@ | ||
Resources: | ||
ConfigRule: | ||
Type: AWS::Config::ConfigRule | ||
Properties: | ||
ConfigRuleName: access-keys-rotated | ||
InputParameters: | ||
maxAccessKeyAge: 90 | ||
Source: | ||
Owner: AWS | ||
SourceIdentifier: ENCRYPTED_VOLUMES | ||
MaximumExecutionFrequency: TwentyFour_Hours | ||
|
18 changes: 18 additions & 0 deletions
18
...ts/queries/cloudFormation/config_rule_for_encryption_volumes_disabled/test/negative2.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,18 @@ | ||
{ | ||
"Resources": { | ||
"ConfigRule": { | ||
"Type": "AWS::Config::ConfigRule", | ||
"Properties": { | ||
"MaximumExecutionFrequency": "TwentyFour_Hours", | ||
"ConfigRuleName": "access-keys-rotated", | ||
"InputParameters": { | ||
"maxAccessKeyAge": 90 | ||
}, | ||
"Source": { | ||
"SourceIdentifier": "ENCRYPTED_VOLUMES", | ||
"Owner": "AWS" | ||
} | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ts/queries/cloudFormation/config_rule_for_encryption_volumes_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,12 @@ | ||
Resources: | ||
ConfigRule: | ||
Type: AWS::Config::ConfigRule | ||
Properties: | ||
ConfigRuleName: access-keys-rotated | ||
InputParameters: | ||
maxAccessKeyAge: 100 | ||
Source: | ||
Owner: AWS | ||
SourceIdentifier: ACCESS_KEYS_ROTATED | ||
MaximumExecutionFrequency: TwentyFour_Hours | ||
|
18 changes: 18 additions & 0 deletions
18
...ts/queries/cloudFormation/config_rule_for_encryption_volumes_disabled/test/positive2.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,18 @@ | ||
{ | ||
"Resources": { | ||
"ConfigRule": { | ||
"Type": "AWS::Config::ConfigRule", | ||
"Properties": { | ||
"ConfigRuleName": "access-keys-rotated", | ||
"InputParameters": { | ||
"maxAccessKeyAge": 100 | ||
}, | ||
"Source": { | ||
"Owner": "AWS", | ||
"SourceIdentifier": "ACCESS_KEYS_ROTATED" | ||
}, | ||
"MaximumExecutionFrequency": "TwentyFour_Hours" | ||
} | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...dFormation/config_rule_for_encryption_volumes_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,14 @@ | ||
[ | ||
{ | ||
"queryName": "Config Rule For Encrypted Volumes Disabled", | ||
"severity": "MEDIUM", | ||
"line": 2, | ||
"fileName": "positive1.yaml" | ||
}, | ||
{ | ||
"fileName": "positive2.json", | ||
"queryName": "Config Rule For Encrypted Volumes Disabled", | ||
"severity": "MEDIUM", | ||
"line": 3 | ||
} | ||
] |
2 changes: 1 addition & 1 deletion
2
assets/queries/terraform/aws/config_rule_for_encrypted_volumes_is_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
2 changes: 1 addition & 1 deletion
2
...form/aws/config_rule_for_encrypted_volumes_is_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