-
Notifications
You must be signed in to change notification settings - Fork 544
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' into google-user-iam-grants
- Loading branch information
Showing
19 changed files
with
839 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
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
74 changes: 74 additions & 0 deletions
74
internal/app/tfsec/aws_outdated_tls_policy_elasticsearch_domain_endpoint_test.go
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,74 @@ | ||
package tfsec | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/liamg/tfsec/internal/app/tfsec/scanner" | ||
|
||
"github.com/liamg/tfsec/internal/app/tfsec/checks" | ||
) | ||
|
||
func Test_AWSOutdatedTLSPolicyElasticsearchDomainEndpoint(t *testing.T) { | ||
|
||
var tests = []struct { | ||
name string | ||
source string | ||
mustIncludeResultCode scanner.RuleID | ||
mustExcludeResultCode scanner.RuleID | ||
}{ | ||
{ | ||
name: "check no domain_endpoint_options aws_elasticsearch_domain", | ||
source: ` | ||
resource "aws_elasticsearch_domain" "my_elasticsearch_domain" { | ||
}`, | ||
mustExcludeResultCode: checks.AWSOutdatedTLSPolicyElasticsearchDomainEndpoint, | ||
}, | ||
{ | ||
name: "check tls_security_policy for aws_elasticsearch_domain isn't the default", | ||
source: ` | ||
resource "aws_elasticsearch_domain" "my_elasticsearch_domain" { | ||
domain_name = "domain-foo" | ||
domain_endpoint_options { | ||
enforce_https = true | ||
} | ||
}`, | ||
mustIncludeResultCode: checks.AWSOutdatedTLSPolicyElasticsearchDomainEndpoint, | ||
}, | ||
{ | ||
name: "check tls_security_policy isn't set to TLsv1.0 for aws_elasticsearch_domain", | ||
source: ` | ||
resource "aws_elasticsearch_domain" "my_elasticsearch_domain" { | ||
domain_name = "domain-foo" | ||
domain_endpoint_options { | ||
enforce_https = true | ||
tls_security_policy = "Policy-Min-TLS-1-0-2019-07" | ||
} | ||
}`, | ||
mustIncludeResultCode: checks.AWSOutdatedTLSPolicyElasticsearchDomainEndpoint, | ||
}, | ||
{ | ||
name: "check tls_security_policy is set to TLSv1.2 for aws_elasticsearch_domain", | ||
source: ` | ||
resource "aws_elasticsearch_domain" "my_elasticsearch_domain" { | ||
domain_name = "domain-foo" | ||
domain_endpoint_options { | ||
enforce_https = true | ||
tls_security_policy = "Policy-Min-TLS-1-2-2019-07" | ||
} | ||
}`, | ||
mustExcludeResultCode: checks.AWSOutdatedTLSPolicyElasticsearchDomainEndpoint, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
results := scanSource(test.source) | ||
assertCheckCode(t, test.mustIncludeResultCode, test.mustExcludeResultCode, results) | ||
}) | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
internal/app/tfsec/aws_plaintext_node_to_node_elasticsearch_traffic_test.go
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,60 @@ | ||
package tfsec | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/liamg/tfsec/internal/app/tfsec/scanner" | ||
|
||
"github.com/liamg/tfsec/internal/app/tfsec/checks" | ||
) | ||
|
||
func Test_AWSPlaintextNodeToNodeElasticsearchTraffic(t *testing.T) { | ||
|
||
var tests = []struct { | ||
name string | ||
source string | ||
mustIncludeResultCode scanner.RuleID | ||
mustExcludeResultCode scanner.RuleID | ||
}{ | ||
{ | ||
name: "check no node_to_node_encryption block aws_elasticsearch_domain", | ||
source: ` | ||
resource "aws_elasticsearch_domain" "my_elasticsearch_domain" { | ||
}`, | ||
mustIncludeResultCode: checks.AWSPlaintextNodeToNodeElasticsearchTraffic, | ||
}, | ||
{ | ||
name: "check false enabled attr aws_elasticsearch_domain", | ||
source: ` | ||
resource "aws_elasticsearch_domain" "my_elasticsearch_domain" { | ||
domain_name = "domain-foo" | ||
node_to_node_encryption { | ||
enabled = false | ||
} | ||
}`, | ||
mustIncludeResultCode: checks.AWSPlaintextNodeToNodeElasticsearchTraffic, | ||
}, | ||
{ | ||
name: "check true enabled attr aws_elasticsearch_domain", | ||
source: ` | ||
resource "aws_elasticsearch_domain" "my_elasticsearch_domain" { | ||
domain_name = "domain-foo" | ||
node_to_node_encryption { | ||
enabled = true | ||
} | ||
}`, | ||
mustExcludeResultCode: checks.AWSPlaintextNodeToNodeElasticsearchTraffic, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
results := scanSource(test.source) | ||
assertCheckCode(t, test.mustIncludeResultCode, test.mustExcludeResultCode, results) | ||
}) | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
internal/app/tfsec/aws_unencrypted_at_rest_elasticache_replication_group_test.go
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,47 @@ | ||
package tfsec | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/liamg/tfsec/internal/app/tfsec/scanner" | ||
|
||
"github.com/liamg/tfsec/internal/app/tfsec/checks" | ||
) | ||
|
||
func Test_AWSUnencryptedAtRestElasticacheReplicationGroup(t *testing.T) { | ||
var tests = []struct { | ||
name string | ||
source string | ||
mustIncludeResultCode scanner.RuleID | ||
mustExcludeResultCode scanner.RuleID | ||
}{ | ||
{ | ||
name: "check aws_elasticache_replication_group missing at_rest_encryption_enabled", | ||
source: ` | ||
resource "aws_elasticache_replication_group" "my-resource" { | ||
replication_group_id = "foo" | ||
replication_group_description = "my foo cluster" | ||
}`, | ||
mustIncludeResultCode: checks.AWSUnencryptedAtRestElasticacheReplicationGroup, | ||
}, | ||
{ | ||
name: "check aws_elasticache_replication_group with at_rest_encryption_enabled", | ||
source: ` | ||
resource "aws_elasticache_replication_group" "my-resource" { | ||
replication_group_id = "foo" | ||
replication_group_description = "my foo cluster" | ||
at_rest_encryption_enabled = true | ||
}`, | ||
mustExcludeResultCode: checks.AWSUnencryptedAtRestElasticacheReplicationGroup, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
results := scanSource(test.source) | ||
assertCheckCode(t, test.mustIncludeResultCode, test.mustExcludeResultCode, results) | ||
}) | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
internal/app/tfsec/aws_unencrypted_elasticearch_domain_test.go
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,58 @@ | ||
package tfsec | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/liamg/tfsec/internal/app/tfsec/scanner" | ||
|
||
"github.com/liamg/tfsec/internal/app/tfsec/checks" | ||
) | ||
|
||
func TestAWSUnencryptedElasticsearchDomain(t *testing.T) { | ||
|
||
var tests = []struct { | ||
name string | ||
source string | ||
mustIncludeResultCode scanner.RuleID | ||
mustExcludeResultCode scanner.RuleID | ||
}{ | ||
{ | ||
name: "check no encrypt_at_rest block aws_elasticsearch_domain", | ||
source: ` | ||
resource "aws_elasticsearch_domain" "my_elasticsearch_domain" { | ||
}`, | ||
mustIncludeResultCode: checks.AWSUnencryptedElasticsearchDomain, | ||
}, | ||
{ | ||
name: "check false enabled attr aws_elasticsearch_domain", | ||
source: ` | ||
resource "aws_elasticsearch_domain" "my_elasticsearch_domain" { | ||
domain_name = "domain-foo" | ||
encrypt_at_rest { } | ||
}`, | ||
mustIncludeResultCode: checks.AWSUnencryptedElasticsearchDomain, | ||
}, | ||
{ | ||
name: "check true enabled attr aws_elasticsearch_domain", | ||
source: ` | ||
resource "aws_elasticsearch_domain" "my_elasticsearch_domain" { | ||
domain_name = "domain-foo" | ||
encrypt_at_rest { | ||
enabled = true | ||
} | ||
}`, | ||
mustExcludeResultCode: checks.AWSUnencryptedElasticsearchDomain, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
results := scanSource(test.source) | ||
assertCheckCode(t, test.mustIncludeResultCode, test.mustExcludeResultCode, results) | ||
}) | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
internal/app/tfsec/aws_unencrypted_in_transit_elasticache_replication_group_test.go
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,47 @@ | ||
package tfsec | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/liamg/tfsec/internal/app/tfsec/scanner" | ||
|
||
"github.com/liamg/tfsec/internal/app/tfsec/checks" | ||
) | ||
|
||
func Test_AWSUnencryptedInTransitElasticacheReplicationGroup(t *testing.T) { | ||
var tests = []struct { | ||
name string | ||
source string | ||
mustIncludeResultCode scanner.RuleID | ||
mustExcludeResultCode scanner.RuleID | ||
}{ | ||
{ | ||
name: "check aws_elasticache_replication_group missing transit_encryption_enabled", | ||
source: ` | ||
resource "aws_elasticache_replication_group" "my-resource" { | ||
replication_group_id = "foo" | ||
replication_group_description = "my foo cluster" | ||
}`, | ||
mustIncludeResultCode: checks.AWSUnencryptedInTransitElasticacheReplicationGroup, | ||
}, | ||
{ | ||
name: "check aws_elasticache_replication_group with transit_encryption_enabled", | ||
source: ` | ||
resource "aws_elasticache_replication_group" "my-resource" { | ||
replication_group_id = "foo" | ||
replication_group_description = "my foo cluster" | ||
transit_encryption_enabled = true | ||
}`, | ||
mustExcludeResultCode: checks.AWSUnencryptedInTransitElasticacheReplicationGroup, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
results := scanSource(test.source) | ||
assertCheckCode(t, test.mustIncludeResultCode, test.mustExcludeResultCode, results) | ||
}) | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
internal/app/tfsec/aws_unenforced_https_elasticsearch_domain_endpoint_test.go
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,60 @@ | ||
package tfsec | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/liamg/tfsec/internal/app/tfsec/scanner" | ||
|
||
"github.com/liamg/tfsec/internal/app/tfsec/checks" | ||
) | ||
|
||
func Test_AWSUnenforcedHTTPSElasticsearchDomainEndpoint(t *testing.T) { | ||
|
||
var tests = []struct { | ||
name string | ||
source string | ||
mustIncludeResultCode scanner.RuleID | ||
mustExcludeResultCode scanner.RuleID | ||
}{ | ||
{ | ||
name: "check no domain_endpoint_options aws_elasticsearch_domain", | ||
source: ` | ||
resource "aws_elasticsearch_domain" "my_elasticsearch_domain" { | ||
}`, | ||
mustIncludeResultCode: checks.AWSUnenforcedHTTPSElasticsearchDomainEndpoint, | ||
}, | ||
{ | ||
name: "check false enforce_https attr aws_elasticsearch_domain", | ||
source: ` | ||
resource "aws_elasticsearch_domain" "my_elasticsearch_domain" { | ||
domain_name = "domain-foo" | ||
domain_endpoint_options { | ||
enforce_https = false | ||
} | ||
}`, | ||
mustIncludeResultCode: checks.AWSUnenforcedHTTPSElasticsearchDomainEndpoint, | ||
}, | ||
{ | ||
name: "check true enforce_https aws_elasticsearch_domain", | ||
source: ` | ||
resource "aws_elasticsearch_domain" "my_elasticsearch_domain" { | ||
domain_name = "domain-foo" | ||
domain_endpoint_options { | ||
enforce_https = true | ||
} | ||
}`, | ||
mustExcludeResultCode: checks.AWSUnenforcedHTTPSElasticsearchDomainEndpoint, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
results := scanSource(test.source) | ||
assertCheckCode(t, test.mustIncludeResultCode, test.mustExcludeResultCode, results) | ||
}) | ||
} | ||
|
||
} |
Oops, something went wrong.