--- policy: /ce/ca/aws/s3/bucket-intelligent-tiering-configuration logic: /ce/ca/aws/s3/bucket-intelligent-tiering-configuration/prod.logic.yaml executionTime: 2026-06-06T12:03:22.654136461Z generationMs: 47 executionMs: 1051 rows: - id: '001' 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: '002' match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 199 actual: 199 conditionText: expected: extract('CA10__intelligentTieringStorageGb__c').isEmpty() && extract('caJsonFrom__lifecycleRulesJson__c').isEmpty() actual: extract('CA10__intelligentTieringStorageGb__c').isEmpty() && extract('caJsonFrom__lifecycleRulesJson__c').isEmpty() runtimeError: {} - id: '003' match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 299 actual: 299 conditionText: expected: "extract('CA10__intelligentTieringStorageGb__c').isEmpty() && extract('caJsonFrom__lifecycleRulesJson__c').jsonQueryText('length([?status==\\\ 'Enabled\\'].transitions[] | [?storageClassAsString==\\'INTELLIGENT_TIERING\\\ '])') == number(0.0)" actual: "extract('CA10__intelligentTieringStorageGb__c').isEmpty() && extract('caJsonFrom__lifecycleRulesJson__c').jsonQueryText('length([?status==\\\ 'Enabled\\'].transitions[] | [?storageClassAsString==\\'INTELLIGENT_TIERING\\\ '])') == number(0.0)" runtimeError: {} - id: '004' match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 399 actual: 399 conditionText: expected: extract('caJsonFrom__intelligentTieringConfigurationsJson__c').isEmpty() actual: extract('caJsonFrom__intelligentTieringConfigurationsJson__c').isEmpty() runtimeError: {} - id: '005' match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 399 actual: 399 conditionText: expected: extract('caJsonFrom__intelligentTieringConfigurationsJson__c').isEmpty() actual: extract('caJsonFrom__intelligentTieringConfigurationsJson__c').isEmpty() runtimeError: {} - id: '006' match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 499 actual: 499 conditionText: expected: extract('caJsonFrom__intelligentTieringConfigurationsJson__c').jsonQueryText('length(@)') == number(0.0) actual: extract('caJsonFrom__intelligentTieringConfigurationsJson__c').jsonQueryText('length(@)') == number(0.0) runtimeError: {} - id: '007' match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 599 actual: 599 conditionText: expected: "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').jsonQueryText('length([?status==\\\ 'Enabled\\'])') == number(0.0)" actual: "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').jsonQueryText('length([?status==\\\ 'Enabled\\'])') == number(0.0)" runtimeError: {} - id: '008' match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 600 actual: 600 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/aws/s3/bucket-intelligent-tiering-configuration/policy.yaml md5Hash: B9DE16FBD93956C48975515DBB635069 content: "---\nnames:\n full: \"AWS S3 Bucket with Intelligent-Tiering is missing\ \ Archive configurations\"\n contextual: \"Bucket with Intelligent-Tiering\ \ is missing Archive configurations\"\ndescription: \"Ensure that S3 buckets\ \ with Intelligent-Tiering enabled are configured\\\n \\ to automatically move\ \ objects to the optional Archive Access and Deep Archive\\\n \\ Access tiers\ \ to maximize storage cost savings.\"\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n\ \ - COST\nframeworkMappings:\n - \"/frameworks/cloudaware/cost-efficiency-and-optimization/resource-optimization\"\ \n " - path: /ce/ca/aws/s3/bucket-intelligent-tiering-configuration/prod.logic.yaml md5Hash: 390B1BBC232D0725246D7229BDC3343C content: "---\ninputType: \"CA10__CaAwsBucket__c\"\ntestData:\n - file: \"test-data.json\"\ \nimportExtracts:\n - file: \"/types/CA10__CaAwsBucket__c/object.extracts.yaml\"\ \nconditions:\n - status: \"INAPPLICABLE\"\n currentStateMessage: \"The\ \ bucket does not store objects in Intelligent Tiering.\"\n check:\n \ \ AND:\n args:\n - IS_EMPTY:\n arg:\n \ \ EXTRACT: \"CA10__intelligentTieringStorageGb__c\"\n - IS_EMPTY:\n\ \ arg:\n EXTRACT: \"caJsonFrom__lifecycleRulesJson__c\"\ \n - status: \"INAPPLICABLE\"\n currentStateMessage: \"The bucket does not\ \ store objects in Intelligent Tiering.\"\n check:\n AND:\n args:\n\ \ - IS_EMPTY:\n arg:\n EXTRACT: \"CA10__intelligentTieringStorageGb__c\"\ \n # returns true if there are no active lifecycle rules that move\ \ objects to INTELLIGENT_TIERING\n - IS_EQUAL:\n left:\n\ \ JSON_QUERY_NUMBER:\n arg: \n \ \ EXTRACT: \"caJsonFrom__lifecycleRulesJson__c\"\n expression:\ \ \"length([?status=='Enabled'].transitions[] | [?storageClassAsString=='INTELLIGENT_TIERING'])\"\ \n undeterminedIf: \n evaluationError: \"\ The JSON query has failed.\"\n resultTypeMismatch: \"The\ \ JSON query did not return a boolean.\"\n right:\n \ \ NUMBER: 0.0 \n - status: \"INCOMPLIANT\"\n currentStateMessage: \"\ The bucket does not have an Intelligent Tiering configuration.\"\n remediationMessage:\ \ \"Create an S3 Intelligent Tiering configuration for the bucket.\"\n check:\n\ \ IS_EMPTY:\n arg:\n EXTRACT: \"caJsonFrom__intelligentTieringConfigurationsJson__c\"\ \n - status: \"INCOMPLIANT\"\n currentStateMessage: \"The bucket does not\ \ have an Intelligent Tiering configuration.\"\n remediationMessage: \"Create\ \ an S3 Intelligent Tiering configuration for the bucket.\"\n check:\n \ \ IS_EQUAL:\n left:\n JSON_QUERY_NUMBER:\n arg:\n\ \ EXTRACT: \"caJsonFrom__intelligentTieringConfigurationsJson__c\"\ \n expression: \"length(@)\"\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 - status: \"INCOMPLIANT\"\n currentStateMessage: \"The\ \ bucket Intelligent Tiering configuration is disabled.\"\n remediationMessage:\ \ \"Enable an S3 Intelligent Tiering configuration for the bucket.\"\n check:\n\ \ IS_EQUAL:\n left:\n JSON_QUERY_NUMBER:\n arg:\n\ \ EXTRACT: \"caJsonFrom__intelligentTieringConfigurationsJson__c\"\ \n expression: \"length([?status=='Enabled'])\"\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 \notherwise:\n status: \"COMPLIANT\"\n\ \ currentStateMessage: \"The bucket has an active Intelligent Tiering configuration.\"\ \n" - path: /ce/ca/aws/s3/bucket-intelligent-tiering-configuration/test-data.json md5Hash: 4C8B259B4B9D193DAFADDA406C0C6A3C content: |- [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2025-09-10T17:26:32Z" }, "Id": "001", "CA10__disappearanceTime__c": "2025-09-04T19:13:10Z", "CA10__intelligentTieringStorageGb__c": null, "CA10__lifecycleRulesJson__c": "[{\"id\":\"id\",\"status\":\"Enabled\"}]", "CA10__intelligentTieringConfigurationsJson__c": "[]" }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "extract('CA10__intelligentTieringStorageGb__c').isEmpty() && extract('caJsonFrom__lifecycleRulesJson__c').isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2025-09-10T17:26:32Z" }, "Id": "002", "CA10__disappearanceTime__c": null, "CA10__intelligentTieringStorageGb__c": null, "CA10__lifecycleRulesJson__c": "", "CA10__intelligentTieringConfigurationsJson__c": "[]" }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "299", "conditionText": "extract('CA10__intelligentTieringStorageGb__c').isEmpty() && extract('caJsonFrom__lifecycleRulesJson__c').jsonQueryText('length([?status==\\'Enabled\\'].transitions[] | [?storageClassAsString==\\'INTELLIGENT_TIERING\\'])') == number(0.0)", "runtimeError": null }, "context": { "snapshotTime": "2025-09-10T17:26:32Z" }, "Id": "003", "CA10__disappearanceTime__c": null, "CA10__intelligentTieringStorageGb__c": null, "CA10__lifecycleRulesJson__c": "[{\"id\":\"id\",\"status\":\"Enabled\"}]", "CA10__intelligentTieringConfigurationsJson__c": "[]" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "399", "conditionText": "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2025-09-10T17:26:32Z" }, "Id": "004", "CA10__disappearanceTime__c": null, "CA10__intelligentTieringStorageGb__c": 10, "CA10__lifecycleRulesJson__c": "[{\"id\":\"id\",\"status\":\"Enabled\"}]", "CA10__intelligentTieringConfigurationsJson__c": "" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "399", "conditionText": "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2025-09-10T17:26:32Z" }, "Id": "005", "CA10__disappearanceTime__c": null, "CA10__intelligentTieringStorageGb__c": null, "CA10__lifecycleRulesJson__c": "[{\"id\":\"id\",\"status\":\"Enabled\",\"transitions\":[{\"storageClass\":\"IntelligentTiering\",\"storageClassAsString\":\"INTELLIGENT_TIERING\",\"days\":90}]}]", "CA10__intelligentTieringConfigurationsJson__c": "" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "499", "conditionText": "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').jsonQueryText('length(@)') == number(0.0)", "runtimeError": null }, "context": { "snapshotTime": "2025-09-10T17:26:32Z" }, "Id": "006", "CA10__disappearanceTime__c": null, "CA10__intelligentTieringStorageGb__c": null, "CA10__lifecycleRulesJson__c": "[{\"id\":\"id\",\"status\":\"Enabled\",\"transitions\":[{\"storageClass\":\"IntelligentTiering\",\"storageClassAsString\":\"INTELLIGENT_TIERING\",\"days\":90}]}]", "CA10__intelligentTieringConfigurationsJson__c": "[]" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "599", "conditionText": "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').jsonQueryText('length([?status==\\'Enabled\\'])') == number(0.0)", "runtimeError": null }, "context": { "snapshotTime": "2025-09-10T17:26:32Z" }, "Id": "007", "CA10__disappearanceTime__c": null, "CA10__intelligentTieringStorageGb__c": null, "CA10__lifecycleRulesJson__c": "[{\"id\":\"id\",\"status\":\"Enabled\",\"transitions\":[{\"storageClass\":\"IntelligentTiering\",\"storageClassAsString\":\"INTELLIGENT_TIERING\",\"days\":90}]}]", "CA10__intelligentTieringConfigurationsJson__c": "[{\"id\":\"intelligent-tiering\",\"status\":\"Disabled\",\"tiering\":[{\"days\":90,\"accessTier\":\"ARCHIVE_ACCESS\"},{\"days\":180,\"accessTier\":\"DEEP_ARCHIVE_ACCESS\"}]}]" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "600", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2025-09-10T17:26:32Z" }, "Id": "008", "CA10__disappearanceTime__c": null, "CA10__intelligentTieringStorageGb__c": 10, "CA10__lifecycleRulesJson__c": "[{\"id\":\"id\",\"status\":\"Enabled\"}]", "CA10__intelligentTieringConfigurationsJson__c": "[{\"id\":\"intelligent-tiering\",\"status\":\"Enabled\",\"tiering\":[{\"days\":90,\"accessTier\":\"ARCHIVE_ACCESS\"},{\"days\":180,\"accessTier\":\"DEEP_ARCHIVE_ACCESS\"}]}]" } ] - path: /types/CA10__CaAwsBucket__c/object.extracts.yaml md5Hash: F56AFA293B0B19D4F39C1EBB70F4C56F 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: \"caJsonBoolean__lifecycleRulesJsonStatusEnabled__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# Nullable.\n\ \ - name: \"CA10__intelligentTieringConfigurationsJson__c\"\n value: \n\ \ FIELD:\n path: \"CA10__intelligentTieringConfigurationsJson__c\"\ \n returnType: BYTES\n - name: \"caJsonFrom__intelligentTieringConfigurationsJson__c\"\ \n value: \n JSON_FROM:\n arg: \n EXTRACT: \"CA10__intelligentTieringConfigurationsJson__c\"\ \n undeterminedIf:\n isInvalid: \"S3 Bucket Policy Document\ \ JSON is invalid.\"\n# Nullable.\n - name: \"CA10__regionName__c\"\n value:\n\ \ FIELD:\n path: \"CA10__regionName__c\"\n# Nullable.\n - name:\ \ \"CA10__intelligentTieringStorageGb__c\"\n value:\n FIELD:\n \ \ path: \"CA10__intelligentTieringStorageGb__c\"\n# Values: AES256 | aws:fsx\ \ | aws:kms | aws:kms:dsse | None. Not Nullable.\n - name: \"CA10__serverSideEncryptionAlgorithm__c\"\ \n value:\n FIELD:\n path: \"CA10__serverSideEncryptionAlgorithm__c\"\ \n undeterminedIf:\n noAccessDelegate:\n path: \"\ CA10__serverSideEncryptionAlgorithm__c\"\n currentStateMessage: \"\ Unable to determine Bucket Encryption Algorithm. Possible permissions issue\ \ with s3:GetEncryptionConfiguration\"\n - name: \"CA10__accessControlPolicy__c\"\ \n value: \n FIELD:\n path: \"CA10__accessControlPolicy__c\"\n\ \ undeterminedIf:\n noAccessDelegate:\n path: \"\ CA10__accessControlPolicy__c\"\n currentStateMessage: \"Unable to\ \ determine the bucket ACL. Possible permission issue with s3:GetBucketAcl\"\ \n - name: \"caJsonFrom__accessControlPolicy__c\"\n value: \n JSON_FROM:\n\ \ arg:\n EXTRACT: \"CA10__accessControlPolicy__c\"\n \ \ undeterminedIf:\n isInvalid: \"The Access Control Policy JSON is\ \ invalid.\"\n - name: \"CA10__accessControlGrants__c\"\n value: \n \ \ FIELD:\n path: \"CA10__accessControlGrants__c\"\n undeterminedIf:\n\ \ noAccessDelegate:\n path: \"CA10__accessControlGrants__c\"\ \n currentStateMessage: \"Unable to determine the bucket ACL. Possible\ \ permission issue with s3:GetBucketAcl\"\n - name: \"CA10__policyIsPublic__c\"\ \n value: \n FIELD:\n path: \"CA10__policyIsPublic__c\"\n \ \ undeterminedIf:\n noAccessDelegate:\n path: \"CA10__policyIsPublic__c\"\ \n currentStateMessage: \"Unable to determine the bucket policy status.\ \ Possible permission issue with s3:GetBucketPolicyStatus\"\n" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "001", "expectedResult" : { "status" : "DISAPPEARED", "conditionIndex" : "99", "conditionText" : "isDisappeared(CA10__disappearanceTime__c)", "runtimeError" : null } }, { "Id" : "002", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "199", "conditionText" : "extract('CA10__intelligentTieringStorageGb__c').isEmpty() && extract('caJsonFrom__lifecycleRulesJson__c').isEmpty()", "runtimeError" : null } }, { "Id" : "003", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "299", "conditionText" : "extract('CA10__intelligentTieringStorageGb__c').isEmpty() && extract('caJsonFrom__lifecycleRulesJson__c').jsonQueryText('length([?status==\\'Enabled\\'].transitions[] | [?storageClassAsString==\\'INTELLIGENT_TIERING\\'])') == number(0.0)", "runtimeError" : null } }, { "Id" : "004", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "399", "conditionText" : "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').isEmpty()", "runtimeError" : null } }, { "Id" : "005", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "399", "conditionText" : "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').isEmpty()", "runtimeError" : null } }, { "Id" : "006", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "499", "conditionText" : "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').jsonQueryText('length(@)') == number(0.0)", "runtimeError" : null } }, { "Id" : "007", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "599", "conditionText" : "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').jsonQueryText('length([?status==\\'Enabled\\'])') == number(0.0)", "runtimeError" : null } }, { "Id" : "008", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "600", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsBucket__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-09-10T17:26:32Z") }, "CA10__disappearanceTime__c" : new Date("2025-09-04T19:13:10Z"), "CA10__intelligentTieringStorageGb__c" : null, "CA10__lifecycleRulesJson__c" : "[{\"id\":\"id\",\"status\":\"Enabled\"}]", "CA10__intelligentTieringConfigurationsJson__c" : "[]", "Id" : "001" }, { "context" : { "snapshotTime" : new Date("2025-09-10T17:26:32Z") }, "CA10__intelligentTieringStorageGb__c" : null, "CA10__lifecycleRulesJson__c" : "", "CA10__intelligentTieringConfigurationsJson__c" : "[]", "Id" : "002" }, { "context" : { "snapshotTime" : new Date("2025-09-10T17:26:32Z") }, "CA10__intelligentTieringStorageGb__c" : null, "CA10__lifecycleRulesJson__c" : "[{\"id\":\"id\",\"status\":\"Enabled\"}]", "CA10__intelligentTieringConfigurationsJson__c" : "[]", "Id" : "003" }, { "context" : { "snapshotTime" : new Date("2025-09-10T17:26:32Z") }, "CA10__intelligentTieringStorageGb__c" : 10, "CA10__lifecycleRulesJson__c" : "[{\"id\":\"id\",\"status\":\"Enabled\"}]", "CA10__intelligentTieringConfigurationsJson__c" : "", "Id" : "004" }, { "context" : { "snapshotTime" : new Date("2025-09-10T17:26:32Z") }, "CA10__intelligentTieringStorageGb__c" : null, "CA10__lifecycleRulesJson__c" : "[{\"id\":\"id\",\"status\":\"Enabled\",\"transitions\":[{\"storageClass\":\"IntelligentTiering\",\"storageClassAsString\":\"INTELLIGENT_TIERING\",\"days\":90}]}]", "CA10__intelligentTieringConfigurationsJson__c" : "", "Id" : "005" }, { "context" : { "snapshotTime" : new Date("2025-09-10T17:26:32Z") }, "CA10__intelligentTieringStorageGb__c" : null, "CA10__lifecycleRulesJson__c" : "[{\"id\":\"id\",\"status\":\"Enabled\",\"transitions\":[{\"storageClass\":\"IntelligentTiering\",\"storageClassAsString\":\"INTELLIGENT_TIERING\",\"days\":90}]}]", "CA10__intelligentTieringConfigurationsJson__c" : "[]", "Id" : "006" }, { "context" : { "snapshotTime" : new Date("2025-09-10T17:26:32Z") }, "CA10__intelligentTieringStorageGb__c" : null, "CA10__lifecycleRulesJson__c" : "[{\"id\":\"id\",\"status\":\"Enabled\",\"transitions\":[{\"storageClass\":\"IntelligentTiering\",\"storageClassAsString\":\"INTELLIGENT_TIERING\",\"days\":90}]}]", "CA10__intelligentTieringConfigurationsJson__c" : "[{\"id\":\"intelligent-tiering\",\"status\":\"Disabled\",\"tiering\":[{\"days\":90,\"accessTier\":\"ARCHIVE_ACCESS\"},{\"days\":180,\"accessTier\":\"DEEP_ARCHIVE_ACCESS\"}]}]", "Id" : "007" }, { "context" : { "snapshotTime" : new Date("2025-09-10T17:26:32Z") }, "CA10__intelligentTieringStorageGb__c" : 10, "CA10__lifecycleRulesJson__c" : "[{\"id\":\"id\",\"status\":\"Enabled\"}]", "CA10__intelligentTieringConfigurationsJson__c" : "[{\"id\":\"intelligent-tiering\",\"status\":\"Enabled\",\"tiering\":[{\"days\":90,\"accessTier\":\"ARCHIVE_ACCESS\"},{\"days\":180,\"accessTier\":\"DEEP_ARCHIVE_ACCESS\"}]}]", "Id" : "008" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsBucket__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__intelligentTieringStorageGb__c FLOAT64, CA10__lifecycleRulesJson__c STRING, CA10__intelligentTieringConfigurationsJson__c STRING, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js OPTIONS (library=['gs://compliance-platform-public/jmespath.min.js']) AS r""" var JsonLib = new function () { this.isEmpty = function(arg) { return this.equal(arg, {}); }; this.isNotEmpty = function(arg) { return this.notEqual(arg, {}); }; this.equal = function jsonEqual(left, right) { function removeNullProperties(obj) { if (obj === null || typeof obj !== 'object') { return obj; } if (Array.isArray(obj)) { return obj.map(removeNullProperties); } const newObj = {}; for (const key in obj) { if (obj[key] !== null) { newObj[key] = removeNullProperties(obj[key]); } } return newObj; } const replacer = (key, value) => { if (value && typeof value === 'object' && !Array.isArray(value)) { return Object.keys(value).sort().reduce((sorted, k) => { sorted[k] = value[k]; return sorted; }, {}); } return value; }; return JSON.stringify(removeNullProperties(left == null ? {} : left), replacer) === JSON.stringify(removeNullProperties(right == null ? {} : right), replacer); } this.notEqual = function(left, right) { return !this.equal(left, right); }; }(); var IsEmptyLib = new function () { this.simpleIsEmpty = function(arg) { return arg == null; }; this.simpleIsNotEmpty = function(arg) { return arg != null; }; }(); var TextLib = new function () { this.normalize = function(arg) { return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase(); }; this.isEmpty = function(arg) { return this.normalize(arg) == ''; }; this.isNotEmpty = function(arg) { return this.normalize(arg) != ''; }; this.equal = function(left, right) { return this.normalize(left) == this.normalize(right); }; this.notEqual = function(left, right) { return this.normalize(left) != this.normalize(right); }; this.startsWith = function(arg, substring) { return this.normalize(arg).startsWith(this.normalize(substring)); }; this.endsWith = function(arg, substring) { return this.normalize(arg).endsWith(this.normalize(substring)); }; this.contains = function(arg, substring) { return this.normalize(arg).includes(this.normalize(substring)); }; this.containsAll = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.every(sub => normalizedArg.includes(this.normalize(sub))); }; this.containsAny = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.some(sub => normalizedArg.includes(this.normalize(sub))); }; }(); var references1 = []; // condition[0], conditionIndex:[0..99] references1.push('Deleted From 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__intelligentTieringStorageGb__c; } return this.out; }; function jsonChecked7() { var input = extract9.call(extract9); input = TextLib.isEmpty(input) ? null : input; var out; try { out = JSON.parse(input); } catch (e) { throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "extract('CA10__lifecycleRulesJson__c').asJson().isInvalid()", currentStateMessage: "S3 Bucket Lifecycle Rules JSON is invalid.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function extract9() { if (!this.out) { this.out = obj.CA10__lifecycleRulesJson__c; } return this.out; }; function extract6() { if (!this.out) { this.out = jsonChecked7(); } return this.out; }; references1.push('Intelligent Tiering Storage, GB [obj.CA10__intelligentTieringStorageGb__c]: ' + obj.CA10__intelligentTieringStorageGb__c); references1.push('Lifecycle Rules JSON [obj.CA10__lifecycleRulesJson__c]: ' + obj.CA10__lifecycleRulesJson__c); try { if (IsEmptyLib.simpleIsEmpty(extract3.call(extract3)) && JsonLib.isEmpty(extract6.call(extract6))) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__intelligentTieringStorageGb__c').isEmpty() && extract('caJsonFrom__lifecycleRulesJson__c').isEmpty()", currentStateMessage: "The bucket does not store objects in Intelligent Tiering.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } // condition[2], conditionIndex:[200..299] function extract12() { if (!this.out) { this.out = obj.CA10__intelligentTieringStorageGb__c; } return this.out; }; function jsonQueryChecked14() { var input = extract16.call(extract16); var out; try { out = jmespath.search(input, 'length([?status==\'Enabled\'].transitions[] | [?storageClassAsString==\'INTELLIGENT_TIERING\'])'); if (out != null && typeof out != 'number') { throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "extract('caJsonFrom__lifecycleRulesJson__c').jsonQueryText('length([?status==\\'Enabled\\'].transitions[] | [?storageClassAsString==\\'INTELLIGENT_TIERING\\'])').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return a boolean.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } } catch (e) { throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extract('caJsonFrom__lifecycleRulesJson__c').jsonQueryText('length([?status==\\'Enabled\\'].transitions[] | [?storageClassAsString==\\'INTELLIGENT_TIERING\\'])').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function jsonChecked17() { var input = extract19.call(extract19); 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__lifecycleRulesJson__c').asJson().isInvalid()", currentStateMessage: "S3 Bucket Lifecycle Rules JSON is invalid.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function extract19() { if (!this.out) { this.out = obj.CA10__lifecycleRulesJson__c; } return this.out; }; function extract16() { if (!this.out) { this.out = jsonChecked17(); } return this.out; }; try { if (IsEmptyLib.simpleIsEmpty(extract12.call(extract12)) && jsonQueryChecked14() == 0.0) { return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "extract('CA10__intelligentTieringStorageGb__c').isEmpty() && extract('caJsonFrom__lifecycleRulesJson__c').jsonQueryText('length([?status==\\'Enabled\\'].transitions[] | [?storageClassAsString==\\'INTELLIGENT_TIERING\\'])') == number(0.0)", currentStateMessage: "The bucket does not store objects in Intelligent Tiering.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } // condition[3], conditionIndex:[300..399] 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:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "extract('CA10__intelligentTieringConfigurationsJson__c').asJson().isInvalid()", currentStateMessage: "S3 Bucket Policy Document JSON is invalid.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function extract25() { if (!this.out) { this.out = obj.CA10__intelligentTieringConfigurationsJson__c; } return this.out; }; function extract22() { if (!this.out) { this.out = jsonChecked23(); } return this.out; }; references1.push('Intelligent Tiering Configurations JSON [obj.CA10__intelligentTieringConfigurationsJson__c]: ' + obj.CA10__intelligentTieringConfigurationsJson__c); try { if (JsonLib.isEmpty(extract22.call(extract22))) { return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').isEmpty()", currentStateMessage: "The bucket does not have an Intelligent Tiering configuration.", currentStateReferences: references1.join('\n'), remediation: "Create an S3 Intelligent Tiering configuration for the bucket.", runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } // condition[4], conditionIndex:[400..499] function jsonQueryChecked27() { var input = extract29.call(extract29); var out; try { out = jmespath.search(input, 'length(@)'); if (out != null && typeof out != 'number') { throw new Error("UNDETERMINED condition:402", {cause: {status: 'UNDETERMINED', conditionIndex: 402, conditionText: "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').jsonQueryText('length(@)').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:403", {cause: {status: 'UNDETERMINED', conditionIndex: 403, conditionText: "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').jsonQueryText('length(@)').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function jsonChecked30() { var input = extract32.call(extract32); input = TextLib.isEmpty(input) ? null : input; var out; try { out = JSON.parse(input); } catch (e) { throw new Error("UNDETERMINED condition:401", {cause: {status: 'UNDETERMINED', conditionIndex: 401, conditionText: "extract('CA10__intelligentTieringConfigurationsJson__c').asJson().isInvalid()", currentStateMessage: "S3 Bucket Policy Document JSON is invalid.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function extract32() { if (!this.out) { this.out = obj.CA10__intelligentTieringConfigurationsJson__c; } return this.out; }; function extract29() { if (!this.out) { this.out = jsonChecked30(); } return this.out; }; try { if (jsonQueryChecked27() == 0.0) { return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').jsonQueryText('length(@)') == number(0.0)", currentStateMessage: "The bucket does not have an Intelligent Tiering configuration.", currentStateReferences: references1.join('\n'), remediation: "Create an S3 Intelligent Tiering configuration for the bucket.", runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } // condition[5], conditionIndex:[500..599] function jsonQueryChecked34() { var input = extract36.call(extract36); var out; try { out = jmespath.search(input, 'length([?status==\'Enabled\'])'); if (out != null && typeof out != 'number') { throw new Error("UNDETERMINED condition:502", {cause: {status: 'UNDETERMINED', conditionIndex: 502, conditionText: "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').jsonQueryText('length([?status==\\'Enabled\\'])').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:503", {cause: {status: 'UNDETERMINED', conditionIndex: 503, conditionText: "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').jsonQueryText('length([?status==\\'Enabled\\'])').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function jsonChecked37() { var input = extract39.call(extract39); input = TextLib.isEmpty(input) ? null : input; var out; try { out = JSON.parse(input); } catch (e) { throw new Error("UNDETERMINED condition:501", {cause: {status: 'UNDETERMINED', conditionIndex: 501, conditionText: "extract('CA10__intelligentTieringConfigurationsJson__c').asJson().isInvalid()", currentStateMessage: "S3 Bucket Policy Document JSON is invalid.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function extract39() { if (!this.out) { this.out = obj.CA10__intelligentTieringConfigurationsJson__c; } return this.out; }; function extract36() { if (!this.out) { this.out = jsonChecked37(); } return this.out; }; try { if (jsonQueryChecked34() == 0.0) { return {status: 'INCOMPLIANT', conditionIndex: 599, conditionText: "extract('caJsonFrom__intelligentTieringConfigurationsJson__c').jsonQueryText('length([?status==\\'Enabled\\'])') == number(0.0)", currentStateMessage: "The bucket Intelligent Tiering configuration is disabled.", currentStateReferences: references1.join('\n'), remediation: "Enable an S3 Intelligent Tiering configuration for the bucket.", runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } return {status: 'COMPLIANT', conditionIndex: 600, conditionText: "otherwise", currentStateMessage: "The bucket has an active Intelligent Tiering configuration.", 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.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__intelligentTieringStorageGb__c AS CA10__intelligentTieringStorageGb__c, sObject.CA10__lifecycleRulesJson__c AS CA10__lifecycleRulesJson__c, sObject.CA10__intelligentTieringConfigurationsJson__c AS CA10__intelligentTieringConfigurationsJson__c, sObject.Id AS Id, process_CA10__CaAwsBucket__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__intelligentTieringStorageGb__c AS CA10__intelligentTieringStorageGb__c, sObject.CA10__lifecycleRulesJson__c AS CA10__lifecycleRulesJson__c, sObject.CA10__intelligentTieringConfigurationsJson__c AS CA10__intelligentTieringConfigurationsJson__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsBucket__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;