---
policy: /ce/ca/google/compute-engine/compute-instance-confidential-computing
logic: /ce/ca/google/compute-engine/compute-instance-confidential-computing/prod.logic.yaml
executionTime: 2025-04-24T23:46:48.787152576Z
rows:
  - id: a4Z1
    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: a4Z2
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: not(extract('CA10__machineTypeName__c').startsWith('n2d-'))
      actual: not(extract('CA10__machineTypeName__c').startsWith('n2d-'))
    runtimeError: {}
  - id: a4Z3
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10__confidentialComputeStatus__c').contains('Enabled')
      actual: extract('CA10__confidentialComputeStatus__c').contains('Enabled')
    runtimeError: {}
  - id: a4Z4
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 300
      actual: 300
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/google/compute-engine/compute-instance-confidential-computing/policy.yaml
    md5Hash: 912C4FF66EBF148C1188E1AB0C044039
    content: "---\nnames: \n  full: \"Google GCE Instance Confidential Compute is\
      \ not enabled\"\n  contextual: \"Instance Confidential Compute is not enabled\"\
      \ndescription: \"Google Cloud encrypts data at-rest and in-transit, but customer\
      \ data must be decrypted \\ \n for processing. Confidential Computing is a breakthrough\
      \ technology which encrypts data in-use—while \\ \n it is being processed. Confidential\
      \ Computing environments keep data encrypted in memory and elsewhere \\ \n outside\
      \ the central processing unit (CPU).\n Confidential VMs leverage the Secure\
      \ Encrypted Virtualization (SEV) feature of AMD EPYC™ CPUs. Customer \\ \n data\
      \ will stay encrypted while it is used, indexed, queried, or trained on. Encryption\
      \ keys are \\ \n generated in hardware, per VM, and not exportable. Thanks to\
      \ built-in hardware optimizations of both \\ \n performance and security, there\
      \ is no significant performance penalty to Confidential Computing workloads.\"\
      \ntype: COMPLIANCE_POLICY\ncategories:\n  - \"SECURITY\"\nframeworkMappings:\n\
      \  - /frameworks/cis-gcp-v3.0.0/04/11\n  - /frameworks/cloudaware/resource-security/data-encryption\n\
      similarPolicies:\n  cloudConformity:\n    - url: \"https://www.trendmicro.com/cloudoneconformity-staging/knowledge-base/gcp/ComputeEngine/confidential-computing.html\"\
      \n      name: \"Enable Confidential Computing for Virtual Machine Instances\"\
      \n"
  - path: /ce/ca/google/compute-engine/compute-instance-confidential-computing/prod.logic.yaml
    md5Hash: 0E4684FA5ECF67D8A576BEB5878CC18A
    content: |-
      ---

      inputType: "CA10__CaGoogleGceInstance__c"
      testData:
        - file: test-data.json
      importExtracts:
        - file: /types/CA10__CaGoogleGceInstance__c/object.extracts.yaml
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "Confidential Computing is currently only supported on N2D and C2D machines."
          check:
            NOT:
              arg:
                STARTS_WITH:
                  arg:
                    EXTRACT: "CA10__machineTypeName__c"
                  prefix:
                    TEXT: "n2d-"
        - status: "COMPLIANT"
          currentStateMessage: "Instance has Confidential Computing enabled."
          check:
            CONTAINS:
              arg:
                EXTRACT: "CA10__confidentialComputeStatus__c"
              substring:
                TEXT: "Enabled"
      otherwise:
        status: "INCOMPLIANT"
        currentStateMessage: "Instance has Confidential Computing disabled."
        remediationMessage: "Enable Confidential Computing."
  - path: /types/CA10__CaGoogleGceInstance__c/object.extracts.yaml
    md5Hash: 95F28CC49887E4035F2848BC20DC25D1
    content: "---\nextracts:\n  - name: \"Name\"\n    value: \n      FIELD:\n    \
      \    path: \"Name\"\n        undeterminedIf:\n          isEmpty:  \"Name should\
      \ not be empty\"\n  - name: \"CA10__labels__c\"\n    value: \n      FIELD:\n\
      \        path: \"CA10__labels__c\"\n        undeterminedIf:\n          isEmpty:\
      \  \"Labels should not be empty\"\n  - name: \"CA10__ipForwarding__c\"\n   \
      \ value: \n      FIELD:\n        path: \"CA10__ipForwarding__c\"\n        undeterminedIf:\n\
      \          isEmpty: \"IP forwarding can't be empty\"\n  - name: \"CA10__shieldedIntegrityMonitoringState__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__shieldedIntegrityMonitoringState__c\"\
      \n  - name: \"CA10__shieldedVtpmState__c\"\n    value: \n      FIELD:\n    \
      \    path: \"CA10__shieldedVtpmState__c\"\n  - name: \"CA10__confidentialComputeStatus__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__confidentialComputeStatus__c\"\
      \n  - name: \"CA10__machineTypeName__c\"\n    value: \n      FIELD:\n      \
      \  path: \"CA10__machineTypeName__c\"\n  - name: \"CA10__metadataJson__c\"\n\
      \    value: \n      FIELD:\n        path: \"CA10__metadataJson__c\"\n      \
      \  returnType: BYTES\n  - name: \"caJsonFrom__metadataJson__c\"\n    value:\
      \ \n      JSON_FROM:\n        arg: \n          EXTRACT: \"CA10__metadataJson__c\"\
      \n        undeterminedIf:\n          isInvalid: \"Metadata JSON is invalid.\"\
      \n          isEmpty: \"Metadata JSON is empty.\"\n  - name: \"caJsonFrom__metadataJson__block_project_ssh_keys_value\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caJsonFrom__metadataJson__c\"\
      \n        expression: \"to_string(items[?key=='block-project-ssh-keys'].value)\"\
      \n        undeterminedIf:\n          evaluationError: \"The JSON query has failed.\"\
      \n          resultTypeMismatch: \"The JSON query did not return a text.\"\n\
      \          resultIsEmpty: \"The JSON query did not return a value.\"\n  - name:\
      \ \"caJsonFrom__metadataJson__enable_oslogin_value\"\n    value: \n      JSON_QUERY_TEXT:\n\
      \        arg:\n          EXTRACT: \"caJsonFrom__metadataJson__c\"\n        expression:\
      \ \"to_string(items[?key=='enable-oslogin'].value)\"\n        undeterminedIf:\n\
      \          evaluationError: \"The JSON query has failed.\"\n          resultTypeMismatch:\
      \ \"The JSON query did not return a text.\"\n          resultIsEmpty: \"The\
      \ JSON query did not return a value.\"\n  - name: \"caJsonFrom__metadataJson__serial_port_enable_value\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caJsonFrom__metadataJson__c\"\
      \n        expression: \"to_string(items[?key=='serial-port-enable'].value)\"\
      \n        undeterminedIf:\n          evaluationError: \"The JSON query has failed.\"\
      \n          resultTypeMismatch: \"The JSON query did not return a text.\"\n\
      \          resultIsEmpty: \"The JSON query did not return a value.\"\n"
  - path: /ce/ca/google/compute-engine/compute-instance-confidential-computing/test-data.json
    md5Hash: 39846B7C7C7E8FA984392A84F545F24B
    content: |
      [
        {
          "expectedResult": {
            "status": "DISAPPEARED",
            "conditionIndex": "99",
            "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-09-02T17:45:22Z" },
          "Id": "a4Z1",
          "CA10__disappearanceTime__c": "2024-08-25T08:14:56Z",
          "CA10__machineTypeName__c": "n1-standard-16",
          "CA10__confidentialComputeStatus__c": ""
        },
        {
          "expectedResult": {
            "status": "INAPPLICABLE",
            "conditionIndex": "199",
            "conditionText": "not(extract('CA10__machineTypeName__c').startsWith('n2d-'))",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-09-02T17:45:22Z" },
          "Id": "a4Z2",
          "CA10__disappearanceTime__c": null,
          "CA10__machineTypeName__c": "custom-2",
          "CA10__confidentialComputeStatus__c": "n1-standard-1"
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "299",
            "conditionText": "extract('CA10__confidentialComputeStatus__c').contains('Enabled')",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-09-02T17:45:22Z" },
          "Id": "a4Z3",
          "CA10__disappearanceTime__c": null,
          "CA10__machineTypeName__c": "n2d-micro",
          "CA10__confidentialComputeStatus__c": "ENABLED"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "300",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-09-02T17:45:22Z" },
          "Id": "a4Z4",
          "CA10__disappearanceTime__c": null,
          "CA10__machineTypeName__c": "n2d-micro",
          "CA10__confidentialComputeStatus__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" : "a4Z1",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "a4Z2",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "199",
      "conditionText" : "not(extract('CA10__machineTypeName__c').startsWith('n2d-'))",
      "runtimeError" : null
    }
  }, {
    "Id" : "a4Z3",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10__confidentialComputeStatus__c').contains('Enabled')",
      "runtimeError" : null
    }
  }, {
    "Id" : "a4Z4",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "300",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaGoogleGceInstance__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__machineTypeName__c STRING,
      CA10__confidentialComputeStatus__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-09-02T17:45:22Z")
    },
    "Id" : "a4Z1",
    "CA10__disappearanceTime__c" : new Date("2024-08-25T08:14:56Z"),
    "CA10__machineTypeName__c" : "n1-standard-16",
    "CA10__confidentialComputeStatus__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-09-02T17:45:22Z")
    },
    "Id" : "a4Z2",
    "CA10__machineTypeName__c" : "custom-2",
    "CA10__confidentialComputeStatus__c" : "n1-standard-1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-09-02T17:45:22Z")
    },
    "Id" : "a4Z3",
    "CA10__machineTypeName__c" : "n2d-micro",
    "CA10__confidentialComputeStatus__c" : "ENABLED"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-09-02T17:45:22Z")
    },
    "Id" : "a4Z4",
    "CA10__machineTypeName__c" : "n2d-micro",
    "CA10__confidentialComputeStatus__c" : ""
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaGoogleGceInstance__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__machineTypeName__c STRING,
          CA10__confidentialComputeStatus__c 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));
          };
      }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From Google [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__machineTypeName__c; } return this.out; };
      references1.push('Machine Type Name [obj.CA10__machineTypeName__c]: ' + obj.CA10__machineTypeName__c);
      if (!TextLib.startsWith(extract3.call(extract3), 'n2d-')) {
          return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "not(extract('CA10__machineTypeName__c').startsWith('n2d-'))", currentStateMessage: "Confidential Computing is currently only supported on N2D and C2D machines.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extract6() { if (!this.out) { this.out = obj.CA10__confidentialComputeStatus__c; } return this.out; };
      references1.push('Confidential Compute Status [obj.CA10__confidentialComputeStatus__c]: ' + obj.CA10__confidentialComputeStatus__c);
      if (TextLib.contains(extract6.call(extract6), 'Enabled')) {
          return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__confidentialComputeStatus__c').contains('Enabled')", currentStateMessage: "Instance has Confidential Computing enabled.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "Instance has Confidential Computing disabled.", currentStateReferences: references1.join('\n'), remediation: "Enable Confidential Computing.", 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__machineTypeName__c AS CA10__machineTypeName__c,
          sObject.CA10__confidentialComputeStatus__c AS CA10__confidentialComputeStatus__c,
          process_CA10__CaGoogleGceInstance__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__machineTypeName__c AS CA10__machineTypeName__c,
                  sObject.CA10__confidentialComputeStatus__c AS CA10__confidentialComputeStatus__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaGoogleGceInstance__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
