---
policy: /ce/ca/aws/iam/policy-allows-full-administrative-privileges
logic: /ce/ca/aws/iam/policy-allows-full-administrative-privileges/prod.logic.yaml
executionTime: 2025-04-24T23:44:55.763466395Z
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: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__attachable__c') != true || extract('CA10__attachmentCount__c')
        == number(0.0)
      actual: extract('CA10__attachable__c') != true || extract('CA10__attachmentCount__c')
        == number(0.0)
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)')\
        \ == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[?\
        \ ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action)\
        \ == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\\
        ' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource\
        \ == \\'*\\')) && (Effect == \\'Allow\\')])') > number(0.0)"
      actual: "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)')\
        \ == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[?\
        \ ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action)\
        \ == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\\
        ' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource\
        \ == \\'*\\')) && (Effect == \\'Allow\\')])') > 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('type(Statement)')\
        \ == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[?\
        \ ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action)\
        \ == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\\
        ' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource\
        \ == \\'*\\')) && (Effect == \\'Allow\\')])') > number(0.0)"
      actual: "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)')\
        \ == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[?\
        \ ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action)\
        \ == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\\
        ' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource\
        \ == \\'*\\')) && (Effect == \\'Allow\\')])') > 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('type(Statement)')\
        \ == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[?\
        \ ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action)\
        \ == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\\
        ' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource\
        \ == \\'*\\')) && (Effect == \\'Allow\\')])') > number(0.0)"
      actual: "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)')\
        \ == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[?\
        \ ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action)\
        \ == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\\
        ' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource\
        \ == \\'*\\')) && (Effect == \\'Allow\\')])') > 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('type(Statement)')\
        \ == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[?\
        \ ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action)\
        \ == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\\
        ' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource\
        \ == \\'*\\')) && (Effect == \\'Allow\\')])') > number(0.0)"
      actual: "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)')\
        \ == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[?\
        \ ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action)\
        \ == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\\
        ' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource\
        \ == \\'*\\')) && (Effect == \\'Allow\\')])') > 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('type(Statement)')
        != 'object'
      actual: extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)')
        != 'object'
    runtimeError: {}
  - id: test8
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: extract('caJsonFrom_policyDocument__c').jsonQueryText('Statement.Effect')
        != 'Allow'
      actual: extract('caJsonFrom_policyDocument__c').jsonQueryText('Statement.Effect')
        != 'Allow'
    runtimeError: {}
  - id: test9
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 599
      actual: 599
    conditionText:
      expected: "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action)\
        \ == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action)\
        \ == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource)\
        \ == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource)\
        \ == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true"
      actual: "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action)\
        \ == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action)\
        \ == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource)\
        \ == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource)\
        \ == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true"
    runtimeError: {}
  - id: test10
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 599
      actual: 599
    conditionText:
      expected: "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action)\
        \ == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action)\
        \ == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource)\
        \ == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource)\
        \ == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true"
      actual: "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action)\
        \ == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action)\
        \ == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource)\
        \ == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource)\
        \ == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true"
    runtimeError: {}
  - id: test11
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 599
      actual: 599
    conditionText:
      expected: "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action)\
        \ == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action)\
        \ == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource)\
        \ == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource)\
        \ == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true"
      actual: "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action)\
        \ == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action)\
        \ == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource)\
        \ == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource)\
        \ == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true"
    runtimeError: {}
  - id: test12
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 599
      actual: 599
    conditionText:
      expected: "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action)\
        \ == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action)\
        \ == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource)\
        \ == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource)\
        \ == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true"
      actual: "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action)\
        \ == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action)\
        \ == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource)\
        \ == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource)\
        \ == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true"
    runtimeError: {}
  - id: test13
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 600
      actual: 600
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/iam/policy-allows-full-administrative-privileges/policy.yaml
    md5Hash: A06E702392DC5C7E8396FA3FAE00CED4
    content: |
      ---
      names:
        full: AWS IAM Policy allows full administrative privileges
        contextual: Policy allows full administrative privileges
      description: "IAM policies are the means by which privileges are granted to users,\
        \ groups, or roles. It is recommended and considered a standard security advice\
        \ to grant least privilege -that is, granting only the permissions required to perform\
        \ a task. Determine what users need to do and then craft policies for them that\
        \ let the users perform only those tasks, instead of allowing full administrative\
        \ privileges."
      type: COMPLIANCE_POLICY
      categories:
        - SECURITY
      frameworkMappings:
        - "/frameworks/cis-aws-v5.0.0/01/15"
        - "/frameworks/cloudaware/identity-and-access-governance/general-access-controls"
        - "/frameworks/aws-fsbp-v1.0.0/iam/01"
      similarPolicies:
        internal:
          - dec-x-157aa4b9
        cloudConformity:
          - url: https://trendmicro.com/cloudoneconformity-staging/knowledge-base/aws/IAM/policies-with-full-administrative-privileges.html
            name: IAM Policies With Full Administrative Privileges
  - path: /ce/ca/aws/iam/policy-allows-full-administrative-privileges/prod.logic.yaml
    md5Hash: A3002C8345CC95D4555F450A049155BD
    content: "---\ninputType: \"CA10__CaAwsIamPolicy__c\"\ntestData:\n  - file: test-data.json\n\
      importExtracts:\n  - file: /types/CA10__CaAwsIamPolicy__c/object.extracts.yaml\n\
      conditions:\n  - status: \"COMPLIANT\"\n    currentStateMessage: \"This IAM\
      \ Policy is not attached.\"\n    check:\n      OR:\n        args:\n        \
      \  - NOT_EQUAL:\n              left:\n                EXTRACT: CA10__attachable__c\n\
      \              right: \n                BOOLEAN: true\n          - IS_EQUAL:\n\
      \              left:\n                EXTRACT: CA10__attachmentCount__c\n  \
      \            right:\n                NUMBER: 0.0\n# For the Statement of array\
      \ type\n  - status: \"INCOMPLIANT\"\n    currentStateMessage: \"This IAM policy\
      \ with admin privileges is attached.\"\n    remediationMessage: \"Consider detaching\
      \ the IAM policy with admin privileges \"\n    check:\n      AND:\n        args:\n\
      \        # Verify that this is an array\n          - IS_EQUAL:\n           \
      \   left:\n                JSON_QUERY_TEXT:\n                  arg:\n      \
      \              EXTRACT: \"caJsonFrom_policyDocument__c\"\n                 \
      \ expression: \"type(Statement)\"\n                  undeterminedIf:\n     \
      \               evaluationError: \"The JSON query has failed.\"\n          \
      \          resultTypeMismatch: \"The JSON query did not return text type.\"\n\
      \              right:\n                TEXT: \"array\"\n        # Check number\
      \ of statements with the following conditions is not 0 (Action == '*' OR Action\
      \ == ['*']) AND (Resource == '*' OR Resource == ['*']) AND (Effect == 'Allow')\n\
      \        # we can't break it into smaller separate statements since we need\
      \ to make sure that all 3 elements (Action, Resource, Effect) present in the\
      \ same statement\n          - GREATER_THAN:\n              left:\n         \
      \       JSON_QUERY_NUMBER:\n                  arg:\n                    EXTRACT:\
      \ \"caJsonFrom_policyDocument__c\"\n                  expression: \"length(Statement[?\
      \ ((type(Action) == 'array' && contains(Action, '*')) || (type(Action) == 'string'\
      \ && Action == '*')) && ((type(Resource) == 'array' && contains(Resource, '*'))\
      \ || (type(Resource) == 'string' && Resource == '*')) && (Effect == 'Allow')])\"\
      \n                  undeterminedIf:\n                    evaluationError: \"\
      The JSON query has failed.\"\n                    resultTypeMismatch: \"The\
      \ JSON query did not return number type.\"\n              right:\n         \
      \       NUMBER: 0.0        \n# at this step any other Statements of array type\
      \ should be compliant\n  - status: \"COMPLIANT\"\n    currentStateMessage: \"\
      This IAM policy does not have admin privileges.\"\n    check:\n      NOT_EQUAL:\n\
      \        left:\n          JSON_QUERY_TEXT:\n            arg:\n             \
      \ EXTRACT: \"caJsonFrom_policyDocument__c\"\n            expression: \"type(Statement)\"\
      \n            undeterminedIf:\n              evaluationError: \"The JSON query\
      \ has failed.\"\n              resultTypeMismatch: \"The JSON query did not\
      \ return text type.\"\n        right:\n          TEXT: \"object\"\n# For the\
      \ Statement of object type Effect == Deny\n  - status: \"COMPLIANT\"\n    currentStateMessage:\
      \ \"This IAM policy does not have admin privileges.\"\n    check:\n      NOT_EQUAL:\n\
      \        left:\n          JSON_QUERY_TEXT:\n            arg:\n             \
      \ EXTRACT: \"caJsonFrom_policyDocument__c\"\n            expression: \"Statement.Effect\"\
      \n            undeterminedIf:\n              evaluationError: \"The JSON query\
      \ has failed.\"\n              resultTypeMismatch: \"The JSON query did not\
      \ return text type.\"\n        right:\n          TEXT: \"Allow\"\n# For the\
      \ Statement of object type (Action == '*' OR Action == ['*']) AND (Resource\
      \ == '*' OR Resource == ['*'])\n  - status: \"INCOMPLIANT\"\n    currentStateMessage:\
      \ \"This IAM policy with admin privileges is attached.\"\n    remediationMessage:\
      \ \"Consider detaching the IAM policy with admin privileges \"\n    check:\n\
      \      AND:\n        args:\n          - IS_EQUAL:\n              left:\n   \
      \             JSON_QUERY_BOOLEAN:\n                  arg:\n                \
      \    EXTRACT: \"caJsonFrom_policyDocument__c\"\n                  expression:\
      \ \"(type(Statement.Action) == 'string' && Statement.Action == '*') || (type(Statement.Action)\
      \ == 'array' && contains(Statement.Action, '*'))\"\n                  undeterminedIf:\n\
      \                    evaluationError: \"The JSON query has failed.\"\n     \
      \               resultTypeMismatch: \"The JSON query did not return boolean\
      \ type.\"\n              right:\n                BOOLEAN: true  \n         \
      \ - IS_EQUAL:\n              left:\n                JSON_QUERY_BOOLEAN:\n  \
      \                arg:\n                    EXTRACT: \"caJsonFrom_policyDocument__c\"\
      \n                  expression: \"(type(Statement.Resource) == 'string' && Statement.Resource\
      \ == '*') || (type(Statement.Resource) == 'array' && contains(Statement.Resource,\
      \ '*'))\"\n                  undeterminedIf:\n                    evaluationError:\
      \ \"The JSON query has failed.\"\n                    resultTypeMismatch: \"\
      The JSON query did not return boolean type.\"\n              right:\n      \
      \          BOOLEAN: true  \notherwise:\n  status: \"COMPLIANT\"\n  currentStateMessage:\
      \ \"This IAM policy does not have admin privileges.\""
  - path: /ce/ca/aws/iam/policy-allows-full-administrative-privileges/test-data.json
    md5Hash: 8739BE8DFA54C62833FE0B8691FF29F1
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-10T20:44:00Z"
              },
              "Id": "test1",
              "CA10__disappearanceTime__c": "2024-07-10T03:39:54Z",
              "CA10__attachable__c": true,
              "CA10__attachmentCount__c": 1,
              "CA10__policyDocument__c": "{\"Version\": \"2012-10-17\",\"Statement\": [{\"Effect\": \"Allow\",\"Action\": [\"*\",\"account:GetAccountInformation\"],\"Resource\": \"*\"}]}"
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "extract('CA10__attachable__c') != true || extract('CA10__attachmentCount__c') == number(0.0)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-10T20:44:00Z"
              },
              "Id": "test2",
              "CA10__disappearanceTime__c": null,
              "CA10__attachable__c": true,
              "CA10__attachmentCount__c": 0,
              "CA10__policyDocument__c": "{\"Version\": \"2012-10-17\",\"Statement\": [{\"Effect\": \"Allow\",\"Action\": [\"*\",\"account:GetAccountInformation\"],\"Resource\": \"*\"}]}"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)') == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[? ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action) == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource == \\'*\\')) && (Effect == \\'Allow\\')])') > number(0.0)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-10T20:44:00Z"
              },
              "Id": "test3",
              "CA10__disappearanceTime__c": null,
              "CA10__attachable__c": true,
              "CA10__attachmentCount__c": 4,
              "CA10__policyDocument__c": "{\"Version\": \"2012-10-17\",\"Statement\": [{\"Effect\": \"Allow\",\"Action\": [\"*\",\"account:action\"],\"Resource\": [\"*\",\"resource\"]}]}"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)') == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[? ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action) == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource == \\'*\\')) && (Effect == \\'Allow\\')])') > number(0.0)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-10T20:44:00Z"
              },
              "Id": "test4",
              "CA10__disappearanceTime__c": null,
              "CA10__attachable__c": true,
              "CA10__attachmentCount__c": 4,
              "CA10__policyDocument__c": "{\"Version\": \"2012-10-17\",\"Statement\": [{\"Effect\": \"Allow\",\"Action\": [\"*\",\"account:action\"],\"Resource\": \"*\"}]}"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)') == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[? ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action) == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource == \\'*\\')) && (Effect == \\'Allow\\')])') > number(0.0)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-10T20:44:00Z"
              },
              "Id": "test5",
              "CA10__disappearanceTime__c": null,
              "CA10__attachable__c": true,
              "CA10__attachmentCount__c": 4,
              "CA10__policyDocument__c": "{\"Version\": \"2012-10-17\",\"Statement\": [{\"Effect\": \"Allow\",\"Action\": \"*\",\"Resource\": [\"*\",\"resource\"]}]}"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)') == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[? ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action) == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource == \\'*\\')) && (Effect == \\'Allow\\')])') > number(0.0)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-10T20:44:00Z"
              },
              "Id": "test6",
              "CA10__disappearanceTime__c": null,
              "CA10__attachable__c": true,
              "CA10__attachmentCount__c": 4,
              "CA10__policyDocument__c": "{\"Version\": \"2012-10-17\",\"Statement\": [{\"Effect\": \"Allow\",\"Action\": \"*\",\"Resource\": \"*\"}]}"
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "399",
                  "conditionText": "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)') != 'object'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-10T20:44:00Z"
              },
              "Id": "test7",
              "CA10__disappearanceTime__c": null,
              "CA10__attachable__c": true,
              "CA10__attachmentCount__c": 1,
              "CA10__policyDocument__c": "{\"Version\": \"2012-10-17\",\"Statement\": [{\"Effect\": \"Allow\",\"Action\": \"action\",\"Resource\": \"resource\"}]}"
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "499",
                  "conditionText": "extract('caJsonFrom_policyDocument__c').jsonQueryText('Statement.Effect') != 'Allow'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-10T20:44:00Z"
              },
              "Id": "test8",
              "CA10__disappearanceTime__c": null,
              "CA10__attachable__c": true,
              "CA10__attachmentCount__c": 1,
              "CA10__policyDocument__c": "{\"Version\": \"2012-10-17\",\"Statement\": {\"Effect\": \"Deny\",\"Action\": \"action\",\"Resource\": \"resource\"}}"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "599",
                  "conditionText": "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action) == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action) == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource) == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource) == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-10T20:44:00Z"
              },
              "Id": "test9",
              "CA10__disappearanceTime__c": null,
              "CA10__attachable__c": true,
              "CA10__attachmentCount__c": 1,
              "CA10__policyDocument__c": "{\"Version\": \"2012-10-17\",\"Statement\": {\"Effect\": \"Allow\",\"Action\": \"*\",\"Resource\": \"*\"}}"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "599",
                  "conditionText": "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action) == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action) == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource) == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource) == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-10T20:44:00Z"
              },
              "Id": "test10",
              "CA10__disappearanceTime__c": null,
              "CA10__attachable__c": true,
              "CA10__attachmentCount__c": 1,
              "CA10__policyDocument__c": "{\"Version\": \"2012-10-17\",\"Statement\": {\"Effect\": \"Allow\",\"Action\": [\"*\",\"account:action\"],\"Resource\": [\"*\",\"resource\"]}}"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "599",
                  "conditionText": "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action) == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action) == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource) == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource) == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-10T20:44:00Z"
              },
              "Id": "test11",
              "CA10__disappearanceTime__c": null,
              "CA10__attachable__c": true,
              "CA10__attachmentCount__c": 1,
              "CA10__policyDocument__c": "{\"Version\": \"2012-10-17\",\"Statement\": {\"Effect\": \"Allow\",\"Action\": \"*\",\"Resource\": [\"*\",\"resource\"]}}"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "599",
                  "conditionText": "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action) == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action) == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource) == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource) == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-10T20:44:00Z"
              },
              "Id": "test12",
              "CA10__disappearanceTime__c": null,
              "CA10__attachable__c": true,
              "CA10__attachmentCount__c": 1,
              "CA10__policyDocument__c": "{\"Version\": \"2012-10-17\",\"Statement\": {\"Effect\": \"Allow\",\"Action\": \"*\",\"Resource\": \"*\"}}"
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "600",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-10T20:44:00Z"
              },
              "Id": "test13",
              "CA10__disappearanceTime__c": null,
              "CA10__attachable__c": true,
              "CA10__attachmentCount__c": 1,
              "CA10__policyDocument__c": "{\"Version\": \"2012-10-17\",\"Statement\": {\"Effect\": \"Allow\",\"Action\": [\"*\",\"account:action\"],\"Resource\": \"resource\"}}"
          }
      ]
  - path: /types/CA10__CaAwsIamPolicy__c/object.extracts.yaml
    md5Hash: C48327B50CE4EB54B3C6B2B464134BB3
    content: "# yaml-language-server: $schema=../../schema/Extracts.schema.json\n\
      ---\nextracts:\n# Not Nullable. Can't have no Access, retrieved via iam:ListPolicies\n\
      - name: \"CA10__name__c\"\n  value: \n    FIELD:\n      path: \"CA10__name__c\"\
      \n      undeterminedIf:\n        isEmpty: \"Corrupted data. Policy Name cannot\
      \ be empty.\"\n# Checkbox. Can't have no Access, retrieved via iam:ListPolicies\n\
      - name: \"CA10__attachable__c\"\n  value: \n    FIELD:\n      path: \"CA10__attachable__c\"\
      \n- name: \"CA10__attachmentCount__c\"\n  value: \n    FIELD:\n      path: \"\
      CA10__attachmentCount__c\"\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 Policy Document.\
      \ Possible permission issue with iam:GetPolicyVersion\"\n- name: \"caJsonFrom_policyDocument__c\"\
      \n  value:\n    JSON_FROM:\n      arg:\n        EXTRACT: \"CA10__policyDocument__c\"\
      \n      undeterminedIf:\n        isInvalid: \"IAM policy document JSON is invalid\"\
      \n# Not Nullable. Can't have no Access, retrieved via iam:ListPolicies\n- name:\
      \ \"CA10__arn__c\"\n  value: \n    FIELD:\n      path: CA10__arn__c\n      undeterminedIf:\n\
      \        isEmpty: \"Corrupted data. Policy ARN cannot be empty.\"\n"
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" : "COMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__attachable__c') != true || extract('CA10__attachmentCount__c') == number(0.0)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)') == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[? ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action) == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource == \\'*\\')) && (Effect == \\'Allow\\')])') > number(0.0)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)') == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[? ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action) == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource == \\'*\\')) && (Effect == \\'Allow\\')])') > number(0.0)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)') == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[? ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action) == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource == \\'*\\')) && (Effect == \\'Allow\\')])') > number(0.0)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test6",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)') == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[? ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action) == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource == \\'*\\')) && (Effect == \\'Allow\\')])') > number(0.0)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test7",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)') != 'object'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test8",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "499",
      "conditionText" : "extract('caJsonFrom_policyDocument__c').jsonQueryText('Statement.Effect') != 'Allow'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test9",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "599",
      "conditionText" : "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action) == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action) == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource) == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource) == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true",
      "runtimeError" : null
    }
  }, {
    "Id" : "test10",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "599",
      "conditionText" : "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action) == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action) == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource) == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource) == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true",
      "runtimeError" : null
    }
  }, {
    "Id" : "test11",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "599",
      "conditionText" : "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action) == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action) == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource) == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource) == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true",
      "runtimeError" : null
    }
  }, {
    "Id" : "test12",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "599",
      "conditionText" : "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action) == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action) == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource) == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource) == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true",
      "runtimeError" : null
    }
  }, {
    "Id" : "test13",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "600",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsIamPolicy__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__attachable__c BOOLEAN,
      CA10__attachmentCount__c FLOAT64,
      CA10__policyDocument__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-07-10T20:44:00Z")
    },
    "Id" : "test1",
    "CA10__disappearanceTime__c" : new Date("2024-07-10T03:39:54Z"),
    "CA10__attachable__c" : true,
    "CA10__attachmentCount__c" : 1,
    "CA10__policyDocument__c" : "{\"Version\": \"2012-10-17\",\"Statement\": [{\"Effect\": \"Allow\",\"Action\": [\"*\",\"account:GetAccountInformation\"],\"Resource\": \"*\"}]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-10T20:44:00Z")
    },
    "Id" : "test2",
    "CA10__attachable__c" : true,
    "CA10__attachmentCount__c" : 0,
    "CA10__policyDocument__c" : "{\"Version\": \"2012-10-17\",\"Statement\": [{\"Effect\": \"Allow\",\"Action\": [\"*\",\"account:GetAccountInformation\"],\"Resource\": \"*\"}]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-10T20:44:00Z")
    },
    "Id" : "test3",
    "CA10__attachable__c" : true,
    "CA10__attachmentCount__c" : 4,
    "CA10__policyDocument__c" : "{\"Version\": \"2012-10-17\",\"Statement\": [{\"Effect\": \"Allow\",\"Action\": [\"*\",\"account:action\"],\"Resource\": [\"*\",\"resource\"]}]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-10T20:44:00Z")
    },
    "Id" : "test4",
    "CA10__attachable__c" : true,
    "CA10__attachmentCount__c" : 4,
    "CA10__policyDocument__c" : "{\"Version\": \"2012-10-17\",\"Statement\": [{\"Effect\": \"Allow\",\"Action\": [\"*\",\"account:action\"],\"Resource\": \"*\"}]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-10T20:44:00Z")
    },
    "Id" : "test5",
    "CA10__attachable__c" : true,
    "CA10__attachmentCount__c" : 4,
    "CA10__policyDocument__c" : "{\"Version\": \"2012-10-17\",\"Statement\": [{\"Effect\": \"Allow\",\"Action\": \"*\",\"Resource\": [\"*\",\"resource\"]}]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-10T20:44:00Z")
    },
    "Id" : "test6",
    "CA10__attachable__c" : true,
    "CA10__attachmentCount__c" : 4,
    "CA10__policyDocument__c" : "{\"Version\": \"2012-10-17\",\"Statement\": [{\"Effect\": \"Allow\",\"Action\": \"*\",\"Resource\": \"*\"}]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-10T20:44:00Z")
    },
    "Id" : "test7",
    "CA10__attachable__c" : true,
    "CA10__attachmentCount__c" : 1,
    "CA10__policyDocument__c" : "{\"Version\": \"2012-10-17\",\"Statement\": [{\"Effect\": \"Allow\",\"Action\": \"action\",\"Resource\": \"resource\"}]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-10T20:44:00Z")
    },
    "Id" : "test8",
    "CA10__attachable__c" : true,
    "CA10__attachmentCount__c" : 1,
    "CA10__policyDocument__c" : "{\"Version\": \"2012-10-17\",\"Statement\": {\"Effect\": \"Deny\",\"Action\": \"action\",\"Resource\": \"resource\"}}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-10T20:44:00Z")
    },
    "Id" : "test9",
    "CA10__attachable__c" : true,
    "CA10__attachmentCount__c" : 1,
    "CA10__policyDocument__c" : "{\"Version\": \"2012-10-17\",\"Statement\": {\"Effect\": \"Allow\",\"Action\": \"*\",\"Resource\": \"*\"}}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-10T20:44:00Z")
    },
    "Id" : "test10",
    "CA10__attachable__c" : true,
    "CA10__attachmentCount__c" : 1,
    "CA10__policyDocument__c" : "{\"Version\": \"2012-10-17\",\"Statement\": {\"Effect\": \"Allow\",\"Action\": [\"*\",\"account:action\"],\"Resource\": [\"*\",\"resource\"]}}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-10T20:44:00Z")
    },
    "Id" : "test11",
    "CA10__attachable__c" : true,
    "CA10__attachmentCount__c" : 1,
    "CA10__policyDocument__c" : "{\"Version\": \"2012-10-17\",\"Statement\": {\"Effect\": \"Allow\",\"Action\": \"*\",\"Resource\": [\"*\",\"resource\"]}}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-10T20:44:00Z")
    },
    "Id" : "test12",
    "CA10__attachable__c" : true,
    "CA10__attachmentCount__c" : 1,
    "CA10__policyDocument__c" : "{\"Version\": \"2012-10-17\",\"Statement\": {\"Effect\": \"Allow\",\"Action\": \"*\",\"Resource\": \"*\"}}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-10T20:44:00Z")
    },
    "Id" : "test13",
    "CA10__attachable__c" : true,
    "CA10__attachmentCount__c" : 1,
    "CA10__policyDocument__c" : "{\"Version\": \"2012-10-17\",\"Statement\": {\"Effect\": \"Allow\",\"Action\": [\"*\",\"account:action\"],\"Resource\": \"resource\"}}"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsIamPolicy__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__attachable__c BOOLEAN,
          CA10__attachmentCount__c FLOAT64,
          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__attachable__c; } return this.out; };
      function extract6() { if (!this.out) { this.out = obj.CA10__attachmentCount__c; } return this.out; };
      references1.push('Attachable [obj.CA10__attachable__c]: ' + obj.CA10__attachable__c);
      references1.push('Attachment Count [obj.CA10__attachmentCount__c]: ' + obj.CA10__attachmentCount__c);
      if (extract3.call(extract3) != true || extract6.call(extract6) == 0.0) {
          return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__attachable__c') != true || extract('CA10__attachmentCount__c') == number(0.0)", currentStateMessage: "This IAM Policy is not attached.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function jsonQueryChecked8() {
          var input = extract10.call(extract10);
          var out;
          try {
              out = jmespath.search(input, 'type(Statement)');
          if (out != null && typeof out != 'string') {
              throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return text type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:204", {cause: {status: 'UNDETERMINED', conditionIndex: 204, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonChecked11() {
          var input = extract13.call(extract13);
          input = TextLib.isEmpty(input) ? null : input;
          var out;
          try {
              out = JSON.parse(input);
          } catch (e) {
              throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "extract('CA10__policyDocument__c').asJson().isInvalid()", currentStateMessage: "IAM policy document JSON is invalid", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function fieldChecked14() {
          if ((obj.CA10__policyDocument__c == null || obj.CA10__policyDocument__c == '')) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__policyDocument__c.delegatedTo(CA10__policyDocument__c).isEmpty()", currentStateMessage: "Unable to determine the Policy Document. Possible permission issue with iam:GetPolicyVersion", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__policyDocument__c;
      }
      function extract13() { if (!this.out) { this.out = fieldChecked14(); } return this.out; };
      function extract10() { if (!this.out) { this.out = jsonChecked11(); } return this.out; };
      function comparison16() {
          var comparisonLeft19 = jsonQueryChecked17();
          return comparisonLeft19 != null && 0.0 != null && comparisonLeft19 > 0.0;
      }
      function jsonQueryChecked17() {
          var input = extract10.call(extract10);
          var out;
          try {
              out = jmespath.search(input, 'length(Statement[? ((type(Action) == \'array\' && contains(Action, \'*\')) || (type(Action) == \'string\' && Action == \'*\')) && ((type(Resource) == \'array\' && contains(Resource, \'*\')) || (type(Resource) == \'string\' && Resource == \'*\')) && (Effect == \'Allow\')])');
          if (out != null && typeof out != 'number') {
              throw new Error("UNDETERMINED condition:205", {cause: {status: 'UNDETERMINED', conditionIndex: 205, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[? ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action) == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource == \\'*\\')) && (Effect == \\'Allow\\')])').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return number type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:206", {cause: {status: 'UNDETERMINED', conditionIndex: 206, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[? ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action) == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource == \\'*\\')) && (Effect == \\'Allow\\')])').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      references1.push('Policy Document JSON [obj.CA10__policyDocument__c]: ' + obj.CA10__policyDocument__c);
      try {
          if (TextLib.equal(jsonQueryChecked8(), 'array') && comparison16()) {
              return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)') == 'array' && extract('caJsonFrom_policyDocument__c').jsonQueryText('length(Statement[? ((type(Action) == \\'array\\' && contains(Action, \\'*\\')) || (type(Action) == \\'string\\' && Action == \\'*\\')) && ((type(Resource) == \\'array\\' && contains(Resource, \\'*\\')) || (type(Resource) == \\'string\\' && Resource == \\'*\\')) && (Effect == \\'Allow\\')])') > number(0.0)", currentStateMessage: "This IAM policy with admin privileges is attached.", currentStateReferences: references1.join('\n'), remediation: "Consider detaching the IAM policy with admin privileges ", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[3], conditionIndex:[300..399]
      function jsonQueryChecked20() {
          var input = extract22.call(extract22);
          var out;
          try {
              out = jmespath.search(input, 'type(Statement)');
          if (out != null && typeof out != 'string') {
              throw new Error("UNDETERMINED condition:303", {cause: {status: 'UNDETERMINED', conditionIndex: 303, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return text type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:304", {cause: {status: 'UNDETERMINED', conditionIndex: 304, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonChecked23() {
          var input = extract25.call(extract25);
          input = TextLib.isEmpty(input) ? null : input;
          var out;
          try {
              out = JSON.parse(input);
          } catch (e) {
              throw new Error("UNDETERMINED condition:302", {cause: {status: 'UNDETERMINED', conditionIndex: 302, conditionText: "extract('CA10__policyDocument__c').asJson().isInvalid()", currentStateMessage: "IAM policy document JSON is invalid", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function fieldChecked26() {
          if ((obj.CA10__policyDocument__c == null || obj.CA10__policyDocument__c == '')) {
              throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "CA10__policyDocument__c.delegatedTo(CA10__policyDocument__c).isEmpty()", currentStateMessage: "Unable to determine the Policy Document. Possible permission issue with iam:GetPolicyVersion", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__policyDocument__c;
      }
      function extract25() { if (!this.out) { this.out = fieldChecked26(); } return this.out; };
      function extract22() { if (!this.out) { this.out = jsonChecked23(); } return this.out; };
      try {
          if (TextLib.notEqual(jsonQueryChecked20(), 'object')) {
              return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('type(Statement)') != 'object'", currentStateMessage: "This IAM policy does not have admin privileges.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[4], conditionIndex:[400..499]
      function jsonQueryChecked28() {
          var input = extract30.call(extract30);
          var out;
          try {
              out = jmespath.search(input, 'Statement.Effect');
          if (out != null && typeof out != 'string') {
              throw new Error("UNDETERMINED condition:403", {cause: {status: 'UNDETERMINED', conditionIndex: 403, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('Statement.Effect').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return text type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:404", {cause: {status: 'UNDETERMINED', conditionIndex: 404, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('Statement.Effect').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonChecked31() {
          var input = extract33.call(extract33);
          input = TextLib.isEmpty(input) ? null : input;
          var out;
          try {
              out = JSON.parse(input);
          } catch (e) {
              throw new Error("UNDETERMINED condition:402", {cause: {status: 'UNDETERMINED', conditionIndex: 402, conditionText: "extract('CA10__policyDocument__c').asJson().isInvalid()", currentStateMessage: "IAM policy document JSON is invalid", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function fieldChecked34() {
          if ((obj.CA10__policyDocument__c == null || obj.CA10__policyDocument__c == '')) {
              throw new Error("UNDETERMINED condition:401", {cause: {status: 'UNDETERMINED', conditionIndex: 401, conditionText: "CA10__policyDocument__c.delegatedTo(CA10__policyDocument__c).isEmpty()", currentStateMessage: "Unable to determine the Policy Document. Possible permission issue with iam:GetPolicyVersion", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__policyDocument__c;
      }
      function extract33() { if (!this.out) { this.out = fieldChecked34(); } return this.out; };
      function extract30() { if (!this.out) { this.out = jsonChecked31(); } return this.out; };
      try {
          if (TextLib.notEqual(jsonQueryChecked28(), 'Allow')) {
              return {status: 'COMPLIANT', conditionIndex: 499, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('Statement.Effect') != 'Allow'", currentStateMessage: "This IAM policy does not have admin privileges.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[5], conditionIndex:[500..599]
      function jsonQueryChecked36() {
          var input = extract38.call(extract38);
          var out;
          try {
              out = jmespath.search(input, '(type(Statement.Action) == \'string\' && Statement.Action == \'*\') || (type(Statement.Action) == \'array\' && contains(Statement.Action, \'*\'))');
          if (out != null && typeof out != 'boolean') {
              throw new Error("UNDETERMINED condition:503", {cause: {status: 'UNDETERMINED', conditionIndex: 503, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action) == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action) == \\'array\\' && contains(Statement.Action, \\'*\\'))').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return boolean type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:504", {cause: {status: 'UNDETERMINED', conditionIndex: 504, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action) == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action) == \\'array\\' && contains(Statement.Action, \\'*\\'))').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonChecked39() {
          var input = extract41.call(extract41);
          input = TextLib.isEmpty(input) ? null : input;
          var out;
          try {
              out = JSON.parse(input);
          } catch (e) {
              throw new Error("UNDETERMINED condition:502", {cause: {status: 'UNDETERMINED', conditionIndex: 502, conditionText: "extract('CA10__policyDocument__c').asJson().isInvalid()", currentStateMessage: "IAM policy document JSON is invalid", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function fieldChecked42() {
          if ((obj.CA10__policyDocument__c == null || obj.CA10__policyDocument__c == '')) {
              throw new Error("UNDETERMINED condition:501", {cause: {status: 'UNDETERMINED', conditionIndex: 501, conditionText: "CA10__policyDocument__c.delegatedTo(CA10__policyDocument__c).isEmpty()", currentStateMessage: "Unable to determine the Policy Document. Possible permission issue with iam:GetPolicyVersion", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__policyDocument__c;
      }
      function extract41() { if (!this.out) { this.out = fieldChecked42(); } return this.out; };
      function extract38() { if (!this.out) { this.out = jsonChecked39(); } return this.out; };
      function jsonQueryChecked44() {
          var input = extract38.call(extract38);
          var out;
          try {
              out = jmespath.search(input, '(type(Statement.Resource) == \'string\' && Statement.Resource == \'*\') || (type(Statement.Resource) == \'array\' && contains(Statement.Resource, \'*\'))');
          if (out != null && typeof out != 'boolean') {
              throw new Error("UNDETERMINED condition:505", {cause: {status: 'UNDETERMINED', conditionIndex: 505, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource) == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource) == \\'array\\' && contains(Statement.Resource, \\'*\\'))').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return boolean type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:506", {cause: {status: 'UNDETERMINED', conditionIndex: 506, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource) == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource) == \\'array\\' && contains(Statement.Resource, \\'*\\'))').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      try {
          if (jsonQueryChecked36() == true && jsonQueryChecked44() == true) {
              return {status: 'INCOMPLIANT', conditionIndex: 599, conditionText: "extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Action) == \\'string\\' && Statement.Action == \\'*\\') || (type(Statement.Action) == \\'array\\' && contains(Statement.Action, \\'*\\'))') == true && extract('caJsonFrom_policyDocument__c').jsonQueryText('(type(Statement.Resource) == \\'string\\' && Statement.Resource == \\'*\\') || (type(Statement.Resource) == \\'array\\' && contains(Statement.Resource, \\'*\\'))') == true", currentStateMessage: "This IAM policy with admin privileges is attached.", currentStateReferences: references1.join('\n'), remediation: "Consider detaching the IAM policy with admin privileges ", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'COMPLIANT', conditionIndex: 600, conditionText: "otherwise", currentStateMessage: "This IAM policy does not have admin privileges.", 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__attachable__c AS CA10__attachable__c,
          sObject.CA10__attachmentCount__c AS CA10__attachmentCount__c,
          sObject.CA10__policyDocument__c AS CA10__policyDocument__c,
          process_CA10__CaAwsIamPolicy__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__attachable__c AS CA10__attachable__c,
                  sObject.CA10__attachmentCount__c AS CA10__attachmentCount__c,
                  sObject.CA10__policyDocument__c AS CA10__policyDocument__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsIamPolicy__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
