forked from Checkmarx/kics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat.(query): Added Alicloud Oss Bucket Public Access Enabled Query f…
…or Terraform (Checkmarx#4931) * Added Alicloud oss bucket cant be public access * Changed per review suggestions
- Loading branch information
1 parent
c3a407a
commit 91c62e8
Showing
7 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
assets/queries/terraform/alicloud/oss_bucket_public_access_enabled/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,11 @@ | ||
{ | ||
"id": "62232513-b16f-4010-83d7-51d0e1d45426", | ||
"queryName": "OSS Bucket Public Access Enabled", | ||
"severity": "HIGH", | ||
"category": "Access Control", | ||
"descriptionText": "OSS Bucket should have public access disabled", | ||
"descriptionUrl": "https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/oss_bucket#acl", | ||
"platform": "Terraform", | ||
"descriptionID": "d8096622", | ||
"cloudProvider": "alicloud" | ||
} |
20 changes: 20 additions & 0 deletions
20
assets/queries/terraform/alicloud/oss_bucket_public_access_enabled/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,20 @@ | ||
package Cx | ||
|
||
import data.generic.common as common_lib | ||
|
||
CxPolicy[result] { | ||
some i | ||
resource := input.document[i].resource.alicloud_oss_bucket[name] | ||
|
||
possibilities:={"public-read", "public-read-write"} | ||
resource.acl == possibilities[p] | ||
|
||
result := { | ||
"documentId": input.document[i].id, | ||
"searchKey": sprintf("alicloud_oss_bucket[%s].acl", [name]), | ||
"issueType": "IncorrectValue", | ||
"keyExpectedValue": "'acl' is set to private or not set", | ||
"keyActualValue": sprintf("'acl' is %s", [possibilities[p]]), | ||
"searchline":common_lib.build_search_line(["resource", "alicloud_oss_bucket", name, "acl"], []), | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
assets/queries/terraform/alicloud/oss_bucket_public_access_enabled/test/negative1.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,4 @@ | ||
resource "alicloud_oss_bucket" "bucket_public_access_enabled1" { | ||
bucket = "bucket-170309-acl" | ||
acl = "private" | ||
} |
3 changes: 3 additions & 0 deletions
3
assets/queries/terraform/alicloud/oss_bucket_public_access_enabled/test/negative2.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,3 @@ | ||
resource "alicloud_oss_bucket" "bucket_public_access_enabled4" { | ||
bucket = "bucket-170309-acl" | ||
} |
4 changes: 4 additions & 0 deletions
4
assets/queries/terraform/alicloud/oss_bucket_public_access_enabled/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,4 @@ | ||
resource "alicloud_oss_bucket" "bucket_public_access_enabled2" { | ||
bucket = "bucket-170309-acl" | ||
acl = "public-read" | ||
} |
13 changes: 13 additions & 0 deletions
13
assets/queries/terraform/alicloud/oss_bucket_public_access_enabled/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,13 @@ | ||
resource "alicloud_oss_bucket" "bucket_public_access_enabled3" { | ||
bucket = "bucket-170309-acl" | ||
acl = "public-read-write" | ||
} | ||
|
||
resource "alicloud_oss_bucket" "bucket-logging" { | ||
bucket = "bucket-170309-logging" | ||
|
||
logging { | ||
target_bucket = alicloud_oss_bucket.bucket-target.id | ||
target_prefix = "log/" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...es/terraform/alicloud/oss_bucket_public_access_enabled/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": "OSS Bucket Public Access Enabled", | ||
"severity": "HIGH", | ||
"line": 3, | ||
"fileName": "positive1.tf" | ||
}, | ||
{ | ||
"queryName": "OSS Bucket Public Access Enabled", | ||
"severity": "HIGH", | ||
"line": 3, | ||
"fileName": "positive2.tf" | ||
} | ||
] |