---
policy: /ce/ca/aws/s3/bucket-policy-deny-http-requests
logic: /ce/ca/aws/s3/bucket-policy-deny-http-requests/prod.logic.yaml
executionTime: 2025-04-24T23:45:11.066914511Z
rows:
  - id: test1
    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: test2
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__policyDocument__c').isEmpty()
      actual: extract('CA10__policyDocument__c').isEmpty()
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\\
        '])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\\
        '1.2\\'])') == number(0.0)"
      actual: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\\
        '])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\\
        '1.2\\'])') == number(0.0)"
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\\
        '])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\\
        '1.2\\'])') == number(0.0)"
      actual: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\\
        '])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\\
        '1.2\\'])') == number(0.0)"
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\\
        '])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\\
        '1.2\\'])') == number(0.0)"
      actual: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\\
        '])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\\
        '1.2\\'])') == number(0.0)"
    runtimeError: {}
  - id: test6
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\\
        '])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\\
        '1.2\\'])') == number(0.0)"
      actual: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\\
        '])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\\
        '1.2\\'])') == number(0.0)"
    runtimeError: {}
  - id: test7
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\\
        '])') > number(0.0) || extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\\
        '1.2\\'])') > number(0.0)"
      actual: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\\
        '])') > number(0.0) || extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\\
        '1.2\\'])') > number(0.0)"
    runtimeError: {}
  - id: test8
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\\
        '])') > number(0.0) || extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\\
        '1.2\\'])') > number(0.0)"
      actual: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\\
        '])') > number(0.0) || extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[?\
        \ Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\\
        '1.2\\'])') > number(0.0)"
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/s3/bucket-policy-deny-http-requests/policy.yaml
    md5Hash: 2BD1484D9DD5B93C00AAB474F49042C7
    content: |
      ---
      names:
        full: AWS S3 Bucket Policy is not set to deny HTTP requests
        contextual: Bucket Policy is not set to deny HTTP requests
      description: "At the Amazon S3 bucket level, you can configure permissions through\
        \ a bucket policy making the objects accessible only through HTTPS."
      type: COMPLIANCE_POLICY
      categories:
        - SECURITY
      frameworkMappings:
        - "/frameworks/cis-aws-v5.0.0/02/01/01"
        - "/frameworks/cloudaware/resource-security/data-encryption"
        - "/frameworks/aws-fsbp-v1.0.0/s3/05"
      similarPolicies:
        internal:
          - dec-x-d5fbfc40
        cloudConformity:
          - url: https://www.trendmicro.com/cloudoneconformity-staging/knowledge-base/aws/S3/secure-transport.html
            name: Secure Transport
  - path: /ce/ca/aws/s3/bucket-policy-deny-http-requests/prod.logic.yaml
    md5Hash: 1763984FE618A6CD9AE7A8A107CC8A7C
    content: "---\ninputType: \"CA10__CaAwsBucket__c\"\ntestData:\n - file: test-data.json\n\
      importExtracts:\n - file: /types/CA10__CaAwsBucket__c/object.extracts.yaml\n\
      conditions:\n  - status: \"INCOMPLIANT\"\n    currentStateMessage: \"The bucket\
      \ policy hasn't been configured for this bucket and by default it's allowing\
      \ both HTTP and HTTPS requests.\"\n    remediationMessage: \"Consider configuring\
      \ the bucket policy that will deny HTTP requests.\"\n    check:\n      IS_EMPTY:\n\
      \        arg:\n          EXTRACT: \"CA10__policyDocument__c\"\n  - status: \"\
      INCOMPLIANT\"\n    currentStateMessage: \"The bucket policy hasn't been configured\
      \ to deny HTTP requests.\"\n    remediationMessage: \"Consider configuring the\
      \ bucket policy that will deny HTTP requests.\"\n    check:\n      AND:\n  \
      \      args:\n          - IS_EQUAL:\n              left:\n                JSON_QUERY_NUMBER:\n\
      \                  arg:\n                    EXTRACT: \"caJsonFrom__policyDocument__c\"\
      \n                  expression: \"length(Statement[? Effect == 'Deny' && Condition.Bool.\\\
      \"aws:SecureTransport\\\" == 'false'])\"\n                  undeterminedIf:\
      \ \n                    evaluationError: \"The JSON query has failed.\"\n  \
      \                  resultTypeMismatch: \"The JSON query did not return a number\
      \ type.\"\n              right:\n                NUMBER: 0.0\n          - IS_EQUAL:\n\
      \              left:\n                JSON_QUERY_NUMBER:\n                 \
      \ arg:\n                    EXTRACT: \"caJsonFrom__policyDocument__c\"\n   \
      \               expression: \"length(Statement[? Effect == 'Deny' && Condition.NumericLessThan.\\\
      \"s3:TlsVersion\\\" == '1.2'])\"\n                  undeterminedIf: \n     \
      \               evaluationError: \"The JSON query has failed.\"\n          \
      \          resultTypeMismatch: \"The JSON query did not return a number type.\"\
      \n              right:\n                NUMBER: 0.0\n  - status: \"COMPLIANT\"\
      \n    currentStateMessage: \"The bucket policy has been configured to deny HTTP\
      \ requests.\"\n    check:\n      OR: \n        args:\n          - GREATER_THAN:\n\
      \              left:\n                JSON_QUERY_NUMBER:\n                 \
      \ arg:\n                    EXTRACT: \"caJsonFrom__policyDocument__c\"\n   \
      \               expression: \"length(Statement[? Effect == 'Deny' && Condition.Bool.\\\
      \"aws:SecureTransport\\\" == 'false'])\"\n                  undeterminedIf:\
      \ \n                    evaluationError: \"The JSON query has failed.\"\n  \
      \                  resultTypeMismatch: \"The JSON query did not return a number\
      \ type.\"\n              right:\n                NUMBER: 0.0\n          - GREATER_THAN:\n\
      \              left:\n                JSON_QUERY_NUMBER:\n                 \
      \ arg:\n                    EXTRACT: \"caJsonFrom__policyDocument__c\"\n   \
      \               expression: \"length(Statement[? Effect == 'Deny' && Condition.NumericLessThan.\\\
      \"s3:TlsVersion\\\" == '1.2'])\"\n                  undeterminedIf: \n     \
      \               evaluationError: \"The JSON query has failed.\"\n          \
      \          resultTypeMismatch: \"The JSON query did not return a number type.\"\
      \n              right:\n                NUMBER: 0.0\notherwise:\n  status: \"\
      UNDETERMINED\"\n  currentStateMessage: \"Unexpected values in the field.\"\n"
  - path: /types/CA10__CaAwsBucket__c/object.extracts.yaml
    md5Hash: D7F01723B629E0F1265F06B9CE2EDE1F
    content: "---\nextracts:\n# Values: yes, no. Not Nullable.\n  - name: \"CA10__objectLockEnabled__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__objectLockEnabled__c\"\n\
      \        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__objectLockEnabled__c\"\n            currentStateMessage: \"Unable to determine\
      \ Object Lock status. Possible permission issue with s3:GetObjectLockConfiguration\"\
      \n          isEmpty: \"Object Lock status is not populated yet\"\n# Nullable.\n\
      \  - name: \"CA10__lifecycleRulesJson__c\"\n    value: \n      FIELD:\n    \
      \    path: \"CA10__lifecycleRulesJson__c\"\n        returnType: BYTES\n    \
      \    # undeterminedIf:\n        #   noAccessDelegate:\n        #     path: \"\
      CA10__lifecycleRulesJson__c\"\n        #     currentStateMessage: \"Unable to\
      \ determine Lifecycle Configuration. Possible permission issue with s3:GetLifecycleConfiguration\"\
      \n# Values: enabled, suspended, off. Not Nullable.\n  - name: \"CA10__versioningStatus__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__versioningStatus__c\"\n \
      \       undeterminedIf:\n          noAccessDelegate:\n            path: \"CA10__versioningStatus__c\"\
      \n            currentStateMessage: \"Unable to determine versioning status.\
      \ Possible permission issue with s3:GetBucketVersioning\"\n          isEmpty:\
      \ \"Status is not populated yet\"\n# Checkbox.\n  - name: \"CA10__versioningMfaDeleteEnabled__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__versioningMfaDeleteEnabled__c\"\
      \n        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__versioningStatus__c\"\n            currentStateMessage: \"Unable to determine\
      \ versioning status. Possible permission issue with s3:GetBucketVersioning\"\
      \n# The field can be empty if server access logging is not enabled\n  - name:\
      \ \"CA10__loggingDestinationBucketName__c\"\n    value: \n      FIELD:\n   \
      \     path: \"CA10__loggingDestinationBucketName__c\"\n        # undeterminedIf:\n\
      \        #   noAccessDelegate:\n        #     path: \"CA10__loggingDestinationBucketName__c\"\
      \n        #     currentStateMessage: \"Unable to determine if server access\
      \ logging is enabled. Possible permission issue with s3:GetBucketLogging\"\n\
      # Cloudaware derives this field from CA10__loggingDestinationBucketName__c\n\
      \  - name: \"CA10__loggingDestinationBucketArn__c\"\n    value: \n      FIELD:\n\
      \        path: \"CA10__loggingDestinationBucketArn__c\"\n        undeterminedIf:\n\
      \          noAccessDelegate:\n            path: \"CA10__loggingDestinationBucketName__c\"\
      \n            currentStateMessage: \"Unable to determine if server access logging\
      \ is enabled. Possible permission issue with s3:GetBucketLogging\"\n# This is\
      \ a look up on CA10__CaAwsBucket__c derived from CA10__loggingDestinationBucketName__c\n\
      \  - name: \"CA10__loggingDestinationBucket__c\"\n    value: \n      FIELD:\n\
      \        path: \"CA10__loggingDestinationBucket__c\"\n        undeterminedIf:\n\
      \          noAccessDelegate:\n            path: \"CA10__loggingDestinationBucketName__c\"\
      \n            currentStateMessage: \"Unable to determine if server access logging\
      \ is enabled. Possible permission issue with s3:GetBucketLogging\"\n  - name:\
      \ \"CA10__arn__c\"\n    value: \n      FIELD:\n        path: \"CA10__arn__c\"\
      \n        undeterminedIf:\n          isEmpty: \"Bucket ARN cannot be empty.\
      \ Potential data corruption\"\n  - name: \"caJsonFrom__lifecycleRulesJson__c\"\
      \n    value: \n      JSON_FROM:\n        arg: \n          EXTRACT: \"CA10__lifecycleRulesJson__c\"\
      \n        undeterminedIf:\n          isInvalid: \"S3 Bucket Lifecycle Rules\
      \ JSON is invalid.\"\n# Returns BOOLEAN true if number of enabled lifecycle\
      \ rules more than 0 otherwise returns false\n  - name: \"caJsonQueryBoolean__lifecycleRulesJson_status_enabled__c\"\
      \n    value: \n      JSON_QUERY_BOOLEAN:\n        arg: \n          EXTRACT:\
      \ \"caJsonFrom__lifecycleRulesJson__c\"\n        expression: \"length([?status=='Enabled'])\
      \ > `0`\"\n        undeterminedIf: \n          evaluationError: \"The JSON query\
      \ has failed.\"\n          resultTypeMismatch: \"The JSON query did not return\
      \ a boolean.\"\n  - name: \"CA10__blockPublicAcls__c\"\n    value: \n      FIELD:\n\
      \        path: \"CA10__blockPublicAcls__c\"\n        undeterminedIf:\n     \
      \     noAccessDelegate:\n            path: \"CA10__blockPublicAcls__c\"\n  \
      \          currentStateMessage: \"Unable to determine the bucket policy. Possible\
      \ permission issue with s3:GetBucketPublicAccessBlock\"\n  - name: \"CA10__blockPublicPolicy__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__blockPublicPolicy__c\"\n\
      \        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__blockPublicPolicy__c\"\n            currentStateMessage: \"Unable to determine\
      \ the bucket policy. Possible permission issue with s3:GetBucketPublicAccessBlock\"\
      \n  - name: \"CA10__ignorePublicAcls__c\"\n    value: \n      FIELD:\n     \
      \   path: \"CA10__ignorePublicAcls__c\"\n        undeterminedIf:\n         \
      \ noAccessDelegate:\n            path: \"CA10__ignorePublicAcls__c\"\n     \
      \       currentStateMessage: \"Unable to determine the bucket policy. Possible\
      \ permission issue with s3:GetBucketPublicAccessBlock\"\n  - name: \"CA10__restrictPublicBuckets__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__restrictPublicBuckets__c\"\
      \n        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__restrictPublicBuckets__c\"\n            currentStateMessage: \"Unable\
      \ to determine the bucket policy. Possible permission issue with s3:GetBucketPublicAccessBlock\"\
      \n# Nullable.\n  - name: \"CA10__policyDocument__c\"\n    value: \n      FIELD:\n\
      \        path: \"CA10__policyDocument__c\"\n        returnType: BYTES\n    \
      \    # undeterminedIf:\n        #   noAccessDelegate:\n        #     path: \"\
      CA10__policyDocument__c\"\n        #     currentStateMessage: \"Unable to determine\
      \ the bucket policy. Possible permission issue with s3:GetBucketPolicy\"\n \
      \ - name: \"caJsonFrom__policyDocument__c\"\n    value: \n      JSON_FROM:\n\
      \        arg: \n          EXTRACT: \"CA10__policyDocument__c\"\n        undeterminedIf:\n\
      \          isInvalid: \"S3 Bucket Policy Document JSON is invalid.\"\n"
  - path: /ce/ca/aws/s3/bucket-policy-deny-http-requests/test-data.json
    md5Hash: 31AD5B8DD97468C94B6DEB458D049CBD
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-11T20:42:28Z"
              },
              "Id": "test1",
              "CA10__disappearanceTime__c": "2024-07-09T13:42:15Z",
              "CA10__policyDocument__c": ""
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "extract('CA10__policyDocument__c').isEmpty()",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-11T20:42:28Z"
              },
              "Id": "test2",
              "CA10__disappearanceTime__c": null,
              "CA10__policyDocument__c": ""
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])') == number(0.0)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-11T20:42:28Z"
              },
              "Id": "test3",
              "CA10__disappearanceTime__c": null,
              "CA10__policyDocument__c": "{\"Version\":\"2020-01-01\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"Principal\",\"Action\":\"Action\",\"Resource\":\"Resource\"}]}"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])') == number(0.0)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-11T20:42:28Z"
              },
              "Id": "test4",
              "CA10__disappearanceTime__c": null,
              "CA10__policyDocument__c": "{\"Version\":\"2020-01-01\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"Principal\",\"Action\":\"Action\",\"Resource\":\"Resource\",\"Condition\":{\"Bool\":{\"Condition1\":\"false\"}}}]}"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])') == number(0.0)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-11T20:42:28Z"
              },
              "Id": "test5",
              "CA10__disappearanceTime__c": null,
              "CA10__policyDocument__c": "{\"Version\":\"2020-01-01\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"Principal\",\"Action\":\"Action\",\"Resource\":\"Resource\",\"Condition\":{\"Condition1\":\"false\"}}]}"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])') == number(0.0)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-11T20:42:28Z"
              },
              "Id": "test6",
              "CA10__disappearanceTime__c": null,
              "CA10__policyDocument__c": "{\"Version\":\"2020-01-01\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"Principal\",\"Action\":\"Action\",\"Resource\":\"Resource\",\"Condition\":\"false\"}]}"
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "399",
                  "conditionText": "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])') > number(0.0) || extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])') > number(0.0)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-11T20:42:28Z"
              },
              "Id": "test7",
              "CA10__disappearanceTime__c": null,
              "CA10__policyDocument__c": "{\"Version\": \"2012-10-17\",\"Id\":\"ExamplePolicy\",\"Statement\":[{\"Sid\":\"AllowSSLRequestsOnly\",\"Effect\":\"Deny\",\"Principal\":\"*\",\"Action\":\"s3:*\",\"Resource\":[\"arn:aws:s3:::boost-dev-screening-video-selfie\",\"arn:aws:s3:::boost-dev-screening-video-selfie/*\"],\"Condition\":{\"Bool\":{\"aws:SecureTransport\":\"false\"}}}]}"
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "399",
                  "conditionText": "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])') > number(0.0) || extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])') > number(0.0)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-11T20:42:28Z"
              },
              "Id": "test8",
              "CA10__disappearanceTime__c": null,
              "CA10__policyDocument__c": "{\"Version\":\"2020-01-01\",\"Statement\":[{\"Effect\":\"Deny\",\"Principal\":\"*\",\"Action\":\"s3:*\",\"Resource\":\"Resource\",\"Condition\":{\"NumericLessThan\":{\"s3:TlsVersion\":\"1.2\"}}}]}"
          }
      ]
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" : "test1",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__policyDocument__c').isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])') == number(0.0)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])') == number(0.0)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])') == number(0.0)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test6",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])') == number(0.0)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test7",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])') > number(0.0) || extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])') > number(0.0)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test8",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])') > number(0.0) || extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])') > number(0.0)",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsBucket__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__policyDocument__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-07-11T20:42:28Z")
    },
    "Id" : "test1",
    "CA10__disappearanceTime__c" : new Date("2024-07-09T13:42:15Z"),
    "CA10__policyDocument__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-11T20:42:28Z")
    },
    "Id" : "test2",
    "CA10__policyDocument__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-11T20:42:28Z")
    },
    "Id" : "test3",
    "CA10__policyDocument__c" : "{\"Version\":\"2020-01-01\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"Principal\",\"Action\":\"Action\",\"Resource\":\"Resource\"}]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-11T20:42:28Z")
    },
    "Id" : "test4",
    "CA10__policyDocument__c" : "{\"Version\":\"2020-01-01\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"Principal\",\"Action\":\"Action\",\"Resource\":\"Resource\",\"Condition\":{\"Bool\":{\"Condition1\":\"false\"}}}]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-11T20:42:28Z")
    },
    "Id" : "test5",
    "CA10__policyDocument__c" : "{\"Version\":\"2020-01-01\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"Principal\",\"Action\":\"Action\",\"Resource\":\"Resource\",\"Condition\":{\"Condition1\":\"false\"}}]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-11T20:42:28Z")
    },
    "Id" : "test6",
    "CA10__policyDocument__c" : "{\"Version\":\"2020-01-01\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"Principal\",\"Action\":\"Action\",\"Resource\":\"Resource\",\"Condition\":\"false\"}]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-11T20:42:28Z")
    },
    "Id" : "test7",
    "CA10__policyDocument__c" : "{\"Version\": \"2012-10-17\",\"Id\":\"ExamplePolicy\",\"Statement\":[{\"Sid\":\"AllowSSLRequestsOnly\",\"Effect\":\"Deny\",\"Principal\":\"*\",\"Action\":\"s3:*\",\"Resource\":[\"arn:aws:s3:::boost-dev-screening-video-selfie\",\"arn:aws:s3:::boost-dev-screening-video-selfie/*\"],\"Condition\":{\"Bool\":{\"aws:SecureTransport\":\"false\"}}}]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-11T20:42:28Z")
    },
    "Id" : "test8",
    "CA10__policyDocument__c" : "{\"Version\":\"2020-01-01\",\"Statement\":[{\"Effect\":\"Deny\",\"Principal\":\"*\",\"Action\":\"s3:*\",\"Resource\":\"Resource\",\"Condition\":{\"NumericLessThan\":{\"s3:TlsVersion\":\"1.2\"}}}]}"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsBucket__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__policyDocument__c STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  OPTIONS (library=['gs://compliance-platform-public/jmespath.min.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 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__policyDocument__c; } return this.out; };
      references1.push('Policy Document JSON [obj.CA10__policyDocument__c]: ' + obj.CA10__policyDocument__c);
      if (extract3.call(extract3) == null || extract3.call(extract3) == '') {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__policyDocument__c').isEmpty()", currentStateMessage: "The bucket policy hasn't been configured for this bucket and by default it's allowing both HTTP and HTTPS requests.", currentStateReferences: references1.join('\n'), remediation: "Consider configuring the bucket policy that will deny HTTP requests.", runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function jsonQueryChecked6() {
          var input = extract8.call(extract8);
          var out;
          try {
              out = jmespath.search(input, 'length(Statement[? Effect == \'Deny\' && Condition.Bool."aws:SecureTransport" == \'false\'])');
          if (out != null && typeof out != 'number') {
              throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return a number type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonChecked9() {
          var input = extract11.call(extract11);
          input = TextLib.isEmpty(input) ? null : input;
          var out;
          try {
              out = JSON.parse(input);
          } catch (e) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "extract('CA10__policyDocument__c').asJson().isInvalid()", currentStateMessage: "S3 Bucket Policy Document JSON is invalid.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function extract11() { if (!this.out) { this.out = obj.CA10__policyDocument__c; } return this.out; };
      function extract8() { if (!this.out) { this.out = jsonChecked9(); } return this.out; };
      function jsonQueryChecked13() {
          var input = extract8.call(extract8);
          var out;
          try {
              out = jmespath.search(input, 'length(Statement[? Effect == \'Deny\' && Condition.NumericLessThan."s3:TlsVersion" == \'1.2\'])');
          if (out != null && typeof out != 'number') {
              throw new Error("UNDETERMINED condition:204", {cause: {status: 'UNDETERMINED', conditionIndex: 204, conditionText: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return a number type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:205", {cause: {status: 'UNDETERMINED', conditionIndex: 205, conditionText: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      try {
          if (jsonQueryChecked6() == 0.0 && jsonQueryChecked13() == 0.0) {
              return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])') == number(0.0) && extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])') == number(0.0)", currentStateMessage: "The bucket policy hasn't been configured to deny HTTP requests.", currentStateReferences: references1.join('\n'), remediation: "Consider configuring the bucket policy that will deny HTTP requests.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[3], conditionIndex:[300..399]
      function comparison15() {
          var comparisonLeft23 = jsonQueryChecked16();
          return comparisonLeft23 != null && 0.0 != null && comparisonLeft23 > 0.0;
      }
      function jsonQueryChecked16() {
          var input = extract18.call(extract18);
          var out;
          try {
              out = jmespath.search(input, 'length(Statement[? Effect == \'Deny\' && Condition.Bool."aws:SecureTransport" == \'false\'])');
          if (out != null && typeof out != 'number') {
              throw new Error("UNDETERMINED condition:302", {cause: {status: 'UNDETERMINED', conditionIndex: 302, conditionText: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return a number type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:303", {cause: {status: 'UNDETERMINED', conditionIndex: 303, conditionText: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonChecked19() {
          var input = extract21.call(extract21);
          input = TextLib.isEmpty(input) ? null : input;
          var out;
          try {
              out = JSON.parse(input);
          } catch (e) {
              throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "extract('CA10__policyDocument__c').asJson().isInvalid()", currentStateMessage: "S3 Bucket Policy Document JSON is invalid.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function extract21() { if (!this.out) { this.out = obj.CA10__policyDocument__c; } return this.out; };
      function extract18() { if (!this.out) { this.out = jsonChecked19(); } return this.out; };
      function comparison24() {
          var comparisonLeft27 = jsonQueryChecked25();
          return comparisonLeft27 != null && 0.0 != null && comparisonLeft27 > 0.0;
      }
      function jsonQueryChecked25() {
          var input = extract18.call(extract18);
          var out;
          try {
              out = jmespath.search(input, 'length(Statement[? Effect == \'Deny\' && Condition.NumericLessThan."s3:TlsVersion" == \'1.2\'])');
          if (out != null && typeof out != 'number') {
              throw new Error("UNDETERMINED condition:304", {cause: {status: 'UNDETERMINED', conditionIndex: 304, conditionText: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return a number type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:305", {cause: {status: 'UNDETERMINED', conditionIndex: 305, conditionText: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      try {
          if (comparison15() || comparison24()) {
              return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.Bool.\"aws:SecureTransport\" == \\'false\\'])') > number(0.0) || extract('caJsonFrom__policyDocument__c').jsonQueryText('length(Statement[? Effect == \\'Deny\\' && Condition.NumericLessThan.\"s3:TlsVersion\" == \\'1.2\\'])') > number(0.0)", currentStateMessage: "The bucket policy has been configured to deny HTTP requests.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'UNDETERMINED', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "Unexpected values in the field.", 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.Id AS Id,
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__policyDocument__c AS CA10__policyDocument__c,
          process_CA10__CaAwsBucket__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__policyDocument__c AS CA10__policyDocument__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsBucket__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
