-
Notifications
You must be signed in to change notification settings - Fork 509
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 #267 from accurics/terrascan-v1.0-policy-support
Terrascan v1.0 policy support
- Loading branch information
Showing
112 changed files
with
2,180 additions
and
30 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
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
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
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,24 @@ | ||
package file | ||
|
||
// Info File info | ||
type Info struct { | ||
Path string | ||
Hash string | ||
HashType string | ||
Attributes string | ||
} | ||
|
||
// Group Group metadata | ||
type Group struct { | ||
Name string | ||
IsReadOnly bool | ||
VerifySignatures bool | ||
Directories []*Info | ||
Files []*Info | ||
} | ||
|
||
// Metadata File metadata | ||
type Metadata struct { | ||
Version string | ||
Groups []*Group | ||
} |
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
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
13 changes: 13 additions & 0 deletions
13
.../aws/aws_cloudfront_distribution/AWS.CloudFront.EncryptionandKeyManagement.High.0407.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,13 @@ | ||
{ | ||
"ruleName": "cloudfrontNoHTTPSTraffic", | ||
"file": "cloudfrontNoHTTPSTraffic.rego", | ||
"ruleTemplate": "cloudfrontNoHTTPSTraffic", | ||
"ruleTemplateArgs": { | ||
"prefix": "" | ||
}, | ||
"severity": "HIGH", | ||
"description": "Use encrypted connection between CloudFront and origin server", | ||
"ruleReferenceId": "AWS.CloudFront.EncryptionandKeyManagement.High.0407", | ||
"category": "Encryption and Key Management", | ||
"version": 2 | ||
} |
13 changes: 13 additions & 0 deletions
13
.../aws/aws_cloudfront_distribution/AWS.CloudFront.EncryptionandKeyManagement.High.0408.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,13 @@ | ||
{ | ||
"ruleName": "cloudfrontNoSecureCiphers", | ||
"file": "cloudfrontNoSecureCiphers.rego", | ||
"ruleTemplate": "cloudfrontNoSecureCiphers", | ||
"ruleTemplateArgs": { | ||
"prefix": "" | ||
}, | ||
"severity": "HIGH", | ||
"description": "Secure ciphers are not used in CloudFront distribution", | ||
"ruleReferenceId": "AWS.CloudFront.EncryptionandKeyManagement.High.0408", | ||
"category": "Encryption and Key Management", | ||
"version": 2 | ||
} |
13 changes: 13 additions & 0 deletions
13
...policies/opa/rego/aws/aws_cloudfront_distribution/AWS.CloudFront.Logging.Medium.0567.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,13 @@ | ||
{ | ||
"ruleName": "cloudfrontNoLogging", | ||
"file": "cloudfrontNoLogging.rego", | ||
"ruleTemplate": "cloudfrontNoLogging", | ||
"ruleTemplateArgs": { | ||
"prefix": "" | ||
}, | ||
"severity": "MEDIUM", | ||
"description": "Ensure that your AWS Cloudfront distributions have the Logging feature enabled in order to track all viewer requests for the content delivered through the Content Delivery Network (CDN).", | ||
"ruleReferenceId": "AWS.CloudFront.Logging.Medium.0567", | ||
"category": "Logging", | ||
"version": 2 | ||
} |
10 changes: 10 additions & 0 deletions
10
pkg/policies/opa/rego/aws/aws_cloudfront_distribution/cloudfrontNoHTTPSTraffic.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,10 @@ | ||
package accurics | ||
|
||
{{.prefix}}cloudfrontNoHTTPSTraffic[retVal]{ | ||
cloudfront = input.aws_cloudfront_distribution[_] | ||
some i | ||
orderedcachebehaviour = cloudfront.config.ordered_cache_behavior[i] | ||
orderedcachebehaviour.viewer_protocol_policy == "allow-all" | ||
traverse := sprintf("ordered_cache_behavior[%d].viewer_protocol_policy", [i]) | ||
retVal := { "Id": cloudfront.id, "ReplaceType": "edit", "CodeType": "attribute", "Traverse": traverse, "Attribute": "ordered_cache_behavior.viewer_protocol_policy", "AttributeDataType": "string", "Expected": "redirect-to-https", "Actual": orderedcachebehaviour.viewer_protocol_policy } | ||
} |
21 changes: 21 additions & 0 deletions
21
pkg/policies/opa/rego/aws/aws_cloudfront_distribution/cloudfrontNoLogging.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,21 @@ | ||
package accurics | ||
|
||
{{.prefix}}cloudfrontNoLogging[retVal]{ | ||
cloudfront = input.aws_cloudfront_distribution[_] | ||
not cloudfront.config.logging_config | ||
|
||
rc = "ewogICJsb2dnaW5nX2NvbmZpZyI6IHsKICAgICJpbmNsdWRlX2Nvb2tpZXMiOiBmYWxzZSwKICAgICJidWNrZXQiOiAiPGJ1Y2tldD4iLAogICAgInByZWZpeCI6ICI8cHJlZml4PiIKICB9Cn0=" | ||
|
||
traverse = "" | ||
retVal := { "Id": cloudfront.id, "ReplaceType": "add", "CodeType": "block", "Traverse": traverse, "Attribute": "logging_config", "AttributeDataType": "base64", "Expected": rc, "Actual": null } | ||
} | ||
|
||
{{.prefix}}cloudfrontNoLogging[retVal]{ | ||
cloudfront = input.aws_cloudfront_distribution[_] | ||
cloudfront.config.logging_config == [] | ||
|
||
rc = "ewogICJsb2dnaW5nX2NvbmZpZyI6IHsKICAgICJpbmNsdWRlX2Nvb2tpZXMiOiBmYWxzZSwKICAgICJidWNrZXQiOiAiPGJ1Y2tldD4iLAogICAgInByZWZpeCI6ICI8cHJlZml4PiIKICB9Cn0=" | ||
|
||
traverse = "" | ||
retVal := { "Id": cloudfront.id, "ReplaceType": "add", "CodeType": "block", "Traverse": traverse, "Attribute": "logging_config", "AttributeDataType": "base64", "Expected": rc, "Actual": null } | ||
} |
19 changes: 19 additions & 0 deletions
19
pkg/policies/opa/rego/aws/aws_cloudfront_distribution/cloudfrontNoSecureCiphers.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,19 @@ | ||
package accurics | ||
|
||
{{.prefix}}cloudfrontNoSecureCiphers[retVal]{ | ||
cloudfront = input.aws_cloudfront_distribution[_] | ||
some i | ||
certificate = cloudfront.config.viewer_certificate[i] | ||
certificate.cloudfront_default_certificate = false | ||
not minimumAllowedProtocolVersion(certificate.minimum_protocol_version) | ||
traverse := sprintf("viewer_certificate[%d].minimum_protocol_version", [i]) | ||
retVal := { "Id": cloudfront.id, "ReplaceType": "edit", "CodeType": "attribute", "Traverse": traverse, "Attribute": "viewer_certificate.minimum_protocol_version", "AttributeDataType": "string", "Expected": "TLSv1.2", "Actual": certificate.minimum_protocol_version } | ||
} | ||
|
||
minimumAllowedProtocolVersion(currentVersion) { | ||
currentVersion == "TLSv1.1" | ||
} | ||
|
||
minimumAllowedProtocolVersion(currentVersion) { | ||
currentVersion == "TLSv1.2" | ||
} |
13 changes: 13 additions & 0 deletions
13
pkg/policies/opa/rego/aws/aws_cloudtrail/AWS.CloudTrail.Logging.High.0399.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,13 @@ | ||
{ | ||
"ruleName": "cloudTrailLogNotEncrypted", | ||
"file": "cloudTrailLogNotEncrypted.rego", | ||
"ruleTemplate": "cloudTrailLogNotEncrypted", | ||
"ruleTemplateArgs": { | ||
"prefix": "" | ||
}, | ||
"severity": "HIGH", | ||
"description": "Cloud Trail Log Not Enabled", | ||
"ruleReferenceId": "AWS.CloudTrail.Logging.High.0399", | ||
"category": "Logging", | ||
"version": 2 | ||
} |
13 changes: 13 additions & 0 deletions
13
pkg/policies/opa/rego/aws/aws_cloudtrail/AWS.CloudTrail.Logging.Low.0559.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,13 @@ | ||
{ | ||
"ruleName": "reme_enableSNSTopic", | ||
"file": "enableSNSTopic.rego", | ||
"ruleTemplate": "enableSNSTopic", | ||
"ruleTemplateArgs": { | ||
"prefix": "reme_" | ||
}, | ||
"severity": "MEDIUM", | ||
"description": "Ensure appropriate subscribers to each SNS topic", | ||
"ruleReferenceId": "AWS.CloudTrail.Logging.Low.0559", | ||
"category": "Logging", | ||
"version": 0 | ||
} |
13 changes: 13 additions & 0 deletions
13
pkg/policies/opa/rego/aws/aws_cloudtrail/AWS.CloudTrail.Logging.Medium.0460.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,13 @@ | ||
{ | ||
"ruleName": "cloudTrailMultiRegionNotCreated", | ||
"file": "cloudTrailMultiRegionNotCreated.rego", | ||
"ruleTemplate": "cloudTrailMultiRegionNotCreated", | ||
"ruleTemplateArgs": { | ||
"prefix": "" | ||
}, | ||
"severity": "MEDIUM", | ||
"description": "Cloud Trail Multi Region not enabled", | ||
"ruleReferenceId": "AWS.CloudTrail.Logging.Medium.0460", | ||
"category": "Logging", | ||
"version": 2 | ||
} |
9 changes: 9 additions & 0 deletions
9
pkg/policies/opa/rego/aws/aws_cloudtrail/cloudTrailLogNotEncrypted.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,9 @@ | ||
package accurics | ||
|
||
{{.prefix}}cloudTrailLogNotEncrypted[retVal]{ | ||
cloud_trail = input.aws_cloudtrail[_] | ||
cloud_trail.config.kms_key_id == null | ||
|
||
traverse = "kms_key_id" | ||
retVal := { "Id": cloud_trail.id, "ReplaceType": "edit", "CodeType": "attribute", "Traverse": traverse, "Attribute": "kms_key_id", "AttributeDataType": "string", "Expected": "<kms_key_id>", "Actual": cloud_trail.config.kms_key_id } | ||
} |
9 changes: 9 additions & 0 deletions
9
pkg/policies/opa/rego/aws/aws_cloudtrail/cloudTrailMultiRegionNotCreated.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,9 @@ | ||
package accurics | ||
|
||
{{.prefix}}cloudTrailMultiRegionNotCreated[retVal]{ | ||
cloud_trail = input.aws_cloudtrail[_] | ||
cloud_trail.config.is_multi_region_trail == false | ||
|
||
traverse = "is_multi_region_trail" | ||
retVal := { "Id": cloud_trail.id, "ReplaceType": "edit", "CodeType": "attribute", "Traverse": traverse, "Attribute": "is_multi_region_trail", "AttributeDataType": "bool", "Expected": true, "Actual": cloud_trail.config.is_multi_region_trail } | ||
} |
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,6 @@ | ||
package accurics | ||
|
||
{{.prefix}}enableSNSTopic[sns.id] { | ||
sns := input.aws_cloudtrail[_] | ||
sns.config.sns_topic_name == null | ||
} |
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,13 @@ | ||
{ | ||
"ruleName": "rdsPubliclyAccessible", | ||
"file": "rdsPubliclyAccessible.rego", | ||
"ruleTemplate": "rdsPubliclyAccessible", | ||
"ruleTemplateArgs": { | ||
"prefix": "" | ||
}, | ||
"severity": "HIGH", | ||
"description": "RDS Instance publicly_accessible flag is true", | ||
"ruleReferenceId": "", | ||
"category": "Data Security", | ||
"version": 2 | ||
} |
9 changes: 9 additions & 0 deletions
9
pkg/policies/opa/rego/aws/aws_db_instance/rdsPubliclyAccessible.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,9 @@ | ||
package accurics | ||
|
||
{{.prefix}}rdsPubliclyAccessible[retVal] { | ||
db := input.aws_db_instance[_] | ||
db.config.publicly_accessible == true | ||
traverse = "publicly_accessible" | ||
retVal := { "Id": db.id, "ReplaceType": "edit", "CodeType": "attribute", "Traverse": traverse, "Attribute": "publicly_accessible", "AttributeDataType": "bool", "Expected": false, "Actual": db.config.publicly_accessible } | ||
} | ||
|
13 changes: 13 additions & 0 deletions
13
pkg/policies/opa/rego/aws/aws_iam_access_key/AWS.IamUser.IAM.High.0390.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,13 @@ | ||
{ | ||
"ruleName": "noAccessKeyForRootAccount", | ||
"file": "noAccessKeyForRootAccount.rego", | ||
"ruleTemplate": "noAccessKeyForRootAccount", | ||
"ruleTemplateArgs": { | ||
"prefix": "" | ||
}, | ||
"severity": "HIGH", | ||
"description": "The root account is the most privileged user in an AWS account. AWS Access Keys provide programmatic access to a given AWS account. It is recommended that all access keys associated with the root account be removed. Removing access keys associated with the root account limits vectors by which the account can be compromised. Additionally, removing the root access keys encourages the creation and use of role based accounts that are least privileged.", | ||
"ruleReferenceId": "AWS.IamUser.IAM.High.0390", | ||
"category": "Identity and Access Management", | ||
"version": 2 | ||
} |
20 changes: 20 additions & 0 deletions
20
pkg/policies/opa/rego/aws/aws_iam_access_key/noAccessKeyForRootAccount.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,20 @@ | ||
package accurics | ||
|
||
{{.prefix}}noAccessKeyForRootAccount[retVal] { | ||
access := input.aws_iam_access_key[_] | ||
access.type == "aws_iam_access_key" | ||
status = getStatus(access.config) | ||
status == "Active" | ||
access.config.user == "root" | ||
traverse = "status" | ||
retVal := { "Id": access.id, "ReplaceType": "edit", "CodeType": "attribute", "Traverse": traverse, "Attribute": "status", "AttributeDataType": "string", "Expected": "Inactive", "Actual": access.config.status } | ||
} | ||
|
||
getStatus(config) = "Active" { | ||
# defaults to Active | ||
not config.status | ||
} | ||
|
||
getStatus(config) = "Active" { | ||
config.status == "Active" | ||
} |
14 changes: 14 additions & 0 deletions
14
pkg/policies/opa/rego/aws/aws_iam_account_password_policy/AWS.Iam.IAM.Low.0540.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 @@ | ||
{ | ||
"ruleName": "passwordRotateEvery90Days", | ||
"file": "passwordRotateEvery90Days.rego", | ||
"ruleTemplate": "passwordRotateEvery90Days", | ||
"ruleTemplateArgs": { | ||
"name": "passwordRotateEvery90Days", | ||
"prefix": "" | ||
}, | ||
"severity": "LOW", | ||
"description": "Reducing the password lifetime increases account resiliency against brute force login attempts", | ||
"ruleReferenceId": "AWS.Iam.IAM.Low.0540", | ||
"category": "IAM", | ||
"version": 2 | ||
} |
15 changes: 15 additions & 0 deletions
15
pkg/policies/opa/rego/aws/aws_iam_account_password_policy/AWS.Iam.IAM.Medium.0454.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,15 @@ | ||
{ | ||
"ruleName": "passwordRequireLowerCase", | ||
"file": "passwordPolicyRequirement.rego", | ||
"ruleTemplate": "passwordRequireLowerCase", | ||
"ruleTemplateArgs": { | ||
"name": "passwordRequireLowerCase", | ||
"prefix": "", | ||
"required_parameter": "require_lowercase_characters" | ||
}, | ||
"severity": "MEDIUM", | ||
"description": "Lower case alphabet not present in the Password, Password Complexity is not high. Increased Password complexity increases resiliency against brute force attack", | ||
"ruleReferenceId": "AWS.Iam.IAM.Medium.0454", | ||
"category": "IAM", | ||
"version": 2 | ||
} |
15 changes: 15 additions & 0 deletions
15
pkg/policies/opa/rego/aws/aws_iam_account_password_policy/AWS.Iam.IAM.Medium.0455.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,15 @@ | ||
{ | ||
"ruleName": "passwordRequireNumber", | ||
"file": "passwordPolicyRequirement.rego", | ||
"ruleTemplate": "passwordRequireNumber", | ||
"ruleTemplateArgs": { | ||
"name": "passwordRequireNumber", | ||
"prefix": "", | ||
"required_parameter": "require_numbers" | ||
}, | ||
"severity": "MEDIUM", | ||
"description": "Number not present in the Password, Password Complexity is not high. Increased Password complexity increases resiliency against brute force attack", | ||
"ruleReferenceId": "AWS.Iam.IAM.Medium.0455", | ||
"category": "IAM", | ||
"version": 2 | ||
} |
Oops, something went wrong.