Skip to content

Commit

Permalink
Fix(query): S3 Bucket Policy Accepts Http Requests (Checkmarx#4949)
Browse files Browse the repository at this point in the history
* Added Allow true to deny_http_requests function

* i had one job
  • Loading branch information
cxAndreFelicidade authored Mar 9, 2022
1 parent e327eee commit 1e1654f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,24 @@ check_action(action) {
action[a] == validActions[x]
}

is_equal(secure, target)
{
secure == target
}else {
secure[_]==target
}
deny_http_requests(policyValue) {
policy := common_lib.json_unmarshal(policyValue)
st := common_lib.get_statement(policy)
statement := st[_]
check_action(statement.Action)
statement.Effect == "Deny"
statement.Condition.Bool["aws:SecureTransport"] == "false"
policy := common_lib.json_unmarshal(policyValue)
st := common_lib.get_statement(policy)
statement := st[_]
check_action(statement.Action)
statement.Effect == "Deny"
is_equal(statement.Condition.Bool["aws:SecureTransport"], "false")
} else {
policy := common_lib.json_unmarshal(policyValue)
st := common_lib.get_statement(policy)
statement := st[_]
check_action(statement.Action)
statement.Effect == "Allow"
is_equal(statement.Condition.Bool["aws:SecureTransport"], "true")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module "s3_bucket" {
source = "terraform-aws-modules/s3-bucket/aws"
version = "3.7.0"

bucket = "my-s3-bucket"
acl = "private"

versioning = {
enabled = true
}

policy = <<EOF
{
"Version": "2012-10-17",
"Id": "MYBUCKETPOLICY",
"Statement": [
{
"Sid": "IPAllow",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"aws_s3_bucket.b.arn"
],
"Condition": {
"Bool": {
"aws:SecureTransport": "true"
}
}
}
]
}
EOF
}

0 comments on commit 1e1654f

Please sign in to comment.