rules:
- id: aws-emr-encrypted-with-cmk
  patterns:
  - pattern-inside: |
      resource "aws_emr_security_configuration" $ANYTHING {
        ...
      }
  - pattern: configuration = "$STATEMENT"
  - metavariable-pattern:
      metavariable: $STATEMENT
      language: json
      patterns:
      - pattern-not-inside: |
          "AwsKmsKey": ...
  message: >-
    Ensure EMR is encrypted at rest using KMS CMKs. CMKs gives you control over the encryption key in
    terms of access and rotation.
  metadata:
    category: security
    technology:
    - terraform
    - aws
    owasp:
    - A03:2017 - Sensitive Data Exposure
    cwe:
    - 'CWE-320: CWE CATEGORY: Key Management Errors'
    references:
    - https://owasp.org/Top10/A02_2021-Cryptographic_Failures
    subcategory:
    - audit
    likelihood: LOW
    impact: LOW
    confidence: LOW
  languages: [hcl]
  severity: WARNING
