-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6314 from tunakyonn/feat/add_nifcloud_engine_support
feat(nifcloud): add nifcloud engine support
- Loading branch information
Showing
12 changed files
with
93 additions
and
4 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 |
---|---|---|
|
@@ -76,7 +76,8 @@ | |
"aws", | ||
"azure", | ||
"common", | ||
"gcp" | ||
"gcp", | ||
"nifcloud" | ||
] | ||
}, | ||
"platform": { | ||
|
12 changes: 12 additions & 0 deletions
12
assets/queries/terraform/nifcloud/computing_instance_has_common_private/metadata.json
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,12 @@ | ||
{ | ||
"id": "df58dd45-8009-43c2-90f7-c90eb9d53ed9", | ||
"queryName": "Nifcloud Computing Has Common Private Network", | ||
"severity": "LOW", | ||
"category": "Networking and Firewall", | ||
"descriptionText": "The instance has common private network", | ||
"descriptionUrl": "https://registry.terraform.io/providers/nifcloud/nifcloud/latest/docs/resources/instance#network_id", | ||
"platform": "Terraform", | ||
"descriptionID": "c5065d3a", | ||
"cloudProvider": "nifcloud", | ||
"experimental": "true" | ||
} |
36 changes: 36 additions & 0 deletions
36
assets/queries/terraform/nifcloud/computing_instance_has_common_private/query.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,36 @@ | ||
package Cx | ||
|
||
import data.generic.terraform as tf_lib | ||
import data.generic.common as common_lib | ||
|
||
CxPolicy[result] { | ||
|
||
instance := input.document[i].resource.nifcloud_instance[name] | ||
instance.network_interface[_].network_id == "net-COMMON_PRIVATE" | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"resourceType": "nifcloud_instance", | ||
"resourceName": tf_lib.get_resource_name(instance, name), | ||
"searchKey": sprintf("nifcloud_instance[%s]", [name]), | ||
"issueType": "IncorrectValue", | ||
"keyExpectedValue": sprintf("'nifcloud_instance[%s]' should use a private LAN to isolate the private side network from the shared network", [name]), | ||
"keyActualValue": sprintf("'nifcloud_instance[%s]' has common private network", [name]), | ||
} | ||
} | ||
|
||
CxPolicy[result] { | ||
|
||
instance := input.document[i].resource.nifcloud_instance[name] | ||
instance.network_interface.network_id == "net-COMMON_PRIVATE" | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"resourceType": "nifcloud_instance", | ||
"resourceName": tf_lib.get_resource_name(instance, name), | ||
"searchKey": sprintf("nifcloud_instance[%s]", [name]), | ||
"issueType": "IncorrectValue", | ||
"keyExpectedValue": sprintf("'nifcloud_instance[%s]' should use a private LAN to isolate the private side network from the shared network", [name]), | ||
"keyActualValue": sprintf("'nifcloud_instance[%s]' has common private network", [name]), | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
assets/queries/terraform/nifcloud/computing_instance_has_common_private/test/negative.tf
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,7 @@ | ||
resource "nifcloud_instance" "negative" { | ||
image_id = data.nifcloud_image.ubuntu.id | ||
security_group = nifcloud_security_group.example.group_name | ||
network_interface { | ||
network_id = nifcloud_private_lan.main.id | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
assets/queries/terraform/nifcloud/computing_instance_has_common_private/test/positive1.tf
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,7 @@ | ||
resource "nifcloud_instance" "positive" { | ||
image_id = data.nifcloud_image.ubuntu.id | ||
security_group = nifcloud_security_group.example.group_name | ||
network_interface { | ||
network_id = "net-COMMON_PRIVATE" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
assets/queries/terraform/nifcloud/computing_instance_has_common_private/test/positive2.tf
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,10 @@ | ||
resource "nifcloud_instance" "positive" { | ||
image_id = data.nifcloud_image.ubuntu.id | ||
security_group = nifcloud_security_group.example.group_name | ||
network_interface { | ||
network_id = "net-COMMON_GLOBAL" | ||
} | ||
network_interface { | ||
network_id = "net-COMMON_PRIVATE" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...rraform/nifcloud/computing_instance_has_common_private/test/positive_expected_result.json
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,14 @@ | ||
[ | ||
{ | ||
"queryName": "Nifcloud Computing Has Common Private Network", | ||
"severity": "LOW", | ||
"line": 1, | ||
"fileName": "positive1.tf" | ||
}, | ||
{ | ||
"queryName": "Nifcloud Computing Has Common Private Network", | ||
"severity": "LOW", | ||
"line": 1, | ||
"fileName": "positive2.tf" | ||
} | ||
] |
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 |
---|---|---|
|
@@ -83,6 +83,7 @@ var ( | |
"aws": "", | ||
"azure": "", | ||
"gcp": "", | ||
"nifcloud": "", | ||
} | ||
) | ||
|
||
|
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