Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rules for security group validation #3026

Merged
merged 4 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
38 changes: 37 additions & 1 deletion scripts/update_schemas_manually.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,34 @@
],
},
),
Patch(
path="/definitions/Ingress/properties/FromPort",
values={"minimum": -1},
),
Patch(
path="/definitions/Ingress/properties/ToPort",
values={"minimum": -1},
),
Patch(
path="/definitions/Egress/properties/FromPort",
values={"minimum": -1},
),
Patch(
path="/definitions/Egress/properties/ToPort", values={"minimum": -1}
),
],
),
ResourcePatch(
resource_type="AWS::EC2::SecurityGroupEgress",
patches=[
Patch(
path="/properties/FromPort",
values={"minimum": -1},
),
Patch(
path="/properties/ToPort",
values={"minimum": -1},
),
],
),
ResourcePatch(
Expand All @@ -747,9 +775,17 @@
"SourcePrefixListId",
"SourceSecurityGroupId",
"SourceSecurityGroupName",
]
],
},
),
Patch(
path="/properties/FromPort",
values={"minimum": -1},
),
Patch(
path="/properties/ToPort",
values={"minimum": -1},
),
],
),
ResourcePatch(
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"effc1836f7a966083fbdb4e0f81a2d47\"", "url": "https://schema.cloudformation.eu-south-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"364b242dff2cf31f2046839c5ab2d57c\"", "url": "https://schema.cloudformation.eu-south-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"751107f951b161baf464053c90900355\"", "url": "https://schema.cloudformation.cn-north-1.amazonaws.com.cn/CloudformationSchema.zip"}
{"etag": "\"a36011ffbc897753ae0d68841d110e2d\"", "url": "https://schema.cloudformation.cn-north-1.amazonaws.com.cn/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"6d1c4c89817c4d396ebe429ea8cfce90\"", "url": "https://schema.cloudformation.us-gov-east-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"fbdc4050d28c3ced1d6c9541632c9ace\"", "url": "https://schema.cloudformation.us-gov-east-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"12a6baebe508a08bf1b9b0eafe66141f\"", "url": "https://schema.cloudformation.me-south-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"b90f4b4902026e5f95b38954998863ff\"", "url": "https://schema.cloudformation.me-south-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"947ff4e5ab8acdc4fcf74a8480b3e0e2\"", "url": "https://schema.cloudformation.us-gov-west-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"176f4e2894ec2acb6290a05a269e6140\"", "url": "https://schema.cloudformation.us-gov-west-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"f84b13a790b6c533e1d4289dc4a745ac\"", "url": "https://schema.cloudformation.me-central-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"0f9432630056521ac617613aad1be09a\"", "url": "https://schema.cloudformation.me-central-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"2c3ed748f499ca6b639ef716d97acac7\"", "url": "https://schema.cloudformation.eu-west-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"54bd5eae10cee4adb4566d26485ff7a3\"", "url": "https://schema.cloudformation.eu-west-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"47f12b87550e918969e60a40727dd190\"", "url": "https://schema.cloudformation.cn-northwest-1.amazonaws.com.cn/CloudformationSchema.zip"}
{"etag": "\"7e931cf80bce968198825b517a866a7e\"", "url": "https://schema.cloudformation.cn-northwest-1.amazonaws.com.cn/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"31d58468f833cbdbc868acba7bf63035\"", "url": "https://schema.cloudformation.af-south-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"3de828380e11418b68b5f34399142410\"", "url": "https://schema.cloudformation.af-south-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"45b27dc6f4f9a7af15585ca2d23c2646\"", "url": "https://schema.cloudformation.us-west-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"adbc25e9e3f06fc434de4680f517c8f6\"", "url": "https://schema.cloudformation.us-west-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"72ca384b3911b66c57ce88bc0ae4b529\"", "url": "https://schema.cloudformation.eu-central-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"0ee63cb2c95b7e841cedcc84f5269a21\"", "url": "https://schema.cloudformation.eu-central-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"63d1de10881d250eca51a9ac7b231b42\"", "url": "https://schema.cloudformation.ap-south-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"952c8778af65cda47b52ff0faefa3b97\"", "url": "https://schema.cloudformation.ap-south-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"c7acdf78bff0113d040a0a7828298b17\"", "url": "https://schema.cloudformation.ap-southeast-4.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"c0c6be40c29fdab9fd7ac2ecfde5ebbb\"", "url": "https://schema.cloudformation.ap-southeast-4.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"6fd6a23bf9b72793460590b1460ce11a\"", "url": "https://schema.cloudformation.us-east-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"df0e0152fe8259730c1fd6fe9d83ce26\"", "url": "https://schema.cloudformation.us-east-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"b14f647c22ed1c53e926654a836665cb\"", "url": "https://schema.cloudformation.ap-southeast-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"fa7b5a5b0e188fd287b5a9463e23f8d7\"", "url": "https://schema.cloudformation.ap-southeast-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"54a78961187dc4bafbf85e79189fdc3f\"", "url": "https://schema.cloudformation.ap-northeast-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"7aab0400c131f31315e6b365531f22eb\"", "url": "https://schema.cloudformation.ap-northeast-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"73eb84789e3f47a2ce8a8d0e2a7fa6ca\"", "url": "https://schema.cloudformation.ap-southeast-3.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"77ca3e0f61d4e8280912652d497260c7\"", "url": "https://schema.cloudformation.ap-southeast-3.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"97827b39bd31296f6c3c69fb1e24553e\"", "url": "https://schema.cloudformation.ap-east-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"f18d01d79d409a1ff8dd99954565a1cb\"", "url": "https://schema.cloudformation.ap-east-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"a40b97e29d258ba3613c6eb982d5d134\"", "url": "https://schema.cloudformation.sa-east-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"42f10982ba2782e11f403c0910f448be\"", "url": "https://schema.cloudformation.sa-east-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"282d72e523a8ffcd280570382ff4b126\"", "url": "https://schema.cloudformation.ap-southeast-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"9a608de28d171727447147e3e6415f48\"", "url": "https://schema.cloudformation.ap-southeast-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"bfb34c90ce8436ce9714869ed81302be\"", "url": "https://schema.cloudformation.ca-west-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"3772c841d6df593f46af09d64d6fbbae\"", "url": "https://schema.cloudformation.ca-west-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"5f4551de59a16a6fa0f8253ca25fa1a1\"", "url": "https://schema.cloudformation.eu-central-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"6651380dd64c2ffb40e6373b0588b44b\"", "url": "https://schema.cloudformation.eu-central-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"ad23ee5cf0745852dbce5435d8fd1871\"", "url": "https://schema.cloudformation.eu-north-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"9d999e6c25138e457453682331190c48\"", "url": "https://schema.cloudformation.eu-north-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"a167957542beaf48f0c31b1ebdd74bc2\"", "url": "https://schema.cloudformation.eu-south-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"bbd26a245b2a825b5a1ed3baf1c49fa3\"", "url": "https://schema.cloudformation.eu-south-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"8b09632a0a5c67bd3c4d0309c8719689\"", "url": "https://schema.cloudformation.ca-central-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"8a4abf7e85cb235600054f091077ea72\"", "url": "https://schema.cloudformation.ca-central-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"c423efe97526abee358744098383d975\"", "url": "https://schema.cloudformation.eu-west-3.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"6628d7949c2c24b6ddab9745da6dcaca\"", "url": "https://schema.cloudformation.eu-west-3.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"3269ce7119ccc620b09b2021b4ffe69c\"", "url": "https://schema.cloudformation.ap-northeast-3.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"600db79e43526641cf88b116db6aba2b\"", "url": "https://schema.cloudformation.ap-northeast-3.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"38638c728c53e779b2f23826b0e02ae1\"", "url": "https://schema.cloudformation.us-west-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"267704ad1d3389f342ec29b202442666\"", "url": "https://schema.cloudformation.us-west-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"25d4ba336b243267d351bf1085371fa6\"", "url": "https://schema.cloudformation.ap-south-2.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"09c1047eb5be4d6c57d38c96ae190d2b\"", "url": "https://schema.cloudformation.ap-south-2.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"d3c7824cf546908c5964ff0a246885d3\"", "url": "https://schema.cloudformation.us-east-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"5bc916b17e9a3f8bbfdbb8a393f0d4fe\"", "url": "https://schema.cloudformation.us-east-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"10287f4b65af7d6e5c741b54035f3aa3\"", "url": "https://schema.cloudformation.eu-west-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"ed54aa1102fc48ca113d2ddbc8fcbfff\"", "url": "https://schema.cloudformation.eu-west-1.amazonaws.com/CloudformationSchema.zip"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"etag": "\"2a91304be4e2f581a998679218a81b98\"", "url": "https://schema.cloudformation.ap-northeast-1.amazonaws.com/CloudformationSchema.zip"}
{"etag": "\"5fa4c1b8dfa49446bd1440422a814828\"", "url": "https://schema.cloudformation.ap-northeast-1.amazonaws.com/CloudformationSchema.zip"}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"allOf": [
{
"if": {
"properties": {
"ToPort": {
"enum": [
-1,
"-1"
]
}
},
"required": [
"ToPort"
]
},
"then": {
"properties": {
"FromPort": {
"enum": [
-1,
"-1"
]
}
},
"required": [
"FromPort"
]
}
},
{
"if": {
"properties": {
"FromPort": {
"enum": [
-1,
"-1"
]
}
},
"required": [
"FromPort"
]
},
"then": {
"properties": {
"ToPort": {
"enum": [
-1,
"-1"
]
}
},
"required": [
"ToPort"
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"if": {
"properties": {
"IpProtocol": {
"not": {
"enum": [
1,
"1",
"icmp",
6,
"6",
"tcp",
17,
"17",
"udp"
]
},
"type": [
"string",
"integer"
]
}
},
"required": [
"IpProtocol"
],
"type": "object"
},
"then": {
"properties": {
"FromPort": false,
"ToPort": false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"if": {
"properties": {
"IpProtocol": {
"enum": [
1,
"1",
"icmp",
6,
"6",
"tcp",
17,
"17",
"udp"
],
"type": [
"string",
"integer"
]
}
},
"required": [
"IpProtocol"
],
"type": "object"
},
"then": {
"required": [
"FromPort",
"ToPort"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"op": "add",
"path": "/definitions/Ingress/cfnSchema",
"value": [
"aws_ec2_securitygroup/protocols_and_port_ranges_include",
"aws_ec2_securitygroup/protocols_and_port_ranges_exclude",
"aws_ec2_securitygroup/all_to_and_from_ports"
]
},
{
"op": "add",
"path": "/definitions/Egress/cfnSchema",
"value": [
"aws_ec2_securitygroup/protocols_and_port_ranges_include",
"aws_ec2_securitygroup/protocols_and_port_ranges_exclude",
"aws_ec2_securitygroup/all_to_and_from_ports"
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,25 @@
"SourceSecurityGroupId",
"SourceSecurityGroupName"
]
},
{
"op": "add",
"path": "/definitions/Ingress/properties/FromPort/minimum",
"value": -1
},
{
"op": "add",
"path": "/definitions/Ingress/properties/ToPort/minimum",
"value": -1
},
{
"op": "add",
"path": "/definitions/Egress/properties/FromPort/minimum",
"value": -1
},
{
"op": "add",
"path": "/definitions/Egress/properties/ToPort/minimum",
"value": -1
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"op": "add",
"path": "/cfnSchema",
"value": [
"aws_ec2_securitygroup/protocols_and_port_ranges_include",
"aws_ec2_securitygroup/protocols_and_port_ranges_exclude",
"aws_ec2_securitygroup/all_to_and_from_ports"
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"op": "add",
"path": "/properties/FromPort/minimum",
"value": -1
},
{
"op": "add",
"path": "/properties/ToPort/minimum",
"value": -1
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"op": "add",
"path": "/cfnSchema",
"value": [
"aws_ec2_securitygroup/protocols_and_port_ranges_include",
"aws_ec2_securitygroup/protocols_and_port_ranges_exclude",
"aws_ec2_securitygroup/all_to_and_from_ports"
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,15 @@
"SourceSecurityGroupId",
"SourceSecurityGroupName"
]
},
{
"op": "add",
"path": "/properties/FromPort/minimum",
"value": -1
},
{
"op": "add",
"path": "/properties/ToPort/minimum",
"value": -1
}
]
Loading