リソースを定義 resource "aws_s3_bucket" "tfsec_sample" { bucket = "tfsec-sample" } Terraformコード tfsec実行結果 Result #1 HIGH No public access block so not blocking public acls Result #2 HIGH No public access block so not blocking public policies Result #3 HIGH Bucket does not have encryption enabled Result #4 HIGH No public access block so not ignoring public acls Result #5 HIGH No public access block so not restricting public buckets Result #6 HIGH Bucket does not encrypt data with a customer managed key Result #7 MEDIUM Bucket does not have logging enabled Result #8 MEDIUM Bucket does not have versioning enabled Result #9 LOW Bucket does not have a corresponding public access block.
の問題を修正 resource "aws_s3_bucket" "tfsec_sample" { bucket = "tfsec-sample" } resource "aws_s3_bucket_public_access_block" "tfsec_sample" { bucket = aws_s3_bucket.tfsec_sample.id block_public_acls = true block_public_policy = true ignore_public_acls = true restrict_public_buckets = true } Terraformコード tfsec実行結果 Result #1 HIGH Bucket does not have encryption enabled Result #2 HIGH Bucket does not encrypt data with a customer managed key Result #7 MEDIUM Bucket does not have logging enabled Result #8 MEDIUM Bucket does not have versioning enabled
severity_overrides: CUS001: ERROR aws-s3-enable-versioning: HIGH .tfsec/config.yml tfsec実行結果 Result #1 HIGH Bucket does not have versioning enabled Result #2 MEDIUM Bucket does not have logging enabled • 組織やチームのポリシーに応じて特定のルールを強制したい場合に有用 ◦ リポジトリのbranch protection ruleでHIGHの問題が残っている間は マージできないようにする等
- code: CUS001 description: aws resources must have confidentiality tag errorMessage: confidentiality tag must be specified matchSpec: action: contains name: tags value: confidentiality requiredTypes: - resource requiredLabels: - aws_s3_bucket severity: ERROR .tfsec/confidentiality_tag_tfchecks.yml tfsec実行結果 Result #1 HIGH Custom check failed for resource aws_s3_bucket.tfsec_sample. confidentiality tag must be specified tfsec実行コマンド 詳細は以下を参照 https://aquasecurity.github.io/tfsec/v1.28.0/guides/configuration/custom-checks/