51 lines
1.4 KiB
YAML
51 lines
1.4 KiB
YAML
id: s3-bucket-key
|
|
info:
|
|
name: S3 Bucket Key not enabled
|
|
author: princechaddha
|
|
severity: medium
|
|
description: |
|
|
This template verifies if Amazon S3 buckets have bucket keys enabled to optimize the cost of AWS Key Management Service (SSE-KMS) for server-side encryption
|
|
reference:
|
|
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html
|
|
metadata:
|
|
max-request: 2
|
|
tags: cloud,devops,aws,amazon,s3,aws-cloud-config
|
|
|
|
flow: |
|
|
code(1)
|
|
for(let bucketName of iterate(template.buckets)){
|
|
set("bucket", bucketName)
|
|
code(2)
|
|
}
|
|
|
|
self-contained: true
|
|
code:
|
|
- engine:
|
|
- sh
|
|
- bash
|
|
source: |
|
|
aws s3api list-buckets --query 'Buckets[*].Name'
|
|
|
|
extractors:
|
|
- type: json # type of the extractor
|
|
internal: true
|
|
name: buckets
|
|
json:
|
|
- '.[]'
|
|
|
|
- engine:
|
|
- sh
|
|
- bash
|
|
source: |
|
|
aws s3api get-bucket-encryption --bucket cc-prod-log-bucket --query 'ServerSideEncryptionConfiguration.Rules[?ApplyServerSideEncryptionByDefault.SSEAlgorithm==`aws:kms`].BucketKeyEnabled'
|
|
|
|
matchers:
|
|
- type: word
|
|
words:
|
|
- false
|
|
|
|
extractors:
|
|
- type: dsl
|
|
dsl:
|
|
- '"Key is not enabled for S3 Bucket " + bucket'
|
|
# digest: 4a0a0047304502201c522f260419eb69ca4b6a84f00cb91ab124c3bffc1e43e212b56ac15819dbce022100abbef96323f036a8483f553224f7a98cf8c6d5c863ac4faab4ef6b6e7831ab50:922c64590222798bb761d5b6d8e72950 |