-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support onlyContains custom check matchspec (#1902)
* feat: support optional provider and service name in custom checks * docs: add missing required type in docs * feat: support onlyContains in custom checks - updated docs to reflect new matchSpec - add example of it in use Signed-off-by: Owen Rumney <[email protected]>
- Loading branch information
Owen Rumney
authored
Sep 21, 2022
1 parent
57c9e4c
commit aaaae87
Showing
7 changed files
with
93 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
checks: | ||
- code: limit-cidr-ranges | ||
description: Custom check to ensure the only allowed cidr range are included for ingress | ||
requiredTypes: | ||
- resource | ||
requiredLabels: | ||
- aws_security_group | ||
severity: HIGH | ||
matchSpec: | ||
name: ingress | ||
action: isPresent | ||
subMatch: | ||
name: cidr_blocks | ||
action: onlyContains | ||
value: | ||
- "1.2.3.4" | ||
- "5.6.7.8" | ||
errorMessage: There is a cidr range that is not allowed | ||
relatedLinks: | ||
- http://internal.acmecorp.com/standards/aws/networking.html |
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,29 @@ | ||
resource "aws_security_group" "example_security_group_compliance" { | ||
name = "example_security_group_compliance" | ||
|
||
description = "Example SG" | ||
|
||
ingress { | ||
description = "Allow SSH" | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
cidr_blocks = ["1.2.3.4", "5.6.7.8"] | ||
} | ||
|
||
} | ||
|
||
resource "aws_security_group" "example_security_group_non_compliance" { | ||
name = "example_security_group_non_compliance" | ||
|
||
description = "Example SG" | ||
|
||
ingress { | ||
description = "Allow SSH" | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
cidr_blocks = ["1.2.3.4", "1.6.7.8"] | ||
} | ||
|
||
} |
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