Skip to content

Instantly share code, notes, and snippets.

@jmassardo
Created February 19, 2021 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmassardo/3332ef2ecd116238b728e65bd8dbafdc to your computer and use it in GitHub Desktop.
Save jmassardo/3332ef2ecd116238b728e65bd8dbafdc to your computer and use it in GitHub Desktop.
# List of insecure ports
disallowedPorts = {"22", "80", "3389"}
deny[msg] {
# loop through the resources and find all the network security groups.
# Get all their security rules and destination ports
resourcePorts := {p | c = input.resource_changes[_];
p = c.change.after.security_rule[_].destination_port_range}
# Find any resource ports that match a port on the disallowed list
badPorts := {b | b = resourcePorts[_]; disallowedPorts[b]}
# Return a list of bad ports to the user
msg := sprintf("The following insecure ports open: %v", [badPorts])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment