Skip to content

Commit

Permalink
fix(terraform): Fix range issue in OCI RDP check (#5832)
Browse files Browse the repository at this point in the history
Fix range
  • Loading branch information
tsmithv11 authored Dec 6, 2023
1 parent a80ecbe commit d15da42
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
32 changes: 22 additions & 10 deletions checkov/terraform/checks/graph_checks/oci/OCI_NSGNotAllowRDP.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,17 @@ definition:
operator: "not_equals"
value: 3389

- cond_type: "attribute"
resource_types: "oci_core_network_security_group_security_rule"
attribute: "tcp_options.destination_port_range.min"
operator: "greater_than"
value: 3389
- or:
- cond_type: "attribute"
resource_types: "oci_core_network_security_group_security_rule"
attribute: "tcp_options.destination_port_range.min"
operator: "greater_than"
value: 3389
- cond_type: "attribute"
resource_types: "oci_core_network_security_group_security_rule"
attribute: "tcp_options.destination_port_range.max"
operator: "less_than"
value: 3389

- and:
- cond_type: "attribute"
Expand All @@ -61,8 +67,14 @@ definition:
operator: "not_equals"
value: 3389

- cond_type: "attribute"
resource_types: "oci_core_network_security_group_security_rule"
attribute: "udp_options.destination_port_range.min"
operator: "greater_than"
value: 3389
- or:
- cond_type: "attribute"
resource_types: "oci_core_network_security_group_security_rule"
attribute: "udp_options.destination_port_range.min"
operator: "greater_than"
value: 3389
- cond_type: "attribute"
resource_types: "oci_core_network_security_group_security_rule"
attribute: "udp_options.destination_port_range.max"
operator: "less_than"
value: 3389
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pass:
- "oci_core_network_security_group_security_rule.pass_1"
- "oci_core_network_security_group_security_rule.pass_2"
- "oci_core_network_security_group_security_rule.pass_3"

fail:
- "oci_core_network_security_group_security_rule.fail_1"
Expand Down
18 changes: 18 additions & 0 deletions tests/terraform/graph/checks/resources/OCI_NSGNotAllowRDP/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,21 @@ resource "oci_core_network_security_group_security_rule" "fail_2" {
}


resource "oci_core_network_security_group_security_rule" "pass_3" {
count = (var.nsg_id == "" ? 1:0)

network_security_group_id = oci_core_network_security_group.network_security_group[0].id
direction = "EGRESS"
protocol = "6" #tcp

description = "rule_allow_22_e_within"
destination = oci_core_network_security_group.network_security_group[0].id
destination_type = "NETWORK_SECURITY_GROUP"

tcp_options {
destination_port_range {
max = 22
min = 22
}
}
}

0 comments on commit d15da42

Please sign in to comment.