---
policy: /ce/ca/aws/efs/file-system-encryption
logic: /ce/ca/aws/efs/file-system-encryption/prod.logic.yaml
executionTime: 2025-04-24T23:44:49.086110009Z
rows:
  - id: a61
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: a62
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__encrypted__c') == true
      actual: extract('CA10__encrypted__c') == true
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/efs/file-system-encryption/policy.yaml
    md5Hash: 85D40DC6C7C2AB5E0C749DB58CCFF95E
    content: |
      ---
      names:
        full: AWS EFS File System encryption is not enabled
        contextual: File System encryption is not enabled
      description: EFS data should be encrypted at rest using AWS KMS (Key Management Service)
      type: COMPLIANCE_POLICY
      categories:
        - SECURITY
      frameworkMappings:
        - "/frameworks/cis-aws-v5.0.0/02/03/01"
        - "/frameworks/cloudaware/resource-security/data-encryption"
        - "/frameworks/aws-fsbp-v1.0.0/efs/01"
      similarPolicies:
        internal:
          - dec-x-966d3183
        cloudConformity:
          - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/aws/EFS/encryption-enabled.html
            name: EFS Encryption Enabled
  - path: /ce/ca/aws/efs/file-system-encryption/prod.logic.yaml
    md5Hash: B93B6126E71DE3E9FB0477C5095D285E
    content: "---\ninputType: \"CA10__CaAwsEfsFileSystem__c\"\ntestData:\n  - file:\
      \ test-data.json\nimportExtracts:\n  - file: /types/CA10__CaAwsEfsFileSystem__c/object.extracts.yaml\n\
      conditions:\n  - status: \"COMPLIANT\"\n    currentStateMessage: \"EFS File\
      \ System data is encrypted.\"\n    check:\n      IS_EQUAL:\n        left:\n\
      \          EXTRACT: CA10__encrypted__c\n        right:\n          BOOLEAN: true\
      \ \notherwise:\n  status: \"INCOMPLIANT\"\n  currentStateMessage: \"EFS File\
      \ System data is not encrypted.\"\n  remediationMessage: \"Consider enabling\
      \ EFS File System data encryption.\""
  - path: /types/CA10__CaAwsEfsFileSystem__c/object.extracts.yaml
    md5Hash: 15385FD3451CEB6C8D0C4AA8A1A8215C
    content: "---\nextracts:\n  - name: CA10__encrypted__c\n    value: \n      FIELD:\n\
      \        path: CA10__encrypted__c\n        # Boolean attribute"
  - path: /ce/ca/aws/efs/file-system-encryption/test-data.json
    md5Hash: 9EA48B262D9BC25412E92A076F7F5C85
    content: |
      [
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-06-04T19:44:50Z" },
          "Id": "a61",
          "CA10__disappearanceTime__c": null,
          "CA10__encrypted__c": false
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "199",
            "conditionText": "extract('CA10__encrypted__c') == true",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-06-04T19:44:50Z" },
          "Id": "a62",
          "CA10__disappearanceTime__c": null,
          "CA10__encrypted__c": true
        }
      ]
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" : "a61",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "a62",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__encrypted__c') == true",
      "runtimeError" : null
    }
  } ];
  """;

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

  CREATE TEMP FUNCTION process_CA10__CaAwsEfsFileSystem__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__encrypted__c BOOLEAN
      >,
      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__encrypted__c; } return this.out; };
      references1.push('Encrypted [obj.CA10__encrypted__c]: ' + obj.CA10__encrypted__c);
      if (extract3.call(extract3) == true) {
          return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__encrypted__c') == true", currentStateMessage: "EFS File System data is encrypted.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "EFS File System data is not encrypted.", currentStateReferences: references1.join('\n'), remediation: "Consider enabling EFS File System data 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.Id AS Id,
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__encrypted__c AS CA10__encrypted__c,
          process_CA10__CaAwsEfsFileSystem__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__encrypted__c AS CA10__encrypted__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsEfsFileSystem__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
