---
policy: /ce/ca/google/vpc/subnetwork-flow-logs
logic: /ce/ca/google/vpc/subnetwork-flow-logs/prod.logic.yaml
executionTime: 2025-04-24T23:47:41.788108805Z
rows:
  - id: a4i0e1
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__flowLogs__c') == 'Enabled' && extract('CA10__logConfigState__c')
        == 'Enabled' && extract('CA10__logConfigAggregationInterval__c') == 'INTERVAL_5_SEC'
        && extract('CA10__logConfigFlowSampling__c') == number(1.0) && extract('CA10__logConfigMetadata__c')
        == 'INCLUDE_ALL_METADATA' && (extract('CA10__logConfigFilterExpr__c') == 'False'
        || extract('CA10__logConfigFilterExpr__c').isEmpty())
      actual: extract('CA10__flowLogs__c') == 'Enabled' && extract('CA10__logConfigState__c')
        == 'Enabled' && extract('CA10__logConfigAggregationInterval__c') == 'INTERVAL_5_SEC'
        && extract('CA10__logConfigFlowSampling__c') == number(1.0) && extract('CA10__logConfigMetadata__c')
        == 'INCLUDE_ALL_METADATA' && (extract('CA10__logConfigFilterExpr__c') == 'False'
        || extract('CA10__logConfigFilterExpr__c').isEmpty())
    runtimeError: {}
  - id: a4i0e8_logConfigFilterExpr2
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__flowLogs__c') == 'Enabled' && extract('CA10__logConfigState__c')
        == 'Enabled' && extract('CA10__logConfigAggregationInterval__c') == 'INTERVAL_5_SEC'
        && extract('CA10__logConfigFlowSampling__c') == number(1.0) && extract('CA10__logConfigMetadata__c')
        == 'INCLUDE_ALL_METADATA' && (extract('CA10__logConfigFilterExpr__c') == 'False'
        || extract('CA10__logConfigFilterExpr__c').isEmpty())
      actual: extract('CA10__flowLogs__c') == 'Enabled' && extract('CA10__logConfigState__c')
        == 'Enabled' && extract('CA10__logConfigAggregationInterval__c') == 'INTERVAL_5_SEC'
        && extract('CA10__logConfigFlowSampling__c') == number(1.0) && extract('CA10__logConfigMetadata__c')
        == 'INCLUDE_ALL_METADATA' && (extract('CA10__logConfigFilterExpr__c') == 'False'
        || extract('CA10__logConfigFilterExpr__c').isEmpty())
    runtimeError: {}
  - id: a4i0e2_flowLogs
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: a4i0e3_logConfigState
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: a4i0e4_logConfigAggregationInterval
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: a4i0e5_logConfigFlowSampling
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: a4i0e6_logConfigMetadata
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: a4i0e7_logConfigFilterExpr1
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/google/vpc/subnetwork-flow-logs/policy.yaml
    md5Hash: 174A021F8A903F363F0750B288106A48
    content: "---\nnames: \n  full: \"Google GCE Subnetwork Flow Logs are not enabled\"\
      \n  contextual: \"GCE Subnetwork Flow Logs are not enabled\"\ndescription: \"\
      Flow Logs is a feature that enables users to capture information about the IP\
      \ traffic \\\n going to and from network interfaces in the organization's VPC\
      \ Subnets. Once a flow log is created, \\\n the user can view and retrieve its\
      \ data in Stackdriver Logging. It is recommended that Flow Logs be \\\n enabled\
      \ for every business-critical VPC subnet.\"\ntype: COMPLIANCE_POLICY\ncategories:\n\
      \  - \"SECURITY\"\nframeworkMappings:\n  - /frameworks/cis-gcp-v3.0.0/03/08\n\
      \  - /frameworks/cloudaware/logging-and-monitoring/logging-and-monitoring-configuration\n\
      similarPolicies:\n  cloudConformity:\n    - url: \"https://www.trendmicro.com/cloudoneconformity/knowledge-base/gcp/CloudVPC/enable-vpc-flow-logs.html\"\
      \n      name: \"Enable VPC Flow Logs for VPC Subnets\"\n"
  - path: /ce/ca/google/vpc/subnetwork-flow-logs/prod.logic.yaml
    md5Hash: C87617E6CC2A3914F65C4A054BBB5319
    content: "---\n\ninputType: \"CA10__CaGoogleGceSubnetwork__c\"\ntestData:\n  -\
      \ file: test-data.json\nimportExtracts:\n  - file: /types/CA10__CaGoogleGceSubnetwork__c/object.extracts.yaml\n\
      conditions:\n  - status: \"COMPLIANT\"\n    currentStateMessage: \"Flow Logs\
      \ are enabled and configured correctly.\"\n    check:\n      AND:\n        args:\n\
      \          - IS_EQUAL:\n              left: \n                EXTRACT: \"CA10__flowLogs__c\"\
      \n              right:\n                TEXT: \"Enabled\"\n          - IS_EQUAL:\n\
      \              left:\n                EXTRACT: \"CA10__logConfigState__c\"\n\
      \              right:\n                TEXT: \"Enabled\"\n          - IS_EQUAL:\n\
      \              left:\n                EXTRACT: \"CA10__logConfigAggregationInterval__c\"\
      \n              right:\n                TEXT: \"INTERVAL_5_SEC\"\n         \
      \ - IS_EQUAL:\n              left:\n                EXTRACT: \"CA10__logConfigFlowSampling__c\"\
      \n              right:\n                NUMBER: 1.0\n          - IS_EQUAL:\n\
      \              left:\n                EXTRACT: \"CA10__logConfigMetadata__c\"\
      \n              right:\n                TEXT: \"INCLUDE_ALL_METADATA\"\n   \
      \       - OR:\n              args:\n                - IS_EQUAL:\n          \
      \          left:\n                      EXTRACT: \"CA10__logConfigFilterExpr__c\"\
      \n                    right:\n                      TEXT: \"False\"\n      \
      \          - IS_EMPTY:\n                    arg:\n                      EXTRACT:\
      \ \"CA10__logConfigFilterExpr__c\"\notherwise:\n  status: \"INCOMPLIANT\"\n\
      \  currentStateMessage: \"Flow Logs aren't enabled or configured correctly.\"\
      \n  remediationMessage: \"Enable flow logs.\""
  - path: /types/CA10__CaGoogleGceSubnetwork__c/object.extracts.yaml
    md5Hash: 32AFC7212BC1465E8669136233FF0873
    content: "---\nextracts:\n  - name: \"CA10__logConfigState__c\"\n    value: \n\
      \      FIELD:\n        path: \"CA10__logConfigState__c\"\n  - name: \"CA10__logConfigMetadataFields__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__logConfigMetadataFields__c\"\
      \n  - name: \"CA10__logConfigMetadata__c\"\n    value: \n      FIELD:\n    \
      \    path: \"CA10__logConfigMetadata__c\"\n  - name: \"CA10__logConfigFlowSampling__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__logConfigFlowSampling__c\"\
      \n  - name: \"CA10__logConfigFilterExpr__c\"\n    value: \n      FIELD:\n  \
      \      path: \"CA10__logConfigFilterExpr__c\"\n  - name: \"CA10__logConfigAggregationInterval__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__logConfigAggregationInterval__c\"\
      \n  - name: \"CA10__flowLogs__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10__flowLogs__c\"\n  - name: \"CA10__purpose__c\"\n    value: \n     \
      \ FIELD:\n        path: \"CA10__purpose__c\""
  - path: /ce/ca/google/vpc/subnetwork-flow-logs/test-data.json
    md5Hash: 63A39A99B1DE6CB9793155A0F824BA69
    content: |
      [
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "199",
            "conditionText": "extract('CA10__flowLogs__c') == 'Enabled' && extract('CA10__logConfigState__c') == 'Enabled' && extract('CA10__logConfigAggregationInterval__c') == 'INTERVAL_5_SEC' && extract('CA10__logConfigFlowSampling__c') == number(1.0) && extract('CA10__logConfigMetadata__c') == 'INCLUDE_ALL_METADATA' && (extract('CA10__logConfigFilterExpr__c') == 'False' || extract('CA10__logConfigFilterExpr__c').isEmpty())",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-11-26T19:27:00Z" },
          "Id": "a4i0e1",
          "CA10__disappearanceTime__c": null,
          "CA10__flowLogs__c": "Enabled",
          "CA10__logConfigState__c": "Enabled",
          "CA10__logConfigAggregationInterval__c": "INTERVAL_5_SEC",
          "CA10__logConfigFlowSampling__c": 1.0,
          "CA10__logConfigMetadata__c": "INCLUDE_ALL_METADATA",
          "CA10__logConfigFilterExpr__c": "false"
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "199",
            "conditionText": "extract('CA10__flowLogs__c') == 'Enabled' && extract('CA10__logConfigState__c') == 'Enabled' && extract('CA10__logConfigAggregationInterval__c') == 'INTERVAL_5_SEC' && extract('CA10__logConfigFlowSampling__c') == number(1.0) && extract('CA10__logConfigMetadata__c') == 'INCLUDE_ALL_METADATA' && (extract('CA10__logConfigFilterExpr__c') == 'False' || extract('CA10__logConfigFilterExpr__c').isEmpty())",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-11-26T19:27:00Z" },
          "Id": "a4i0e8_logConfigFilterExpr2",
          "CA10__disappearanceTime__c": null,
          "CA10__flowLogs__c": "Enabled",
          "CA10__logConfigState__c": "Enabled",
          "CA10__logConfigAggregationInterval__c": "INTERVAL_5_SEC",
          "CA10__logConfigFlowSampling__c": 1.0,
          "CA10__logConfigMetadata__c": "INCLUDE_ALL_METADATA",
          "CA10__logConfigFilterExpr__c": ""
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-11-26T19:27:00Z" },
          "Id": "a4i0e2_flowLogs",
          "CA10__disappearanceTime__c": null,
          "CA10__flowLogs__c": "Disabled",
          "CA10__logConfigState__c": "Enabled",
          "CA10__logConfigAggregationInterval__c": "INTERVAL_5_SEC",
          "CA10__logConfigFlowSampling__c": 1.0,
          "CA10__logConfigMetadata__c": "INCLUDE_ALL_METADATA",
          "CA10__logConfigFilterExpr__c": "false"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-11-26T19:27:00Z" },
          "Id": "a4i0e3_logConfigState",
          "CA10__disappearanceTime__c": null,
          "CA10__flowLogs__c": "Enabled",
          "CA10__logConfigState__c": "Disabled",
          "CA10__logConfigAggregationInterval__c": "INTERVAL_5_SEC",
          "CA10__logConfigFlowSampling__c": 1.0,
          "CA10__logConfigMetadata__c": "INCLUDE_ALL_METADATA",
          "CA10__logConfigFilterExpr__c": "false"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-11-26T19:27:00Z" },
          "Id": "a4i0e4_logConfigAggregationInterval",
          "CA10__disappearanceTime__c": null,
          "CA10__flowLogs__c": "Enabled",
          "CA10__logConfigState__c": "Enabled",
          "CA10__logConfigAggregationInterval__c": "INTERVAL_30_SEC",
          "CA10__logConfigFlowSampling__c": 1.0,
          "CA10__logConfigMetadata__c": "INCLUDE_ALL_METADATA",
          "CA10__logConfigFilterExpr__c": "false"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-11-26T19:27:00Z" },
          "Id": "a4i0e5_logConfigFlowSampling",
          "CA10__disappearanceTime__c": null,
          "CA10__flowLogs__c": "Enabled",
          "CA10__logConfigState__c": "Enabled",
          "CA10__logConfigAggregationInterval__c": "INTERVAL_5_SEC",
          "CA10__logConfigFlowSampling__c": 0.5,
          "CA10__logConfigMetadata__c": "INCLUDE_ALL_METADATA",
          "CA10__logConfigFilterExpr__c": "false"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-11-26T19:27:00Z" },
          "Id": "a4i0e6_logConfigMetadata",
          "CA10__disappearanceTime__c": null,
          "CA10__flowLogs__c": "Enabled",
          "CA10__logConfigState__c": "Enabled",
          "CA10__logConfigAggregationInterval__c": "INTERVAL_5_SEC",
          "CA10__logConfigFlowSampling__c": 1.0,
          "CA10__logConfigMetadata__c": "CUSTOM_METADATA",
          "CA10__logConfigFilterExpr__c": "false"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-11-26T19:27:00Z" },
          "Id": "a4i0e7_logConfigFilterExpr1",
          "CA10__disappearanceTime__c": null,
          "CA10__flowLogs__c": "Enabled",
          "CA10__logConfigState__c": "Enabled",
          "CA10__logConfigAggregationInterval__c": "INTERVAL_5_SEC",
          "CA10__logConfigFlowSampling__c": 1.0,
          "CA10__logConfigMetadata__c": "INCLUDE_ALL_METADATA",
          "CA10__logConfigFilterExpr__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" : "a4i0e1",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__flowLogs__c') == 'Enabled' && extract('CA10__logConfigState__c') == 'Enabled' && extract('CA10__logConfigAggregationInterval__c') == 'INTERVAL_5_SEC' && extract('CA10__logConfigFlowSampling__c') == number(1.0) && extract('CA10__logConfigMetadata__c') == 'INCLUDE_ALL_METADATA' && (extract('CA10__logConfigFilterExpr__c') == 'False' || extract('CA10__logConfigFilterExpr__c').isEmpty())",
      "runtimeError" : null
    }
  }, {
    "Id" : "a4i0e8_logConfigFilterExpr2",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__flowLogs__c') == 'Enabled' && extract('CA10__logConfigState__c') == 'Enabled' && extract('CA10__logConfigAggregationInterval__c') == 'INTERVAL_5_SEC' && extract('CA10__logConfigFlowSampling__c') == number(1.0) && extract('CA10__logConfigMetadata__c') == 'INCLUDE_ALL_METADATA' && (extract('CA10__logConfigFilterExpr__c') == 'False' || extract('CA10__logConfigFilterExpr__c').isEmpty())",
      "runtimeError" : null
    }
  }, {
    "Id" : "a4i0e2_flowLogs",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "a4i0e3_logConfigState",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "a4i0e4_logConfigAggregationInterval",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "a4i0e5_logConfigFlowSampling",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "a4i0e6_logConfigMetadata",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "a4i0e7_logConfigFilterExpr1",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaGoogleGceSubnetwork__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__flowLogs__c STRING,
      CA10__logConfigState__c STRING,
      CA10__logConfigAggregationInterval__c STRING,
      CA10__logConfigFlowSampling__c FLOAT64,
      CA10__logConfigMetadata__c STRING,
      CA10__logConfigFilterExpr__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-11-26T19:27:00Z")
    },
    "Id" : "a4i0e1",
    "CA10__flowLogs__c" : "Enabled",
    "CA10__logConfigState__c" : "Enabled",
    "CA10__logConfigAggregationInterval__c" : "INTERVAL_5_SEC",
    "CA10__logConfigFlowSampling__c" : 1.0,
    "CA10__logConfigMetadata__c" : "INCLUDE_ALL_METADATA",
    "CA10__logConfigFilterExpr__c" : "false"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-26T19:27:00Z")
    },
    "Id" : "a4i0e8_logConfigFilterExpr2",
    "CA10__flowLogs__c" : "Enabled",
    "CA10__logConfigState__c" : "Enabled",
    "CA10__logConfigAggregationInterval__c" : "INTERVAL_5_SEC",
    "CA10__logConfigFlowSampling__c" : 1.0,
    "CA10__logConfigMetadata__c" : "INCLUDE_ALL_METADATA",
    "CA10__logConfigFilterExpr__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-26T19:27:00Z")
    },
    "Id" : "a4i0e2_flowLogs",
    "CA10__flowLogs__c" : "Disabled",
    "CA10__logConfigState__c" : "Enabled",
    "CA10__logConfigAggregationInterval__c" : "INTERVAL_5_SEC",
    "CA10__logConfigFlowSampling__c" : 1.0,
    "CA10__logConfigMetadata__c" : "INCLUDE_ALL_METADATA",
    "CA10__logConfigFilterExpr__c" : "false"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-26T19:27:00Z")
    },
    "Id" : "a4i0e3_logConfigState",
    "CA10__flowLogs__c" : "Enabled",
    "CA10__logConfigState__c" : "Disabled",
    "CA10__logConfigAggregationInterval__c" : "INTERVAL_5_SEC",
    "CA10__logConfigFlowSampling__c" : 1.0,
    "CA10__logConfigMetadata__c" : "INCLUDE_ALL_METADATA",
    "CA10__logConfigFilterExpr__c" : "false"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-26T19:27:00Z")
    },
    "Id" : "a4i0e4_logConfigAggregationInterval",
    "CA10__flowLogs__c" : "Enabled",
    "CA10__logConfigState__c" : "Enabled",
    "CA10__logConfigAggregationInterval__c" : "INTERVAL_30_SEC",
    "CA10__logConfigFlowSampling__c" : 1.0,
    "CA10__logConfigMetadata__c" : "INCLUDE_ALL_METADATA",
    "CA10__logConfigFilterExpr__c" : "false"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-26T19:27:00Z")
    },
    "Id" : "a4i0e5_logConfigFlowSampling",
    "CA10__flowLogs__c" : "Enabled",
    "CA10__logConfigState__c" : "Enabled",
    "CA10__logConfigAggregationInterval__c" : "INTERVAL_5_SEC",
    "CA10__logConfigFlowSampling__c" : 0.5,
    "CA10__logConfigMetadata__c" : "INCLUDE_ALL_METADATA",
    "CA10__logConfigFilterExpr__c" : "false"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-26T19:27:00Z")
    },
    "Id" : "a4i0e6_logConfigMetadata",
    "CA10__flowLogs__c" : "Enabled",
    "CA10__logConfigState__c" : "Enabled",
    "CA10__logConfigAggregationInterval__c" : "INTERVAL_5_SEC",
    "CA10__logConfigFlowSampling__c" : 1.0,
    "CA10__logConfigMetadata__c" : "CUSTOM_METADATA",
    "CA10__logConfigFilterExpr__c" : "false"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-26T19:27:00Z")
    },
    "Id" : "a4i0e7_logConfigFilterExpr1",
    "CA10__flowLogs__c" : "Enabled",
    "CA10__logConfigState__c" : "Enabled",
    "CA10__logConfigAggregationInterval__c" : "INTERVAL_5_SEC",
    "CA10__logConfigFlowSampling__c" : 1.0,
    "CA10__logConfigMetadata__c" : "INCLUDE_ALL_METADATA",
    "CA10__logConfigFilterExpr__c" : "true"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaGoogleGceSubnetwork__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__flowLogs__c STRING,
          CA10__logConfigState__c STRING,
          CA10__logConfigAggregationInterval__c STRING,
          CA10__logConfigFlowSampling__c FLOAT64,
          CA10__logConfigMetadata__c STRING,
          CA10__logConfigFilterExpr__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__flowLogs__c; } return this.out; };
      function extract6() { if (!this.out) { this.out = obj.CA10__logConfigState__c; } return this.out; };
      function extract9() { if (!this.out) { this.out = obj.CA10__logConfigAggregationInterval__c; } return this.out; };
      function extract12() { if (!this.out) { this.out = obj.CA10__logConfigFlowSampling__c; } return this.out; };
      function extract15() { if (!this.out) { this.out = obj.CA10__logConfigMetadata__c; } return this.out; };
      function extract18() { if (!this.out) { this.out = obj.CA10__logConfigFilterExpr__c; } return this.out; };
      references1.push('Flow Logs [obj.CA10__flowLogs__c]: ' + obj.CA10__flowLogs__c);
      references1.push('Log Config: State [obj.CA10__logConfigState__c]: ' + obj.CA10__logConfigState__c);
      references1.push('Log Config: Aggregation Interval [obj.CA10__logConfigAggregationInterval__c]: ' + obj.CA10__logConfigAggregationInterval__c);
      references1.push('Log Config: Flow Sampling [obj.CA10__logConfigFlowSampling__c]: ' + obj.CA10__logConfigFlowSampling__c);
      references1.push('Log Config: Metadata [obj.CA10__logConfigMetadata__c]: ' + obj.CA10__logConfigMetadata__c);
      references1.push('Log Config: Filter Expr [obj.CA10__logConfigFilterExpr__c]: ' + obj.CA10__logConfigFilterExpr__c);
      if (TextLib.equal(extract3.call(extract3), 'Enabled') && TextLib.equal(extract6.call(extract6), 'Enabled') && TextLib.equal(extract9.call(extract9), 'INTERVAL_5_SEC') && extract12.call(extract12) == 1.0 && TextLib.equal(extract15.call(extract15), 'INCLUDE_ALL_METADATA') && (TextLib.equal(extract18.call(extract18), 'False') || TextLib.isEmpty(extract18.call(extract18)))) {
          return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__flowLogs__c') == 'Enabled' && extract('CA10__logConfigState__c') == 'Enabled' && extract('CA10__logConfigAggregationInterval__c') == 'INTERVAL_5_SEC' && extract('CA10__logConfigFlowSampling__c') == number(1.0) && extract('CA10__logConfigMetadata__c') == 'INCLUDE_ALL_METADATA' && (extract('CA10__logConfigFilterExpr__c') == 'False' || extract('CA10__logConfigFilterExpr__c').isEmpty())", currentStateMessage: "Flow Logs are enabled and configured correctly.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "Flow Logs aren't enabled or configured correctly.", currentStateReferences: references1.join('\n'), remediation: "Enable flow logs.", 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__flowLogs__c AS CA10__flowLogs__c,
          sObject.CA10__logConfigState__c AS CA10__logConfigState__c,
          sObject.CA10__logConfigAggregationInterval__c AS CA10__logConfigAggregationInterval__c,
          sObject.CA10__logConfigFlowSampling__c AS CA10__logConfigFlowSampling__c,
          sObject.CA10__logConfigMetadata__c AS CA10__logConfigMetadata__c,
          sObject.CA10__logConfigFilterExpr__c AS CA10__logConfigFilterExpr__c,
          process_CA10__CaGoogleGceSubnetwork__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__flowLogs__c AS CA10__flowLogs__c,
                  sObject.CA10__logConfigState__c AS CA10__logConfigState__c,
                  sObject.CA10__logConfigAggregationInterval__c AS CA10__logConfigAggregationInterval__c,
                  sObject.CA10__logConfigFlowSampling__c AS CA10__logConfigFlowSampling__c,
                  sObject.CA10__logConfigMetadata__c AS CA10__logConfigMetadata__c,
                  sObject.CA10__logConfigFilterExpr__c AS CA10__logConfigFilterExpr__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaGoogleGceSubnetwork__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
