---
policy: /ce/ca/aws/rds/cluster-encryption
logic: /ce/ca/aws/rds/cluster-encryption/prod.logic.yaml
executionTime: 2025-11-17T14:33:41.843250749Z
generationMs: 70
executionMs: 613
rows:
  - id: test1
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__storageEncrypted__c') == true
      actual: extract('CA10__storageEncrypted__c') == true
    runtimeError: {}
  - id: test2
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/rds/cluster-encryption/policy.yaml
    md5Hash: AEBECCB0CE10724B0B5F53BFAA7096C8
    content: "---\nnames:\n  full: \"AWS RDS Cluster Encryption is not enabled\"\n\
      \  contextual: \"Cluster Encryption is not enabled\"\ndescription: >\n  Ensure\
      \ that Amazon RDS Database Clusters have storage encryption enabled to protect\
      \ data at rest.\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n  - \"SECURITY\"\n\
      frameworkMappings:\n  - \"/frameworks/cloudaware/resource-security/data-encryption\"\
      \n  - \"/frameworks/aws-fsbp-v1.0.0/rds/27\"\n  - \"/frameworks/aws-fsbp-v1.0.0/documentdb/01\"\
      \n  - \"/frameworks/aws-well-architected/sec/08/02\"\nsimilarPolicies:\n  awsSecurityHub:\n\
      \    - name: \"[RDS.27] RDS DB clusters should be encrypted at rest\"\n    \
      \  url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/rds-controls.html#rds-27\"\
      \n    - name: \"[DocumentDB.1] Amazon DocumentDB clusters should be encrypted\
      \ at rest\"  \n      url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/documentdb-controls.html#documentdb-1\""
  - path: /ce/ca/aws/rds/cluster-encryption/prod.logic.yaml
    md5Hash: 672CE5E5CB8DFB2AF76A6BDF503A96AA
    content: "---\ninputType: \"CA10__CaAwsDbCluster__c\"\ntestData:\n  - file: test-data.json\n\
      importExtracts:\n  - file: /types/CA10__CaAwsDbCluster__c/object.extracts.yaml\n\
      conditions:\n  - status: \"COMPLIANT\"\n    currentStateMessage: \"RDS Cluster\
      \ storage encryption is enabled.\"\n    check:\n      IS_EQUAL:\n        left:\n\
      \          EXTRACT: CA10__storageEncrypted__c\n        right:\n          BOOLEAN:\
      \ true \notherwise:\n  status: \"INCOMPLIANT\"\n  currentStateMessage: \"RDS\
      \ Cluster storage encryption is disabled.\"\n  remediationMessage: \"Enable\
      \ RDS Cluster storage encryption.\"\n"
  - path: /ce/ca/aws/rds/cluster-encryption/test-data.json
    md5Hash: 543955F6C011435E9B1BBA2D53060B55
    content: |
      [
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "199",
            "conditionText": "extract('CA10__storageEncrypted__c') == true",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-06-04T19:44:50Z" },
          "Id": "test1",
          "CA10__disappearanceTime__c": null,
          "CA10__storageEncrypted__c": true
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-06-04T19:44:50Z" },
          "Id": "test2",
          "CA10__disappearanceTime__c": null,
          "CA10__storageEncrypted__c": false
        }
      ]
  - path: /types/CA10__CaAwsDbCluster__c/object.extracts.yaml
    md5Hash: AA33B47137B4F1B016C5B164CD2F02E6
    content: |
      ---
      extracts:
        - name: CA10__engine__c
          value:
            FIELD:
              path: CA10__engine__c
              undeterminedIf:
                # https://docs.aws.amazon.com/cli/latest/reference/rds/describe-db-clusters.html
                # "Engine" attribute represents a non-nullable string.
                isEmpty: DB Engine value cannot be empty. Potential data corruption.
      # Values: Yes | No. Not nullable. Cannot have no access, retrieved via rds:DescribeDBClusters
        - name: CA10__autoMinorVersionUpgrade__c
          value:
            FIELD:
              path: CA10__autoMinorVersionUpgrade__c
      # Checkbox.
        - name: CA10__multiAZ__c
          value:
            FIELD:
              path: CA10__multiAZ__c
      # Checkbox.
        - name: CA10__storageEncrypted__c
          value:
            FIELD:
              path: CA10__storageEncrypted__c
script: |-
  CREATE TEMP FUNCTION mock_ExpectedResult()
  RETURNS ARRAY<STRUCT<
          Id STRING,
          expectedResult STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, runtimeError STRING>
      >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "Id" : "test1",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__storageEncrypted__c') == true",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsDbCluster__c()
  RETURNS ARRAY<STRUCT<
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__storageEncrypted__c BOOLEAN,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "CA10__storageEncrypted__c" : true,
    "Id" : "test1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-04T19:44:50Z")
    },
    "CA10__storageEncrypted__c" : false,
    "Id" : "test2"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsDbCluster__c(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__storageEncrypted__c BOOLEAN,
          Id STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c);
      if (obj.CA10__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function extract3() { if (!this.out) { this.out = obj.CA10__storageEncrypted__c; } return this.out; };
      references1.push('Storage Encrypted [obj.CA10__storageEncrypted__c]: ' + obj.CA10__storageEncrypted__c);
      if (extract3.call(extract3) == true) {
          return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__storageEncrypted__c') == true", currentStateMessage: "RDS Cluster storage encryption is enabled.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "RDS Cluster storage encryption is disabled.", currentStateReferences: references1.join('\n'), remediation: "Enable RDS Cluster storage encryption.", runtimeError: null};
  """;


  SELECT
    expectedResult.Id as Id,
    IF (
      IFNULL(expectedResult.expectedResult.status, '') = IFNULL(sObject.result.status, '')
      AND IFNULL(expectedResult.expectedResult.conditionIndex, -1) = IFNULL(sObject.result.conditionIndex, -1)
      AND IFNULL(expectedResult.expectedResult.conditionText, '') = IFNULL(sObject.result.conditionText, '')
      AND IFNULL(expectedResult.expectedResult.runtimeError, '') = IFNULL(sObject.result.runtimeError, ''),
      "MATCH",
      "FAIL"
    ) as match,
    expectedResult.expectedResult.status as expectedStatus, sObject.result.status as actualStatus,
    expectedResult.expectedResult.conditionIndex as expectedConditionIndex, sObject.result.conditionIndex as actualConditionIndex,
    expectedResult.expectedResult.conditionText as expectedConditionText, sObject.result.conditionText as actualConditionText,
    expectedResult.expectedResult.runtimeError as expectedRuntimeError, sObject.result.runtimeError as actualRuntimeError
  FROM UNNEST(mock_ExpectedResult()) expectedResult
  LEFT JOIN (
      SELECT
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__storageEncrypted__c AS CA10__storageEncrypted__c,
          sObject.Id AS Id,
          process_CA10__CaAwsDbCluster__c(
              STRUCT(
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__storageEncrypted__c AS CA10__storageEncrypted__c,
                  sObject.Id AS Id
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsDbCluster__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
