-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(checks): migrate Nifcloud network, dns, sslcertificate to Rego
Signed-off-by: Nikita Pivkin <[email protected]>
- Loading branch information
Showing
40 changed files
with
598 additions
and
684 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# METADATA | ||
# title: Delete verified record | ||
# description: | | ||
# Removing verified record of TXT auth the risk that | ||
# | ||
# If the authentication record remains, anyone can register the zone | ||
# scope: package | ||
# schemas: | ||
# - input: schema["cloud"] | ||
# related_resources: | ||
# - https://pfs.nifcloud.com/guide/dns/zone_new.htm | ||
# custom: | ||
# id: AVD-NIF-0007 | ||
# avd_id: AVD-NIF-0007 | ||
# provider: nifcloud | ||
# service: dns | ||
# severity: CRITICAL | ||
# short_code: remove-verified-record | ||
# recommended_action: Remove verified record | ||
# input: | ||
# selector: | ||
# - type: cloud | ||
# subtypes: | ||
# - service: dns | ||
# provider: nifcloud | ||
package builtin.nifcloud.dns.nifcloud0007 | ||
|
||
import rego.v1 | ||
|
||
zone_registration_auth_txt := "nifty-dns-verify=" | ||
|
||
deny contains res if { | ||
some record in input.nifcloud.dns.records | ||
record.type.value == "TXT" | ||
startswith(record.record.value, zone_registration_auth_txt) | ||
res := result.new("Authentication TXT record exists.", record) | ||
} |
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
checks/cloud/nifcloud/dns/remove_verified_record_test.rego
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,38 @@ | ||
package builtin.nifcloud.dns.nifcloud0007_test | ||
|
||
import rego.v1 | ||
|
||
import data.builtin.nifcloud.dns.nifcloud0007 as check | ||
import data.lib.test | ||
|
||
test_allow_txt_record if { | ||
inp := build_input({ | ||
"type": {"value": "TXT"}, | ||
"record": {"value": "test"}, | ||
}) | ||
|
||
res := check.deny with input as inp | ||
res == set() | ||
} | ||
|
||
test_deny_verified_txt_record if { | ||
inp := build_input({ | ||
"type": {"value": "TXT"}, | ||
"record": {"value": "nifty-dns-verify=test"}, | ||
}) | ||
|
||
res := check.deny with input as inp | ||
count(res) == 1 | ||
} | ||
|
||
test_allow_verified_not_txt_record if { | ||
inp := build_input({ | ||
"type": {"value": "A"}, | ||
"record": {"value": "nifty-dns-verify=test"}, | ||
}) | ||
|
||
res := check.deny with input as inp | ||
res == set() | ||
} | ||
|
||
build_input(record) := {"nifcloud": {"dns": {"records": [record]}}} |
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
37 changes: 37 additions & 0 deletions
37
checks/cloud/nifcloud/network/add_security_group_to_router.rego
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,37 @@ | ||
# METADATA | ||
# title: Missing security group for router. | ||
# description: | | ||
# Need to add a security group to your router. | ||
# scope: package | ||
# schemas: | ||
# - input: schema["cloud"] | ||
# related_resources: | ||
# - https://pfs.nifcloud.com/help/router/change.htm | ||
# custom: | ||
# id: AVD-NIF-0016 | ||
# avd_id: AVD-NIF-0016 | ||
# provider: nifcloud | ||
# service: network | ||
# severity: CRITICAL | ||
# short_code: add-security-group-to-router | ||
# recommended_action: Add security group for all routers | ||
# input: | ||
# selector: | ||
# - type: cloud | ||
# subtypes: | ||
# - service: network | ||
# provider: nifcloud | ||
# terraform: | ||
# links: | ||
# - https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/router#security_group | ||
# good_examples: checks/cloud/nifcloud/network/add_security_group_to_router.tf.go | ||
# bad_examples: checks/cloud/nifcloud/network/add_security_group_to_router.tf.go | ||
package builtin.nifcloud.network.nifcloud0016 | ||
|
||
import rego.v1 | ||
|
||
deny contains res if { | ||
some router in input.nifcloud.network.routers | ||
router.securitygroup.value == "" | ||
res := result.new("Router does not have a securiy group.", router.securitygroup) | ||
} |
65 changes: 0 additions & 65 deletions
65
checks/cloud/nifcloud/network/add_security_group_to_router_test.go
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.