-
Notifications
You must be signed in to change notification settings - Fork 359
feat(flags): ast 116512 support new cloud providers ibm cloud and oracle cloud #7887
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
Open
cx-laura-rodrigues
wants to merge
12
commits into
master
Choose a base branch
from
AST-116512-kics-support-new-cloud-providers-ibm-cloud-and-oracle-cloud
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d26d813
Update branch with master changes
cx-laura-rodrigues 7e43e50
feat(cloud provider): Support cloud providers IBM cloud and Oracle cloud
cx-laura-rodrigues 0a9dfb8
removing files
cx-laura-rodrigues 79c567a
adding dummy folders for queries validations
cx-laura-rodrigues dd89ae9
fix query id pattern
cx-laura-rodrigues 061ba1e
Merge branch 'master' into AST-116512-kics-support-new-cloud-provider…
cx-rui-araujo 907fe9a
Merge branch 'master' into AST-116512-kics-support-new-cloud-provider…
cx-laura-rodrigues b90ffcc
removing dummy queries and adding experimental
cx-laura-rodrigues 5da5da1
small fix
cx-laura-rodrigues 409fd70
update IBM Cloud load balancer type validation
cx-laura-rodrigues ec8c107
Merge branch 'master' into AST-116512-kics-support-new-cloud-provider…
cx-laura-rodrigues e1b91f7
added support for simID transition for oracle and ibm cloud
cx-laura-rodrigues File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -105,7 +105,9 @@ | |
| "azure", | ||
| "common", | ||
| "gcp", | ||
| "ibmcloud", | ||
| "nifcloud", | ||
| "oraclecloud", | ||
| "tencentcloud" | ||
| ] | ||
| }, | ||
|
|
||
This file contains hidden or 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
14 changes: 14 additions & 0 deletions
14
assets/queries/terraform/ibmcloud/load_balancer_vpc_is_public/metadata.json
This file contains hidden or 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 @@ | ||
| { | ||
| "id": "a6bc2970-c10d-45ab-9050-cf69c393e911", | ||
| "queryName": "Load Balancer VPC is Public", | ||
| "severity": "MEDIUM", | ||
| "category": "Insecure Configurations", | ||
| "descriptionText": "IBM Load Balancer VPC should not be public", | ||
| "descriptionUrl": "https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/is_lb", | ||
| "platform": "Terraform", | ||
| "descriptionID": "a6bc2970", | ||
| "cloudProvider": "ibmcloud", | ||
| "cwe": "668", | ||
| "riskScore": "3.0", | ||
| "experimental": "true" | ||
| } |
39 changes: 39 additions & 0 deletions
39
assets/queries/terraform/ibmcloud/load_balancer_vpc_is_public/query.rego
This file contains hidden or 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,39 @@ | ||
| package Cx | ||
|
|
||
| import data.generic.common as common_lib | ||
| import data.generic.terraform as tf_lib | ||
|
|
||
| CxPolicy[result] { | ||
|
|
||
| lb := input.document[i].resource.ibm_is_lb[name] | ||
| not common_lib.valid_key(lb, "type") | ||
|
|
||
| result := { | ||
| "documentId": input.document[i].id, | ||
| "resourceType": "ibm_is_lb", | ||
| "resourceName": tf_lib.get_resource_name(lb, name), | ||
| "searchKey": sprintf("ibm_is_lb[%s]", [name]), | ||
| "issueType": "MissingAttribute", | ||
| "keyExpectedValue": sprintf("'ibm_is_lb[%s]' should be set to private or private_path.", [name]), | ||
| "keyActualValue": sprintf("'ibm_is_lb[%s]' is missing type property, defaults to public.", [name]), | ||
| "searchLine": common_lib.build_search_line(["resource","ibm_is_lb", name], []), | ||
| } | ||
| } | ||
|
|
||
| CxPolicy[result] { | ||
|
|
||
| lb := input.document[i].resource.ibm_is_lb[name] | ||
| lb.type != "private" | ||
| lb.type != "private_path" | ||
|
|
||
| result := { | ||
| "documentId": input.document[i].id, | ||
| "resourceType": "ibm_is_lb", | ||
| "resourceName": tf_lib.get_resource_name(lb, name), | ||
| "searchKey": sprintf("ibm_is_lb[%s]", [name]), | ||
| "issueType": "IncorrectValue", | ||
| "keyExpectedValue": sprintf("'ibm_is_lb[%s]' should be set to private or private_path.", [name]), | ||
| "keyActualValue": sprintf("'ibm_is_lb[%s]' is set to %s.", [name, lb.type]), | ||
| "searchLine": common_lib.build_search_line(["resource","ibm_is_lb", name, "type"], []), | ||
| } | ||
| } | ||
7 changes: 7 additions & 0 deletions
7
assets/queries/terraform/ibmcloud/load_balancer_vpc_is_public/test/negative1.tf
This file contains hidden or 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 @@ | ||
| # Case: type is defined to private_path | ||
| resource "ibm_is_lb" "example" { | ||
| name = "example-load-balancer" | ||
| subnets = [ibm_is_subnet.example.id] | ||
| profile = "network-private-path" | ||
| type = "private_path" | ||
| } |
7 changes: 7 additions & 0 deletions
7
assets/queries/terraform/ibmcloud/load_balancer_vpc_is_public/test/negative2.tf
This file contains hidden or 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 @@ | ||
| # Case: type is defined to private | ||
| resource "ibm_is_lb" "example" { | ||
| name = "example-load-balancer" | ||
| subnets = [ibm_is_subnet.example.id] | ||
| profile = "network-private-path" | ||
| type = "private" | ||
| } |
7 changes: 7 additions & 0 deletions
7
assets/queries/terraform/ibmcloud/load_balancer_vpc_is_public/test/positive1.tf
This file contains hidden or 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 @@ | ||
| # Case: type is defined to public | ||
| resource "ibm_is_lb" "example" { | ||
| name = "example-load-balancer" | ||
| subnets = [ibm_is_subnet.example.id] | ||
| profile = "network-private-path" | ||
| type = "public" | ||
| } |
6 changes: 6 additions & 0 deletions
6
assets/queries/terraform/ibmcloud/load_balancer_vpc_is_public/test/positive2.tf
This file contains hidden or 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,6 @@ | ||
| resource "ibm_is_lb" "example" { | ||
| name = "example-load-balancer" | ||
| subnets = [ibm_is_subnet.example.id] | ||
| profile = "network-private-path" | ||
| # Case: type is not defined, defaults to public | ||
| } |
15 changes: 15 additions & 0 deletions
15
...queries/terraform/ibmcloud/load_balancer_vpc_is_public/test/positive_expected_result.json
This file contains hidden or 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,15 @@ | ||
| [ | ||
| { | ||
| "queryName": "Load Balancer VPC is Public", | ||
| "severity": "MEDIUM", | ||
| "line": 6, | ||
| "fileName": "positive1.tf" | ||
| }, | ||
| { | ||
| "queryName": "Load Balancer VPC is Public", | ||
| "severity": "MEDIUM", | ||
| "line": 1, | ||
| "fileName": "positive2.tf" | ||
| } | ||
| ] | ||
|
|
14 changes: 14 additions & 0 deletions
14
assets/queries/terraform/oraclecloud/instance_monitoring_disabled/metadata.json
This file contains hidden or 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 @@ | ||
| { | ||
| "id": "1d2e88ff-7ee7-4c8a-bf16-01488c83f295", | ||
| "queryName": "Instance Monitoring Disabled", | ||
| "severity": "LOW", | ||
| "category": "Observability", | ||
| "descriptionText": "Instance should have monitoring enabled", | ||
| "descriptionUrl": "https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/core_instance_configuration.html#is_monitoring_disabled-2", | ||
| "platform": "Terraform", | ||
| "descriptionID": "1d2e88ff", | ||
| "cloudProvider": "oraclecloud", | ||
| "cwe": "778", | ||
| "riskScore": "1.0", | ||
| "experimental": "true" | ||
| } |
21 changes: 21 additions & 0 deletions
21
assets/queries/terraform/oraclecloud/instance_monitoring_disabled/query.rego
This file contains hidden or 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 @@ | ||
| package Cx | ||
|
|
||
| import data.generic.common as common_lib | ||
| import data.generic.terraform as tf_lib | ||
|
|
||
| CxPolicy[result] { | ||
| resource := input.document[i].resource.oci_core_instance[name] | ||
| agent_config := resource.agent_config | ||
| agent_config.is_monitoring_disabled == true | ||
|
|
||
| result := { | ||
| "documentId": input.document[i].id, | ||
| "resourceType": "oci_core_instance", | ||
| "resourceName": tf_lib.get_resource_name(resource, name), | ||
| "searchKey": sprintf("oci_core_instance[%s]", [name]), | ||
| "issueType": "IncorrectValue", | ||
| "keyExpectedValue": "Attribute 'is_monitoring_disabled' should be set to false.", | ||
| "keyActualValue": "Attribute 'is_monitoring_disabled' is set to true.", | ||
| "searchLine": common_lib.build_search_line(["resource", "oci_core_instance", name, "agent_config", "is_monitoring_disabled"], []), | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
assets/queries/terraform/oraclecloud/instance_monitoring_disabled/test/negative1.tf
This file contains hidden or 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,9 @@ | ||
| # Case: is_monitoring_disabled set to false | ||
| resource "oci_core_instance" "fail" { | ||
| availability_domain = var.instance_availability_domain | ||
| compartment_id = var.compartment_id | ||
| shape = var.instance_shape | ||
| agent_config { | ||
| is_monitoring_disabled = false | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
assets/queries/terraform/oraclecloud/instance_monitoring_disabled/test/negative2.tf
This file contains hidden or 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,6 @@ | ||
| # Case: missing is_monitoring_disabled property, defaults to false | ||
| resource "oci_core_instance" "fail" { | ||
| availability_domain = var.instance_availability_domain | ||
| compartment_id = var.compartment_id | ||
| shape = var.instance_shape | ||
| } |
7 changes: 7 additions & 0 deletions
7
assets/queries/terraform/oraclecloud/instance_monitoring_disabled/test/negative3.tf
This file contains hidden or 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 @@ | ||
| # Case: missing is_monitoring_disabled inside agent_config | ||
| resource "oci_core_instance" "fail" { | ||
| availability_domain = var.instance_availability_domain | ||
| compartment_id = var.compartment_id | ||
| shape = var.instance_shape | ||
| agent_config {} | ||
| } |
8 changes: 8 additions & 0 deletions
8
assets/queries/terraform/oraclecloud/instance_monitoring_disabled/test/positive.tf
This file contains hidden or 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,8 @@ | ||
| resource "oci_core_instance" "fail" { | ||
| availability_domain = var.instance_availability_domain | ||
| compartment_id = var.compartment_id | ||
| shape = var.instance_shape | ||
| agent_config { | ||
| is_monitoring_disabled = true | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
...ies/terraform/oraclecloud/instance_monitoring_disabled/test/positive_expected_result.json
This file contains hidden or 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,8 @@ | ||
| [ | ||
| { | ||
| "queryName": "Instance Monitoring Disabled", | ||
| "severity": "LOW", | ||
| "line": 6, | ||
| "fileName": "positive.tf" | ||
| } | ||
| ] |
This file contains hidden or 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 hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.