---
policy: /ce/ca/azure/virtual-network/virtual-network-flow-logs-retention-period-over-90-days
logic: /ce/ca/azure/virtual-network/virtual-network-flow-logs-retention-period-over-90-days/prod.logic.yaml
executionTime: 2025-07-21T17:40:59.010074911Z
rows:
  - id: '001'
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10Z1__logStatus__c') != 'Enabled'
      actual: extract('CA10Z1__logStatus__c') != 'Enabled'
    runtimeError: {}
  - id: '002'
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: isEmptyLookup('CA10Z1__virtualNetwork__r')
      actual: isEmptyLookup('CA10Z1__virtualNetwork__r')
    runtimeError: {}
  - id: '003'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10Z1__retentionPolicyStatus__c') != 'Enabled'
      actual: extract('CA10Z1__retentionPolicyStatus__c') != 'Enabled'
    runtimeError: {}
  - id: '004'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 500
      actual: 500
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: '005'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: extract('CA10Z1__retentionPolicyDays__c') == number(0.0) || extract('CA10Z1__retentionPolicyDays__c')
        >= number(90.0)
      actual: extract('CA10Z1__retentionPolicyDays__c') == number(0.0) || extract('CA10Z1__retentionPolicyDays__c')
        >= number(90.0)
    runtimeError: {}
  - id: '006'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: extract('CA10Z1__retentionPolicyDays__c') == number(0.0) || extract('CA10Z1__retentionPolicyDays__c')
        >= number(90.0)
      actual: extract('CA10Z1__retentionPolicyDays__c') == number(0.0) || extract('CA10Z1__retentionPolicyDays__c')
        >= number(90.0)
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/virtual-network/virtual-network-flow-logs-retention-period-over-90-days/policy.yaml
    md5Hash: ACEEDF9AE78970D827F4C3B56EA5CDBE
    content: |
      ---
      names:
        full: Azure Virtual Network Flow Logs retention period is less than 90 days
        contextual: Virtual Network Flow Logs retention period is less than 90 days
      description: Ensure that virtual network flow logs are retained for greater than or equal to 90 days.
      type: COMPLIANCE_POLICY
      categories:
        - SECURITY
        - RELIABILITY
      frameworkMappings:
        - "/frameworks/cis-azure-v4.0.0/08/08"
        - "/frameworks/cloudaware/logging-and-monitoring/logging-and-monitoring-configuration"
  - path: /ce/ca/azure/virtual-network/virtual-network-flow-logs-retention-period-over-90-days/prod.logic.yaml
    md5Hash: 0E63FC49C6A917F8F58E1A0DC14E00E4
    content: |-
      ---
      inputType: "CA10Z1__CaAzureNetworkWatcherFlowLog__c"
      importExtracts:
        - file: /types/CA10Z1__CaAzureNetworkWatcherFlowLog__c/object.extracts.yaml
      testData:
        - file: "test-data.json"
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "Flow Log is disabled."
          check:
            NOT_EQUAL:
              left:
                EXTRACT: "CA10Z1__logStatus__c"
              right:
                TEXT: "Enabled"
        - status: "INAPPLICABLE"
          currentStateMessage: "Only for Virtual network Flow Logs."
          check:
            IS_EMPTY_LOOKUP: "CA10Z1__virtualNetwork__r"
        - status: "INCOMPLIANT"
          currentStateMessage: "Virtual network Flow Logs retention policy is disabled."
          remediationMessage: "Consider enabling retention policy for Virtual network Flow Logs."
          check:
            NOT_EQUAL:
              left:
                EXTRACT: "CA10Z1__retentionPolicyStatus__c"
              right:
                TEXT: "Enabled"
        - status: "COMPLIANT"
          currentStateMessage: "Virtual network Flow Logs are enabled and the retention period is set to 'greater than or equal to 90 days'."
          check:
            OR:
              args:
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10Z1__retentionPolicyDays__c"
                    right:
                      NUMBER: 0.0
                - GREATER_THAN_EQUAL:
                    left:
                      EXTRACT: "CA10Z1__retentionPolicyDays__c"
                    right:
                      NUMBER: 90.0
      otherwise:
        status: "INCOMPLIANT"
        currentStateMessage: "Virtual network Flow Logs retention period is less than 90 days."
        remediationMessage: "Consider setting the retention period to 'greater then or equal to 90 days'."
  - path: /types/CA10Z1__CaAzureNetworkWatcherFlowLog__c/object.extracts.yaml
    md5Hash: 59B4D363F220B72D61773BA679C17EDB
    content: "---\nextracts:\n# Nullable. Text field.\n  - name: \"CA10Z1__logStatus__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10Z1__logStatus__c\"\n# Nullable.\
      \ Text field.\n  - name: \"CA10Z1__retentionPolicyStatus__c\"\n    value: \n\
      \      FIELD:\n        path: \"CA10Z1__retentionPolicyStatus__c\"\n# Nullable.\
      \ Number field.\n  - name: \"CA10Z1__retentionPolicyDays__c\"\n    value: \n\
      \      FIELD:\n        path: \"CA10Z1__retentionPolicyDays__c\"        \n\n\n\
      \n\n\n        \n\n        "
  - path: /ce/ca/azure/virtual-network/virtual-network-flow-logs-retention-period-over-90-days/test-data.json
    md5Hash: 7006BE66A50B1A7F8EB9BBE14B5B813C
    content: |
      [
        {
          "expectedResult": {
            "status": "INAPPLICABLE",
            "conditionIndex": "199",
            "conditionText": "extract('CA10Z1__logStatus__c') != 'Enabled'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-03T06:52:36Z" },
          "Id": "001",
          "CA10Z1__disappearanceTime__c": null,
          "CA10Z1__logStatus__c": "Disabled",
          "CA10Z1__virtualNetwork__c": "v001",
          "CA10Z1__virtualNetworkId__c": "/subscriptions/565c00f0-066e-43b6-9bee-9cf93fe2b312/resourcegroups/domaincontrollers-rg/providers/microsoft.network/virtualNetworks/v001",
          "CA10Z1__retentionPolicyStatus__c": "Disabled",
          "CA10Z1__retentionPolicyDays__c": 0,
          "CA10Z1__virtualNetwork__r": {
            "Id": "v001",
            "CA10__disappearanceTime__c": null
          }
        },
        {
          "expectedResult": {
            "status": "INAPPLICABLE",
            "conditionIndex": "299",
            "conditionText": "isEmptyLookup('CA10Z1__virtualNetwork__r')",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-03T06:52:36Z" },
          "Id": "002",
          "CA10Z1__disappearanceTime__c": null,
          "CA10Z1__logStatus__c": "Enabled",
          "CA10Z1__networkSecurityGroup__c": "g001",
          "CA10Z1__networkSecurityGroupId__c": "/subscriptions/565c00f0-066e-43b6-9bee-9cf93fe2b312/resourcegroups/domaincontrollers-rg/providers/microsoft.network/networkSecurityGroups/g001",
          "CA10Z1__retentionPolicyStatus__c": "Disabled",
          "CA10Z1__retentionPolicyDays__c": 0,
          "CA10Z1__networkSecurityGroup__r": {
            "Id": "g001",
            "CA10__disappearanceTime__c": null
          },
          "CA10Z1__virtualNetwork__c": "",
          "CA10Z1__virtualNetworkId__c": "",
          "CA10Z1__virtualNetwork__r": {
            "Id": null,
            "CA10__disappearanceTime__c": null
          }
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "399",
            "conditionText": "extract('CA10Z1__retentionPolicyStatus__c') != 'Enabled'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-03T06:52:36Z" },
          "Id": "003",
          "CA10Z1__disappearanceTime__c": null,
          "CA10Z1__logStatus__c": "Enabled",
          "CA10Z1__virtualNetwork__c": "v002",
          "CA10Z1__virtualNetworkId__c": "/subscriptions/565c00f0-066e-43b6-9bee-9cf93fe2b312/resourcegroups/domaincontrollers-rg/providers/microsoft.network/virtualNetworks/v002",
          "CA10Z1__retentionPolicyStatus__c": "Disabled",
          "CA10Z1__retentionPolicyDays__c": 0,
          "CA10Z1__virtualNetwork__r": {
            "Id": "v002",
            "CA10__disappearanceTime__c": null
          }
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "500",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-03T06:52:36Z" },
          "Id": "004",
          "CA10Z1__disappearanceTime__c": null,
          "CA10Z1__logStatus__c": "Enabled",
          "CA10Z1__virtualNetwork__c": "v003",
          "CA10Z1__virtualNetworkId__c": "/subscriptions/603da06c-b6b0-4092-9d96-89617bcf6635/resourcegroups/sitecore-pp-agw/providers/microsoft.network/virtualNetworks/v003",
          "CA10Z1__retentionPolicyStatus__c": "Enabled",
          "CA10Z1__retentionPolicyDays__c": 30,
          "CA10Z1__virtualNetwork__r": {
            "Id": "v003",
            "CA10__disappearanceTime__c": null
          }
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "499",
            "conditionText": "extract('CA10Z1__retentionPolicyDays__c') == number(0.0) || extract('CA10Z1__retentionPolicyDays__c') >= number(90.0)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-03T06:52:36Z" },
          "Id": "005",
          "CA10Z1__disappearanceTime__c": null,
          "CA10Z1__logStatus__c": "Enabled",
          "CA10Z1__virtualNetwork__c": "v004",
          "CA10Z1__virtualNetworkId__c": "/subscriptions/603da06c-b6b0-4092-9d96-89617bcf6635/resourcegroups/sitecore-pp-agw/providers/microsoft.network/virtualNetworks/v004",
          "CA10Z1__retentionPolicyStatus__c": "Enabled",
          "CA10Z1__retentionPolicyDays__c": 0,
          "CA10Z1__virtualNetwork__r": {
            "Id": "v004",
            "CA10__disappearanceTime__c": null
          }
        },
          {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "499",
            "conditionText": "extract('CA10Z1__retentionPolicyDays__c') == number(0.0) || extract('CA10Z1__retentionPolicyDays__c') >= number(90.0)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-03T06:52:36Z" },
          "Id": "006",
          "CA10Z1__disappearanceTime__c": null,
          "CA10Z1__logStatus__c": "Enabled",
          "CA10Z1__virtualNetwork__c": "v005",
          "CA10Z1__virtualNetworkId__c": "/subscriptions/603da06c-b6b0-4092-9d96-89617bcf6635/resourcegroups/sitecore-pp-agw/providers/microsoft.network/virtualNetworks/v005",
          "CA10Z1__retentionPolicyStatus__c": "Enabled",
          "CA10Z1__retentionPolicyDays__c": 99,
          "CA10Z1__virtualNetwork__r": {
            "Id": "v005",
            "CA10__disappearanceTime__c": null
          }
        }
      ]
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" : "INAPPLICABLE",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10Z1__logStatus__c') != 'Enabled'",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "299",
      "conditionText" : "isEmptyLookup('CA10Z1__virtualNetwork__r')",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('CA10Z1__retentionPolicyStatus__c') != 'Enabled'",
      "runtimeError" : null
    }
  }, {
    "Id" : "004",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "500",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "005",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "499",
      "conditionText" : "extract('CA10Z1__retentionPolicyDays__c') == number(0.0) || extract('CA10Z1__retentionPolicyDays__c') >= number(90.0)",
      "runtimeError" : null
    }
  }, {
    "Id" : "006",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "499",
      "conditionText" : "extract('CA10Z1__retentionPolicyDays__c') == number(0.0) || extract('CA10Z1__retentionPolicyDays__c') >= number(90.0)",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10Z1__CaAzureNetworkWatcherFlowLog__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10Z1__disappearanceTime__c TIMESTAMP,
      CA10Z1__logStatus__c STRING,
      CA10Z1__virtualNetwork__c STRING,
      CA10Z1__virtualNetworkId__c STRING,
      CA10Z1__retentionPolicyStatus__c STRING,
      CA10Z1__retentionPolicyDays__c FLOAT64,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "001",
    "CA10Z1__logStatus__c" : "Disabled",
    "CA10Z1__virtualNetwork__c" : "v001",
    "CA10Z1__virtualNetworkId__c" : "/subscriptions/565c00f0-066e-43b6-9bee-9cf93fe2b312/resourcegroups/domaincontrollers-rg/providers/microsoft.network/virtualNetworks/v001",
    "CA10Z1__retentionPolicyStatus__c" : "Disabled",
    "CA10Z1__retentionPolicyDays__c" : 0
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "002",
    "CA10Z1__logStatus__c" : "Enabled",
    "CA10Z1__virtualNetwork__c" : "",
    "CA10Z1__virtualNetworkId__c" : "",
    "CA10Z1__retentionPolicyStatus__c" : "Disabled",
    "CA10Z1__retentionPolicyDays__c" : 0
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "003",
    "CA10Z1__logStatus__c" : "Enabled",
    "CA10Z1__virtualNetwork__c" : "v002",
    "CA10Z1__virtualNetworkId__c" : "/subscriptions/565c00f0-066e-43b6-9bee-9cf93fe2b312/resourcegroups/domaincontrollers-rg/providers/microsoft.network/virtualNetworks/v002",
    "CA10Z1__retentionPolicyStatus__c" : "Disabled",
    "CA10Z1__retentionPolicyDays__c" : 0
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "004",
    "CA10Z1__logStatus__c" : "Enabled",
    "CA10Z1__virtualNetwork__c" : "v003",
    "CA10Z1__virtualNetworkId__c" : "/subscriptions/603da06c-b6b0-4092-9d96-89617bcf6635/resourcegroups/sitecore-pp-agw/providers/microsoft.network/virtualNetworks/v003",
    "CA10Z1__retentionPolicyStatus__c" : "Enabled",
    "CA10Z1__retentionPolicyDays__c" : 30
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "005",
    "CA10Z1__logStatus__c" : "Enabled",
    "CA10Z1__virtualNetwork__c" : "v004",
    "CA10Z1__virtualNetworkId__c" : "/subscriptions/603da06c-b6b0-4092-9d96-89617bcf6635/resourcegroups/sitecore-pp-agw/providers/microsoft.network/virtualNetworks/v004",
    "CA10Z1__retentionPolicyStatus__c" : "Enabled",
    "CA10Z1__retentionPolicyDays__c" : 0
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "006",
    "CA10Z1__logStatus__c" : "Enabled",
    "CA10Z1__virtualNetwork__c" : "v005",
    "CA10Z1__virtualNetworkId__c" : "/subscriptions/603da06c-b6b0-4092-9d96-89617bcf6635/resourcegroups/sitecore-pp-agw/providers/microsoft.network/virtualNetworks/v005",
    "CA10Z1__retentionPolicyStatus__c" : "Enabled",
    "CA10Z1__retentionPolicyDays__c" : 99
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureVirtualNetwork__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "v001"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : null
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "v002"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "v003"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "v004"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "v005"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10Z1__CaAzureNetworkWatcherFlowLog__c(
      obj STRUCT<
          Id STRING,
          CA10Z1__disappearanceTime__c TIMESTAMP,
          CA10Z1__logStatus__c STRING,
          CA10Z1__virtualNetwork__c STRING,
          CA10Z1__virtualNetworkId__c STRING,
          CA10Z1__retentionPolicyStatus__c STRING,
          CA10Z1__retentionPolicyDays__c FLOAT64,
          CA10Z1__virtualNetwork__r STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP
          >
      >,
      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 Azure [CA10Z1__disappearanceTime__c]: ' + obj.CA10Z1__disappearanceTime__c);
      if (obj.CA10Z1__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10Z1__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.CA10Z1__logStatus__c; } return this.out; };
      references1.push('Log Status [obj.CA10Z1__logStatus__c]: ' + obj.CA10Z1__logStatus__c);
      if (TextLib.notEqual(extract3.call(extract3), 'Enabled')) {
          return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10Z1__logStatus__c') != 'Enabled'", currentStateMessage: "Flow Log is disabled.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      if (TextLib.isEmpty(obj.CA10Z1__virtualNetworkId__c) || TextLib.isEmpty(obj.CA10Z1__virtualNetwork__c) || obj.CA10Z1__virtualNetwork__r.CA10__disappearanceTime__c != null) {
          return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "isEmptyLookup('CA10Z1__virtualNetwork__r')", currentStateMessage: "Only for Virtual network Flow Logs.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[3], conditionIndex:[300..399]
      function extract6() { if (!this.out) { this.out = obj.CA10Z1__retentionPolicyStatus__c; } return this.out; };
      references1.push('Retention Policy: Status [obj.CA10Z1__retentionPolicyStatus__c]: ' + obj.CA10Z1__retentionPolicyStatus__c);
      if (TextLib.notEqual(extract6.call(extract6), 'Enabled')) {
          return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('CA10Z1__retentionPolicyStatus__c') != 'Enabled'", currentStateMessage: "Virtual network Flow Logs retention policy is disabled.", currentStateReferences: references1.join('\n'), remediation: "Consider enabling retention policy for Virtual network Flow Logs.", runtimeError: null};
      }
      // condition[4], conditionIndex:[400..499]
      function extract9() { if (!this.out) { this.out = obj.CA10Z1__retentionPolicyDays__c; } return this.out; };
      references1.push('Retention Policy: Days [obj.CA10Z1__retentionPolicyDays__c]: ' + obj.CA10Z1__retentionPolicyDays__c);
      if (extract9.call(extract9) == 0.0 || (extract9.call(extract9) != null && 90.0 != null && extract9.call(extract9) >= 90.0)) {
          return {status: 'COMPLIANT', conditionIndex: 499, conditionText: "extract('CA10Z1__retentionPolicyDays__c') == number(0.0) || extract('CA10Z1__retentionPolicyDays__c') >= number(90.0)", currentStateMessage: "Virtual network Flow Logs are enabled and the retention period is set to 'greater than or equal to 90 days'.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 500, conditionText: "otherwise", currentStateMessage: "Virtual network Flow Logs retention period is less than 90 days.", currentStateReferences: references1.join('\n'), remediation: "Consider setting the retention period to 'greater then or equal to 90 days'.", 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.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c,
          sObject.CA10Z1__logStatus__c AS CA10Z1__logStatus__c,
          sObject.CA10Z1__virtualNetwork__c AS CA10Z1__virtualNetwork__c,
          sObject.CA10Z1__virtualNetworkId__c AS CA10Z1__virtualNetworkId__c,
          sObject.CA10Z1__retentionPolicyStatus__c AS CA10Z1__retentionPolicyStatus__c,
          sObject.CA10Z1__retentionPolicyDays__c AS CA10Z1__retentionPolicyDays__c,
          STRUCT (
              `CA10Z1__virtualNetwork__r`.Id AS Id,
              `CA10Z1__virtualNetwork__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c
          ) AS CA10Z1__virtualNetwork__r,
          process_CA10Z1__CaAzureNetworkWatcherFlowLog__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c,
                  sObject.CA10Z1__logStatus__c AS CA10Z1__logStatus__c,
                  sObject.CA10Z1__virtualNetwork__c AS CA10Z1__virtualNetwork__c,
                  sObject.CA10Z1__virtualNetworkId__c AS CA10Z1__virtualNetworkId__c,
                  sObject.CA10Z1__retentionPolicyStatus__c AS CA10Z1__retentionPolicyStatus__c,
                  sObject.CA10Z1__retentionPolicyDays__c AS CA10Z1__retentionPolicyDays__c,
                  STRUCT (
                      `CA10Z1__virtualNetwork__r`.Id AS Id,
                      `CA10Z1__virtualNetwork__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c
                  ) AS CA10Z1__virtualNetwork__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10Z1__CaAzureNetworkWatcherFlowLog__c()) AS sObject
      LEFT JOIN UNNEST(mock_CA10__CaAzureVirtualNetwork__c()) AS `CA10Z1__virtualNetwork__r`
          ON sObject.CA10Z1__virtualNetwork__c = `CA10Z1__virtualNetwork__r`.Id
  ) sObject ON sObject.Id = expectedResult.Id;
