rules:
- id: aws-codebuild-project-artifacts-unencrypted
  patterns:
  - pattern: |
      resource "aws_codebuild_project" $ANYTHING {
        ...
        artifacts {
          ...
          encryption_disabled = true
          ...
        }
        ...
      }
  - pattern-not-inside: |
      resource "aws_codebuild_project" $ANYTHING {
        ...
        artifacts {
          type = "NO_ARTIFACTS"
          encryption_disabled = true
        }
        ...
      }
  - pattern-not-inside: |
      resource "aws_codebuild_project" $ANYTHING {
        ...
        artifacts {
          type = "NO_ARTIFACTS"
        }
        ...
      }
  message: The AWS CodeBuild Project Artifacts are unencrypted. The AWS KMS encryption key protects artifacts
    in the CodeBuild Projects. To create your own, create a aws_kms_key resource or use the ARN string
    of a key in your account.
  languages: [hcl]
  severity: WARNING
  metadata:
    owasp:
    - A03:2017 - Sensitive Data Exposure
    cwe:
    - 'CWE-320: CWE CATEGORY: Key Management Errors'
    technology:
    - aws
    - terraform
    category: security
    references:
    - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
    subcategory:
    - audit
    likelihood: LOW
    impact: LOW
    confidence: LOW
