Skip to content

Commit 83ac3dd

Browse files
authored
fix: check only managed load balancers (#369)
* fix: check only managed load balancers Signed-off-by: Nikita Pivkin <[email protected]> * rest: add test cases Signed-off-by: Nikita Pivkin <[email protected]> --------- Signed-off-by: Nikita Pivkin <[email protected]>
1 parent ff19a15 commit 83ac3dd

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

checks/cloud/aws/elb/http_not_used.rego

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import rego.v1
2929

3030
deny contains res if {
3131
some lb in input.aws.elb.loadbalancers
32+
isManaged(lb)
3233
lb.type.value == "application"
3334

3435
some listener in lb.listeners

checks/cloud/aws/elb/http_not_used_test.rego

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ test_allow_http_but_not_application if {
5050
test.assert_empty(check.deny) with input as inp
5151
}
5252

53+
test_allow_not_managed if {
54+
inp := {"aws": {"elb": {"loadbalancers": [{
55+
"__defsec_metadata": {"managed": false},
56+
"type": {"value": "application"},
57+
"listeners": [{
58+
"protocol": {"value": "HTTP"},
59+
"defaultactions": [{"type": {"value": "forward"}}],
60+
}],
61+
}]}}}
62+
63+
test.assert_empty(check.deny) with input as inp
64+
}
65+
5366
test_deny_http_without_redirect if {
5467
inp := {"aws": {"elb": {"loadbalancers": [{
5568
"type": {"value": "application"},

checks/cloud/aws/elb/use_secure_tls_policy.rego

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ outdated_ssl_policies := {
3939

4040
deny contains res if {
4141
some lb in input.aws.elb.loadbalancers
42+
isManaged(lb)
4243
some listener in lb.listeners
4344
has_outdated_policy(listener)
4445
res := result.new("Listener uses an outdated TLS policy.", listener.tlspolicy)

checks/cloud/aws/elb/use_secure_tls_policy_test.rego

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ test_deny_with_outdated_tls_policy if {
1111
test.assert_equal_message("Load balancer listener using TLS v1.0", check.deny) with input as inp
1212
}
1313

14+
test_allow_not_managed if {
15+
inp := {"aws": {"elb": {"loadbalancers": [{
16+
"__defsec_metadata": {"managed": false},
17+
"listeners": [{"tlspolicy": {"value": "ELBSecurityPolicy-TLS-1-0-2015-04"}}],
18+
}]}}}
19+
20+
test.assert_empty(check.deny) with input as inp
21+
}
22+
1423
test_allow_with_actual_tls_policy if {
1524
inp := {"aws": {"elb": {"loadbalancers": [{"listeners": [{"tlspolicy": {"value": "ELBSecurityPolicy-TLS-1-2-2017-01"}}]}]}}}
1625

0 commit comments

Comments
 (0)