added
Additional custom policies operators đď¸
about 1 month ago by Gilad Mark
Bridgecrew now allows users to have additional customized policies capabilities by expanding the vast number of operators supported in our scheme. Newly supported operators include:
- JSON Path Equals - evaluate a JSON input if it equals a given value
- JSON Path Exists - evaluate a JSON input if it exists
- Subset - evaluate that all variables in the list exist in the policy subset list
- Not Subset - evaluate that at least one of the variables in the list does not exist in the policy subset
The following example combines some of these operators into a policy that requires every security group to have each of the following ingress rules:
- Port 22 from the IP 192.168.0.122/32
- Port 443 from the IP 8.0.4.19/32
---
metadata:
name: âAWS Security Group rule checkâ
guidelines: âSecurity groups must allow port 22 from the bastion host and port 443 from 8.0.4.19â
category: âgeneralâ
severity: âcriticalâ
scope:
provider: âawsâ
definition:
and:
- cond_type: âattributeâ
resource_types:
- âaws_security_groupâ
attribute: âingress[?(@.to_port == 22 & @.from_port == 22)].cidr_blocks[*]â
operator: âjsonpath_equalsâ
value: "192.168.0.122/32" # bastion host IP
- cond_type: âattributeâ
resource_types:
- âaws_security_groupâ
attribute: âingress[?(@.to_port == 443 & @.from_port == 443)].cidr_blocks[?(@ == â8.0.4.19/32â)]â
operator: âjsonpath_existsâ
The following example requires that all IPs in any security group ingress rule use CIDR blocks from a closed list of valid values. (It also skips any egress rules.)
---
metadata:
name: âAWS Security Group rule checkâ
guidelines: âAll ingress rules must include IPs from specific serversâ
category: âgeneralâ
severity: âcriticalâ
scope:
provider: âawsâ
definition:
or:
- cond_type: âattributeâ
resource_types:
- âaws_security_group_ruleâ
attribute: âtypeâ
operator: âequalsâ
value: "egress"
- cond_type: âattributeâ
resource_types:
- âaws_security_group_ruleâ
attribute: âcidr_blocksâ
operator: âsubsetâ
value:
- â1.2.3.4/32â
- â2.3.4.5/32â