-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(checks): align AVD-AWS-0107 and AVD-AWS-0105 checks with CIS Benc…
…hmarks Signed-off-by: Nikita Pivkin <[email protected]>
- Loading branch information
Showing
14 changed files
with
189 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
Set a more restrictive cidr range | ||
Set a more restrictive CIDR range | ||
|
||
```yaml--- | ||
Resources: | ||
|
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
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,52 @@ | ||
# METADATA | ||
# custom: | ||
# library: true | ||
# input: | ||
# selector: | ||
# - type: cloud | ||
package lib.net | ||
|
||
import rego.v1 | ||
|
||
ssh_port := 22 | ||
|
||
rdp_port := 3389 | ||
|
||
all_ips := {"0.0.0.0/0", "0000:0000:0000:0000:0000:0000:0000:0000/0", "::/0"} | ||
|
||
# "-1" or "all" equivalent to all protocols | ||
# https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AuthorizeSecurityGroupIngress.html | ||
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_firewall#protocol | ||
all_protocols := {"-1", "all"} | ||
|
||
# "6" is ID of TCP | ||
# https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml | ||
is_tcp_protocol(protocol) if protocol in {"tcp", "6"} | ||
|
||
is_tcp_protocol(protocol) if protocol in all_protocols | ||
|
||
# "17" is ID of UDP | ||
# https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml | ||
is_udp_protocol(protocol) if protocol in {"udp", "17"} | ||
|
||
is_udp_protocol(protocol) if protocol in all_protocols | ||
|
||
is_tcp_or_udp_protocol(protocol) if is_tcp_protocol(protocol) | ||
|
||
is_tcp_or_udp_protocol(protocol) if is_udp_protocol(protocol) | ||
|
||
# protocol "-1" allows traffic on all ports, regardless of any port range you specify. | ||
# https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AuthorizeSecurityGroupIngress.html | ||
is_ssh_or_rdp_port(rule) if rule.protocol.value in {"-1"} | ||
|
||
is_ssh_or_rdp_port(rule) if is_port_range_include(rule.fromport.value, rule.toport.value, ssh_port) | ||
|
||
is_ssh_or_rdp_port(rule) if is_port_range_include(rule.fromport.value, rule.toport.value, rdp_port) | ||
|
||
is_port_range_include(from, to, port) if { | ||
from <= port | ||
port <= to | ||
} | ||
|
||
# check if CIDR defines an IP block containing all possible IP addresses | ||
cidr_allows_all_ips(cidr) if cidr in all_ips |
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