π§ AWS EC2 Security Group allows unrestricted traffic to MySQL - prod.logic.yaml π’
- Contextual name: π§ prod.logic.yaml π’
- ID:
/ce/ca/aws/ec2/security-group-allows-unrestricted-traffic-to-mysql/prod.logic.yaml
- Located in: π AWS EC2 Security Group allows unrestricted traffic to MySQL π’
Flagsβ
- π’ Logic test success
- π’ Logic with extracts
- π’ Logic with test data
Input Typeβ
Type | API Name | Extracts | Extract Files | Logic Files | |
---|---|---|---|---|---|
π | π AWS EC2 Security Group | CA10__CaAwsSecurityGroup__c | 1 | 1 | 17 |
Usesβ
Test Results π’β
Generated at: 2025-05-10T12:01:59.813040852Z Open
Result | Id | Condition Index | Condition Text | Runtime Error |
---|---|---|---|---|
π’ | test1 | βοΈ 99 | βοΈ isDisappeared(CA10__disappearanceTime__c) | βοΈ null |
π’ | test2 | βοΈ 199 | βοΈ CA10__AWS_EC2_Security_Group_Rules__r.has(INCOMPLIANT) | βοΈ null |
π’ | test3 | βοΈ 199 | βοΈ CA10__AWS_EC2_Security_Group_Rules__r.has(INCOMPLIANT) | βοΈ null |
π’ | test5 | βοΈ 200 | βοΈ otherwise | βοΈ null |
π’ | test6 | βοΈ 200 | βοΈ otherwise | βοΈ null |
π’ | test7 | βοΈ 200 | βοΈ otherwise | βοΈ null |
π’ | test8 | βοΈ 200 | βοΈ otherwise | βοΈ null |
Generationβ
File | MD5 | |
---|---|---|
Open | /ce/ca/aws/ec2/security-group-allows-unrestricted-traffic-to-mysql/policy.yaml | FF340D73728CFF1BE280137616E04CEC |
Open | /ce/ca/aws/ec2/security-group-allows-unrestricted-traffic-to-mysql/prod.logic.yaml | F75254A6B9E1F54ABD2351E6597EBCDC |
Open | /ce/ca/aws/ec2/security-group-allows-unrestricted-traffic-to-mysql/test-data.json | 34B1FC516AC0CE520B55AEE722CB4C36 |
Open | /types/CA10__CaAwsSecurityGroupRule2__c/object.extracts.yaml | 58DC1872D7462985D50972C65C61C237 |
Generate FULL scriptβ
java -jar repo-manager.jar policies generate FULL /ce/ca/aws/ec2/security-group-allows-unrestricted-traffic-to-mysql/prod.logic.yaml
Generate DEBUG scriptβ
java -jar repo-manager.jar policies generate DEBUG /ce/ca/aws/ec2/security-group-allows-unrestricted-traffic-to-mysql/prod.logic.yaml
Generate CAPTURE_TEST_DATA scriptβ
java -jar repo-manager.jar policies generate CAPTURE_TEST_DATA /ce/ca/aws/ec2/security-group-allows-unrestricted-traffic-to-mysql/prod.logic.yaml
Generate TESTS scriptβ
java -jar repo-manager.jar policies generate TESTS /ce/ca/aws/ec2/security-group-allows-unrestricted-traffic-to-mysql/prod.logic.yaml
Execute testsβ
java -jar repo-manager.jar policies test /ce/ca/aws/ec2/security-group-allows-unrestricted-traffic-to-mysql/prod.logic.yaml
Contentβ
---
inputType: "CA10__CaAwsSecurityGroup__c"
testData:
- file: "test-data.json"
conditions:
- status: "INCOMPLIANT"
currentStateMessage: "This Security Group allows access from 0.0.0.0/0 or ::/0 to MySQL on port 3306."
remediationMessage: "Consider changing the Security Group source field to a range other than 0.0.0.0/0 or delete the offending inbound rule."
check:
RELATED_LIST_HAS:
status: "INCOMPLIANT"
relationshipName: "CA10__AWS_EC2_Security_Group_Rules__r"
otherwise:
status: "COMPLIANT"
currentStateMessage: "This Security Group doesn't allow unrestricted access to MySQL."
relatedLists:
- relationshipName: "CA10__AWS_EC2_Security_Group_Rules__r"
importExtracts:
- file: "/types/CA10__CaAwsSecurityGroupRule2__c/object.extracts.yaml"
conditions:
- status: "INAPPLICABLE"
currentStateMessage: "This is an outbound security group rule."
check:
NOT_EQUAL:
left:
EXTRACT: "CA10__direction__c"
right:
TEXT: "Inbound"
- status: "INAPPLICABLE"
currentStateMessage: "This security group rule does not allow unrestricted access."
check:
AND:
args:
- NOT_EQUAL:
left:
EXTRACT: "CA10__sourceIpRange__c"
right:
TEXT: "0.0.0.0/0"
- NOT_EQUAL:
left:
EXTRACT: "CA10__sourceIpRange__c"
right:
TEXT: "::/0"
- status: "INAPPLICABLE"
currentStateMessage: "This security group rule protocol is not All or TCP."
check:
# check that protocol is neither all or tcp
NOT:
arg:
OR:
args:
- IS_EQUAL:
left:
EXTRACT: "CA10__protocol__c"
right:
TEXT: "All"
- IS_EQUAL:
left:
EXTRACT: "CA10__protocol__c"
right:
TEXT: "tcp"
- status: "INCOMPLIANT"
currentStateMessage: "This Security Group allows access from 0.0.0.0/0 or\
\ ::/0 to MySQL on port 3306."
remediationMessage: "Consider changing the source field to a range other\
\ than 0.0.0.0/0 or delete the offending inbound rule."
check:
AND:
args:
- LESS_THAN_EQUAL:
left:
EXTRACT: "CA10__fromPort__c"
right:
NUMBER: 3306.0
- GREATER_THAN_EQUAL:
left:
EXTRACT: "CA10__toPort__c"
right:
NUMBER: 3306.0
otherwise:
status: "COMPLIANT"
currentStateMessage: "This Security Group doesn't allow unrestricted access."