Skip to content

Commit

Permalink
Feat.(query): Added Alicloud Oss Bucket Public Access Enabled Query f…
Browse files Browse the repository at this point in the history
…or Terraform (Checkmarx#4931)

* Added Alicloud oss bucket cant be public access

* Changed per review suggestions
  • Loading branch information
cxAndreFelicidade authored Mar 9, 2022
1 parent c3a407a commit 91c62e8
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 0 deletions.
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"
}
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"], []),
}
}
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"
}
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"
}
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"
}
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/"
}
}
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"
}
]

0 comments on commit 91c62e8

Please sign in to comment.