---
policy: /ce/ca/aws/workspaces/workspace-storage-encryption
logic: /ce/ca/aws/workspaces/workspace-storage-encryption/prod.logic.yaml
executionTime: 2026-01-31T12:02:24.538389207Z
generationMs: 54
executionMs: 959
rows:
  - id: '001'
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10__disappearanceTime__c)
      actual: isDisappeared(CA10__disappearanceTime__c)
    runtimeError: {}
  - id: '002'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10__rootVolumeEncryptionEnabled__c') == false && extract('CA10__userVolumeEncryptionEnabled__c')
        == false
      actual: extract('CA10__rootVolumeEncryptionEnabled__c') == false && extract('CA10__userVolumeEncryptionEnabled__c')
        == false
    runtimeError: {}
  - id: '003'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 500
      actual: 500
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: '004'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10__rootVolumeEncryptionEnabled__c') == false
      actual: extract('CA10__rootVolumeEncryptionEnabled__c') == false
    runtimeError: {}
  - id: '005'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: extract('CA10__userVolumeEncryptionEnabled__c') == false
      actual: extract('CA10__userVolumeEncryptionEnabled__c') == false
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/workspaces/workspace-storage-encryption/policy.yaml
    md5Hash: 3EE79C07FE0BBEA4E639E61EA81FD1E7
    content: "---\nnames:\n  full: \"AWS WorkSpace instance EBS volumes are not encrypted\"\
      \n  contextual: \"WorkSpace instance EBS volumes are not encrypted\"\ndescription:\
      \ >\n  Ensure that Amazon WorkSpaces have both root and user storage volumes\
      \ encrypted \n  at rest. Encrypting these volumes protects sensitive data stored\
      \ on the virtual \n  desktop from unauthorized access and helps meet data-at-rest\
      \ encryption requirements.\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n  - \"\
      SECURITY\"\nframeworkMappings:\n  - \"/frameworks/cloudaware/resource-security/data-encryption\"\
      \n  - \"/frameworks/aws-fsbp-v1.0.0/workspace/01\"\n  - \"/frameworks/aws-fsbp-v1.0.0/workspace/02\"\
      \nsimilarPolicies:\n  awsSecurityHub:\n    - name: \"[WorkSpaces.1] WorkSpaces\
      \ user volumes should be encrypted at rest\"\n      url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/workspaces-controls.html#workspaces-1\"\
      \n    - name: \"[WorkSpaces.2] WorkSpaces root volumes should be encrypted at\
      \ rest\"\n      url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/workspaces-controls.html#workspaces-2\"\
      \n  cloudConformity:\n    - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/aws/WorkSpaces/storage-encryption.html\n\
      \      name: WorkSpaces Storage Encryption"
  - path: /ce/ca/aws/workspaces/workspace-storage-encryption/prod.logic.yaml
    md5Hash: D8BC2C88270BBA4803C1824FA0C80BF6
    content: |
      ---
      inputType: "CA10__CaAwsWorkspace__c"
      testData:
        - file: "test-data.json"
      importExtracts:
        - file: "/types/CA10__CaAwsWorkspace__c/object.extracts.yaml"
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "The WorkSpace is not available."
          check:
            NOT_EQUAL:
              left:
                EXTRACT: "CA10__state__c"
              right:
                TEXT: "AVAILABLE"
        - status: "INCOMPLIANT"
          currentStateMessage: "Both root and user WorkSpace volumes are not encrypted at rest."
          remediationMessage: "Enable encryption for the WorkSpace volumes."
          check:
            AND:
              args:
                - IS_EQUAL:
                    left:
                      EXTRACT: CA10__rootVolumeEncryptionEnabled__c
                    right:
                      BOOLEAN: false
                - IS_EQUAL:
                    left:
                      EXTRACT: CA10__userVolumeEncryptionEnabled__c
                    right:
                      BOOLEAN: false
        - status: "INCOMPLIANT"
          currentStateMessage: "The root WorkSpace volume is not encrypted at rest."
          remediationMessage: "Enable encryption for the root volume."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10__rootVolumeEncryptionEnabled__c
              right:
                BOOLEAN: false
        - status: "INCOMPLIANT"
          currentStateMessage: "The user WorkSpace volume is not encrypted at rest."
          remediationMessage: "Enable encryption for the user volume."
          check:
            IS_EQUAL:
              left:
                EXTRACT: CA10__userVolumeEncryptionEnabled__c
              right:
                BOOLEAN: false
      otherwise:
        status: "COMPLIANT"
        currentStateMessage: "The WorkSpace EBS volumes are encrypted at rest."
  - path: /ce/ca/aws/workspaces/workspace-storage-encryption/test-data.json
    md5Hash: 2EA437E0545AD2D141F3B1D7B3111347
    content: |
      [
        {
          "expectedResult": {
            "status": "DISAPPEARED",
            "conditionIndex": "99",
            "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-24T08:56:32Z" },
          "CA10__disappearanceTime__c": "2025-12-15T10:38:57Z",
          "CA10__rootVolumeEncryptionEnabled__c": false,
          "CA10__userVolumeEncryptionEnabled__c": true,
          "CA10__state__c": "AVAILABLE",
          "Id": "001"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "299",
            "conditionText": "extract('CA10__rootVolumeEncryptionEnabled__c') == false && extract('CA10__userVolumeEncryptionEnabled__c') == false",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-24T08:56:32Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__rootVolumeEncryptionEnabled__c": false,
          "CA10__userVolumeEncryptionEnabled__c": false,
          "CA10__state__c": "AVAILABLE",
          "Id": "002"
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "500",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-24T08:56:32Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__rootVolumeEncryptionEnabled__c": true,
          "CA10__userVolumeEncryptionEnabled__c": true,
          "CA10__state__c": "AVAILABLE",
          "Id": "003"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "399",
            "conditionText": "extract('CA10__rootVolumeEncryptionEnabled__c') == false",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-24T08:56:32Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__rootVolumeEncryptionEnabled__c": false,
          "CA10__userVolumeEncryptionEnabled__c": true,
          "CA10__state__c": "AVAILABLE",
          "Id": "004"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "499",
            "conditionText": "extract('CA10__userVolumeEncryptionEnabled__c') == false",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-24T08:56:32Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__rootVolumeEncryptionEnabled__c": true,
          "CA10__userVolumeEncryptionEnabled__c": false,
          "CA10__state__c": "AVAILABLE",
          "Id": "005"
        }
      ]
  - path: /types/CA10__CaAwsWorkspace__c/object.extracts.yaml
    md5Hash: 653A7214D9FA947DB5A00F602EFFCB5C
    content: "---\nextracts:\n# Nullable.\n  - name: CA10__lastKnownUserConnectionTimestamp__c\n\
      \    value:\n      FIELD: \n        path: CA10__lastKnownUserConnectionTimestamp__c\n\
      # Not nullable. Can't have no access, retrieved via workspaces:DescribeWorkspaces\n\
      \  - name: CA10__state__c\n    value:\n      FIELD: \n        path: CA10__state__c\n\
      \        undeterminedIf:\n          isEmpty: \"Corrupted data. Workspace state\
      \ cannot be empty.\"\n# Values: AUTO_STOP | ALWAYS_ON | MANUAL. Not nullable.\
      \ Can't have no access, retrieved via workspaces:DescribeWorkspaces\n  - name:\
      \ CA10__runningMode__c\n    value:\n      FIELD: \n        path: CA10__runningMode__c\n\
      \        undeterminedIf:\n          isEmpty: \"Corrupted data. Workspace Running\
      \ Mode cannot be empty.\"\n# Nullable.\n  - name: CA10__rootVolumeEncryptionEnabled__c\n\
      \    value:\n      FIELD: \n        path: CA10__rootVolumeEncryptionEnabled__c\n\
      # Nullable.\n  - name: CA10__userVolumeEncryptionEnabled__c\n    value:\n  \
      \    FIELD: \n        path: CA10__userVolumeEncryptionEnabled__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" : "001",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10__rootVolumeEncryptionEnabled__c') == false && extract('CA10__userVolumeEncryptionEnabled__c') == false",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "500",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "004",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('CA10__rootVolumeEncryptionEnabled__c') == false",
      "runtimeError" : null
    }
  }, {
    "Id" : "005",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "499",
      "conditionText" : "extract('CA10__userVolumeEncryptionEnabled__c') == false",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsWorkspace__c()
  RETURNS ARRAY<STRUCT<
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__state__c STRING,
      CA10__rootVolumeEncryptionEnabled__c BOOLEAN,
      CA10__userVolumeEncryptionEnabled__c BOOLEAN,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-12-24T08:56:32Z")
    },
    "CA10__disappearanceTime__c" : new Date("2025-12-15T10:38:57Z"),
    "CA10__state__c" : "AVAILABLE",
    "CA10__rootVolumeEncryptionEnabled__c" : false,
    "CA10__userVolumeEncryptionEnabled__c" : true,
    "Id" : "001"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-24T08:56:32Z")
    },
    "CA10__state__c" : "AVAILABLE",
    "CA10__rootVolumeEncryptionEnabled__c" : false,
    "CA10__userVolumeEncryptionEnabled__c" : false,
    "Id" : "002"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-24T08:56:32Z")
    },
    "CA10__state__c" : "AVAILABLE",
    "CA10__rootVolumeEncryptionEnabled__c" : true,
    "CA10__userVolumeEncryptionEnabled__c" : true,
    "Id" : "003"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-24T08:56:32Z")
    },
    "CA10__state__c" : "AVAILABLE",
    "CA10__rootVolumeEncryptionEnabled__c" : false,
    "CA10__userVolumeEncryptionEnabled__c" : true,
    "Id" : "004"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-24T08:56:32Z")
    },
    "CA10__state__c" : "AVAILABLE",
    "CA10__rootVolumeEncryptionEnabled__c" : true,
    "CA10__userVolumeEncryptionEnabled__c" : false,
    "Id" : "005"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsWorkspace__c(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__state__c STRING,
          CA10__rootVolumeEncryptionEnabled__c BOOLEAN,
          CA10__userVolumeEncryptionEnabled__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 TextLib = new function () {
      this.normalize = function(arg) {
          return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase();
      };
      this.isEmpty = function(arg) {
          return this.normalize(arg) == '';
      };
      this.isNotEmpty = function(arg) {
          return this.normalize(arg) != '';
      };
      this.equal = function(left, right) {
          return this.normalize(left) == this.normalize(right);
      };
      this.notEqual = function(left, right) {
          return this.normalize(left) != this.normalize(right);
      };
      this.startsWith = function(arg, substring) {
          return this.normalize(arg).startsWith(this.normalize(substring));
      };
      this.endsWith = function(arg, substring) {
          return this.normalize(arg).endsWith(this.normalize(substring));
      };
      this.contains = function(arg, substring) {
          return this.normalize(arg).includes(this.normalize(substring));
      };
      this.containsAll = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.every(sub => normalizedArg.includes(this.normalize(sub)));
      };
      this.containsAny = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.some(sub => normalizedArg.includes(this.normalize(sub)));
      };
  }();
      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 fieldChecked4() {
          if (TextLib.isEmpty(obj.CA10__state__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__state__c.isEmpty()", currentStateMessage: "Corrupted data. Workspace state cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__state__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('State [obj.CA10__state__c]: ' + obj.CA10__state__c);
      try {
          if (TextLib.notEqual(extract3.call(extract3), 'AVAILABLE')) {
              return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__state__c') != 'AVAILABLE'", currentStateMessage: "The WorkSpace is not available.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[2], conditionIndex:[200..299]
      function extract6() { if (!this.out) { this.out = obj.CA10__rootVolumeEncryptionEnabled__c; } return this.out; };
      function extract9() { if (!this.out) { this.out = obj.CA10__userVolumeEncryptionEnabled__c; } return this.out; };
      references1.push('Root Volume Encryption Enabled [obj.CA10__rootVolumeEncryptionEnabled__c]: ' + obj.CA10__rootVolumeEncryptionEnabled__c);
      references1.push('User Volume Encryption Enabled [obj.CA10__userVolumeEncryptionEnabled__c]: ' + obj.CA10__userVolumeEncryptionEnabled__c);
      if (extract6.call(extract6) == false && extract9.call(extract9) == false) {
          return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__rootVolumeEncryptionEnabled__c') == false && extract('CA10__userVolumeEncryptionEnabled__c') == false", currentStateMessage: "Both root and user WorkSpace volumes are not encrypted at rest.", currentStateReferences: references1.join('\n'), remediation: "Enable encryption for the WorkSpace volumes.", runtimeError: null};
      }
      // condition[3], conditionIndex:[300..399]
      function extract12() { if (!this.out) { this.out = obj.CA10__rootVolumeEncryptionEnabled__c; } return this.out; };
      if (extract12.call(extract12) == false) {
          return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__rootVolumeEncryptionEnabled__c') == false", currentStateMessage: "The root WorkSpace volume is not encrypted at rest.", currentStateReferences: references1.join('\n'), remediation: "Enable encryption for the root volume.", runtimeError: null};
      }
      // condition[4], conditionIndex:[400..499]
      function extract15() { if (!this.out) { this.out = obj.CA10__userVolumeEncryptionEnabled__c; } return this.out; };
      if (extract15.call(extract15) == false) {
          return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "extract('CA10__userVolumeEncryptionEnabled__c') == false", currentStateMessage: "The user WorkSpace volume is not encrypted at rest.", currentStateReferences: references1.join('\n'), remediation: "Enable encryption for the user volume.", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 500, conditionText: "otherwise", currentStateMessage: "The WorkSpace EBS volumes are encrypted at rest.", currentStateReferences: references1.join('\n'), remediation: null, 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__state__c AS CA10__state__c,
          sObject.CA10__rootVolumeEncryptionEnabled__c AS CA10__rootVolumeEncryptionEnabled__c,
          sObject.CA10__userVolumeEncryptionEnabled__c AS CA10__userVolumeEncryptionEnabled__c,
          sObject.Id AS Id,
          process_CA10__CaAwsWorkspace__c(
              STRUCT(
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__state__c AS CA10__state__c,
                  sObject.CA10__rootVolumeEncryptionEnabled__c AS CA10__rootVolumeEncryptionEnabled__c,
                  sObject.CA10__userVolumeEncryptionEnabled__c AS CA10__userVolumeEncryptionEnabled__c,
                  sObject.Id AS Id
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsWorkspace__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
