--- policy: /ce/ca/aws/iam/root-account-used-recently logic: /ce/ca/aws/iam/root-account-used-recently/prod.logic.yaml executionTime: 2026-06-06T12:03:02.43576241Z generationMs: 47 executionMs: 1304 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: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 199 actual: 199 conditionText: expected: extract('CA10__userName__c') != 'root' actual: extract('CA10__userName__c') != 'root' runtimeError: {} - id: test3 match: true status: expected: UNDETERMINED actual: UNDETERMINED conditionIndex: expected: 201 actual: 201 conditionText: expected: CA10__credReportAttributesJson__c.isEmpty() actual: CA10__credReportAttributesJson__c.isEmpty() runtimeError: {} - id: test4 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 499 actual: 499 conditionText: expected: extract('CA10__credReportPasswordLastUsed__c').withinLastDays(30) actual: extract('CA10__credReportPasswordLastUsed__c').withinLastDays(30) runtimeError: {} - id: test5 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 500 actual: 500 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test6 match: true status: expected: UNDETERMINED actual: UNDETERMINED conditionIndex: expected: 201 actual: 201 conditionText: expected: CA10__credReportAttributesJson__c.isEmpty() actual: CA10__credReportAttributesJson__c.isEmpty() runtimeError: {} - id: test7 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10__credReportAccessKey1LastUsed__c').withinLastDays(30) actual: extract('CA10__credReportAccessKey1LastUsed__c').withinLastDays(30) runtimeError: {} - id: test8 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 399 actual: 399 conditionText: expected: extract('CA10__credReportAccessKey2LastUsed__c').withinLastDays(30) actual: extract('CA10__credReportAccessKey2LastUsed__c').withinLastDays(30) runtimeError: {} usedFiles: - path: /ce/ca/aws/iam/root-account-used-recently/policy.yaml md5Hash: 1A89E884095270C1805B3B1A8D012EEE content: "---\nnames:\n full: AWS Account Root User credentials were used is\ \ the last 30 days\n contextual: Root User credentials were used is the last\ \ 30 days\ndescription: >\n Ensure that the AWS root account credentials have\ \ not been used within the \n past 30 days. Minimize the usage of root account\ \ credentials to reduce the \n risk of unauthorized access or accidental changes\ \ to your AWS account.\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n - \"SECURITY\"\ \nframeworkMappings:\n - \"/frameworks/cis-aws-v7.0.0/02/07\"\n - \"/frameworks/cloudaware/identity-and-access-governance/credential-lifecycle-management\"\ \nsimilarPolicies:\n internal:\n - dec-x-e58fd8e0\n cloudConformity:\n\ \ - url: https://www.trendmicro.com/cloudoneconformity-staging/knowledge-base/aws/IAM/root-account-used-recently.html\n\ \ name: Root Account Credentials Usage\n" - path: /ce/ca/aws/iam/root-account-used-recently/prod.logic.yaml md5Hash: 25F2458A6F66C54C9C5EDE6756406D72 content: | --- inputType: CA10__CaAwsUser__c testData: - file: "test-data.json" importExtracts: - file: "/types/CA10__CaAwsUser__c/credReport.extracts.yaml" - file: "/types/CA10__CaAwsUser__c/object.extracts.yaml" conditions: - status: INAPPLICABLE currentStateMessage: "This is not a root user." check: NOT_EQUAL: left: EXTRACT: CA10__userName__c right: TEXT: root - status: INCOMPLIANT currentStateMessage: "The root user's access key was used within the last 30 days." remediationMessage: "Delete the access key for the root user." check: IS_WITHIN_LAST_DAYS: offsetDays: 30 arg: EXTRACT: CA10__credReportAccessKey1LastUsed__c - status: INCOMPLIANT currentStateMessage: "The root user's access key was used within the last 30 days." remediationMessage: "Delete the access key for the root user." check: IS_WITHIN_LAST_DAYS: offsetDays: 30 arg: EXTRACT: CA10__credReportAccessKey2LastUsed__c - status: INCOMPLIANT currentStateMessage: "The root user's password was used within the last 30 days." remediationMessage: "Avoid logging in as the root user." check: IS_WITHIN_LAST_DAYS: offsetDays: 30 arg: EXTRACT: CA10__credReportPasswordLastUsed__c otherwise: status: COMPLIANT currentStateMessage: "The root user's password has not been used within the last 30 days." - path: /ce/ca/aws/iam/root-account-used-recently/test-data.json md5Hash: 680CA632B238A20081F22987E9BD98B6 content: |- [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2024-12-06T07:21:54Z" }, "Id": "test1", "CA10__disappearanceTime__c": "2024-12-06T07:21:54Z", "CA10__userName__c": "root", "CA10__credReportAttributesJson__c": "{\"password_last_used\":\"2024-11-29T17:56:06Z\",\"access_key_1_last_used_region\":\"N/A\",\"password_enabled\":\"true\",\"access_key_1_last_used_date\":\"N/A\",\"access_key_1_last_used_service\":\"N/A\",\"mfa_active\":\"false\",\"access_key_2_last_used_date\":\"N/A\",\"user_creation_time\":\"2021-05-06T14:51:01Z\",\"cert_2_active\":\"false\",\"cert_1_active\":\"false\",\"cert_1_last_rotated\":\"N/A\",\"access_key_2_last_used_service\":\"N/A\",\"access_key_2_active\":\"false\",\"access_key_1_active\":\"false\",\"password_next_rotation\":\"not_supported\",\"access_key_2_last_rotated\":\"N/A\",\"arn\":\"arn:aws:iam::012345678910:root\",\"access_key_1_last_rotated\":\"N/A\",\"access_key_2_last_used_region\":\"N/A\",\"user\":\"root\",\"password_last_changed\":\"2021-05-06T14:55:07Z\",\"cert_2_last_rotated\":\"N/A\"}" }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "extract('CA10__userName__c') != 'root'", "runtimeError": null }, "context": { "snapshotTime": "2024-12-06T07:21:54Z" }, "Id": "test2", "CA10__disappearanceTime__c": null, "CA10__userName__c": "User", "CA10__credReportAttributesJson__c": "{\"password_last_used\":\"N/A\",\"access_key_1_last_used_region\":\"N/A\",\"password_enabled\":\"false\",\"access_key_1_last_used_date\":\"N/A\",\"access_key_1_last_used_service\":\"N/A\",\"mfa_active\":\"false\",\"access_key_2_last_used_date\":\"N/A\",\"user_creation_time\":\"2023-03-07T15:23:41Z\",\"cert_2_active\":\"false\",\"cert_1_active\":\"false\",\"cert_1_last_rotated\":\"N/A\",\"access_key_2_last_used_service\":\"N/A\",\"access_key_2_active\":\"false\",\"access_key_1_active\":\"false\",\"password_next_rotation\":\"N/A\",\"access_key_2_last_rotated\":\"N/A\",\"arn\":\"arn:aws:iam::012345678910:user/User\",\"access_key_1_last_rotated\":\"N/A\",\"access_key_2_last_used_region\":\"N/A\",\"user\":\"User\",\"password_last_changed\":\"N/A\",\"cert_2_last_rotated\":\"N/A\"}" }, { "expectedResult": { "status": "UNDETERMINED", "conditionIndex": "201", "conditionText": "CA10__credReportAttributesJson__c.isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2024-12-06T07:21:54Z" }, "Id": "test3", "CA10__disappearanceTime__c": null, "CA10__userName__c": "root", "CA10__credReportAttributesJson__c": "" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "499", "conditionText": "extract('CA10__credReportPasswordLastUsed__c').withinLastDays(30)", "runtimeError": null }, "context": { "snapshotTime": "2024-12-06T07:21:54Z" }, "Id": "test4", "CA10__disappearanceTime__c": null, "CA10__userName__c": "root", "CA10__credReportAttributesJson__c": "{\"password_last_used\":\"2024-11-29T17:56:06Z\",\"access_key_1_last_used_region\":\"N/A\",\"password_enabled\":\"true\",\"access_key_1_last_used_date\":\"N/A\",\"access_key_1_last_used_service\":\"N/A\",\"mfa_active\":\"false\",\"access_key_2_last_used_date\":\"N/A\",\"user_creation_time\":\"2021-05-06T14:51:01Z\",\"cert_2_active\":\"false\",\"cert_1_active\":\"false\",\"cert_1_last_rotated\":\"N/A\",\"access_key_2_last_used_service\":\"N/A\",\"access_key_2_active\":\"false\",\"access_key_1_active\":\"false\",\"password_next_rotation\":\"not_supported\",\"access_key_2_last_rotated\":\"N/A\",\"arn\":\"arn:aws:iam::012345678910:root\",\"access_key_1_last_rotated\":\"N/A\",\"access_key_2_last_used_region\":\"N/A\",\"user\":\"root\",\"password_last_changed\":\"2021-05-06T14:55:07Z\",\"cert_2_last_rotated\":\"N/A\"}" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "500", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2024-12-06T07:21:54Z" }, "Id": "test5", "CA10__disappearanceTime__c": null, "CA10__userName__c": "root", "CA10__credReportAttributesJson__c": "{\"password_last_used\":\"2021-10-15T16:30:24Z\",\"access_key_1_last_used_region\":\"us-east-1\",\"password_enabled\":\"true\",\"access_key_1_last_used_date\":\"2020-02-27T12:03:00Z\",\"access_key_1_last_used_service\":\"s3\",\"mfa_active\":\"false\",\"access_key_2_last_used_date\":\"N/A\",\"user_creation_time\":\"2008-06-17T18:41:41Z\",\"cert_2_active\":\"false\",\"cert_1_active\":\"true\",\"cert_1_last_rotated\":\"2011-04-27T13:23:57Z\",\"access_key_2_last_used_service\":\"N/A\",\"access_key_2_active\":\"false\",\"access_key_1_active\":\"false\",\"password_next_rotation\":\"not_supported\",\"access_key_2_last_rotated\":\"2014-07-03T15:12:24Z\",\"arn\":\"arn:aws:iam::012345678910:root\",\"access_key_1_last_rotated\":\"2011-04-27T13:20:07Z\",\"access_key_2_last_used_region\":\"N/A\",\"user\":\"root\",\"password_last_changed\":\"2023-02-07T18:24:40Z\",\"cert_2_last_rotated\":\"N/A\"}" }, { "expectedResult": { "status": "UNDETERMINED", "conditionIndex": "201", "conditionText": "CA10__credReportAttributesJson__c.isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2024-12-06T07:21:54Z" }, "Id": "test6", "CA10__disappearanceTime__c": null, "CA10__userName__c": "root", "CA10__credReportAttributesJson__c": null }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "299", "conditionText": "extract('CA10__credReportAccessKey1LastUsed__c').withinLastDays(30)", "runtimeError": null }, "context": { "snapshotTime": "2024-12-06T07:21:54Z" }, "Id": "test7", "CA10__disappearanceTime__c": null, "CA10__userName__c": "root", "CA10__credReportAttributesJson__c": "{\"password_last_used\":\"2021-11-29T17:56:06Z\",\"access_key_1_last_used_region\":\"N/A\",\"password_enabled\":\"true\",\"access_key_1_last_used_date\":\"2024-11-29T17:56:06Z\",\"access_key_1_last_used_service\":\"N/A\",\"mfa_active\":\"false\",\"access_key_2_last_used_date\":\"N/A\",\"user_creation_time\":\"2021-05-06T14:51:01Z\",\"cert_2_active\":\"false\",\"cert_1_active\":\"false\",\"cert_1_last_rotated\":\"N/A\",\"access_key_2_last_used_service\":\"N/A\",\"access_key_2_active\":\"false\",\"access_key_1_active\":\"false\",\"password_next_rotation\":\"not_supported\",\"access_key_2_last_rotated\":\"N/A\",\"arn\":\"arn:aws:iam::012345678910:root\",\"access_key_1_last_rotated\":\"N/A\",\"access_key_2_last_used_region\":\"N/A\",\"user\":\"root\",\"password_last_changed\":\"2021-05-06T14:55:07Z\",\"cert_2_last_rotated\":\"N/A\"}" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "399", "conditionText": "extract('CA10__credReportAccessKey2LastUsed__c').withinLastDays(30)", "runtimeError": null }, "context": { "snapshotTime": "2024-12-06T07:21:54Z" }, "Id": "test8", "CA10__disappearanceTime__c": null, "CA10__userName__c": "root", "CA10__credReportAttributesJson__c": "{\"password_last_used\":\"2021-11-29T17:56:06Z\",\"access_key_1_last_used_region\":\"N/A\",\"password_enabled\":\"true\",\"access_key_1_last_used_date\":\"N/A\",\"access_key_1_last_used_service\":\"N/A\",\"mfa_active\":\"false\",\"access_key_2_last_used_date\":\"2024-11-29T17:56:06Z\",\"user_creation_time\":\"2021-05-06T14:51:01Z\",\"cert_2_active\":\"false\",\"cert_1_active\":\"false\",\"cert_1_last_rotated\":\"N/A\",\"access_key_2_last_used_service\":\"N/A\",\"access_key_2_active\":\"false\",\"access_key_1_active\":\"false\",\"password_next_rotation\":\"not_supported\",\"access_key_2_last_rotated\":\"N/A\",\"arn\":\"arn:aws:iam::012345678910:root\",\"access_key_1_last_rotated\":\"N/A\",\"access_key_2_last_used_region\":\"N/A\",\"user\":\"root\",\"password_last_changed\":\"2021-05-06T14:55:07Z\",\"cert_2_last_rotated\":\"N/A\"}" } ] - path: /types/CA10__CaAwsUser__c/credReport.extracts.yaml md5Hash: F6D383D933A0B64268B39ADE7012508C content: "\n# password_last_used: 2021-10-15T16:30:24+00:00\n# access_key_1_last_used_region:\ \ us-east-1\n# password_enabled: not_supported\n# access_key_1_last_used_date:\ \ 2020-02-27T12:03:00+00:00\n# access_key_1_last_used_service: s3\n# mfa_active:\ \ false\n# access_key_2_last_used_date: N/A\n# user_creation_time: 2008-06-17T18:41:41+00:00\n\ # cert_2_active: false\n# cert_1_active: true\n# cert_1_last_rotated: 2011-04-27T13:23:57+00:00\n\ # access_key_2_last_used_service: N/A\n# access_key_2_active: false\n# access_key_1_active:\ \ false\n# password_next_rotation: not_supported\n# access_key_2_last_rotated:\ \ 2014-07-03T15:12:24+00:00\n# arn: arn:aws:iam::814021343637:root\n# access_key_1_last_rotated:\ \ 2011-04-27T13:20:07+00:00\n# access_key_2_last_used_region: N/A\n# user: \n\ # password_last_changed: not_supported\n# cert_2_last_rotated: N/A\n---\nextracts:\n\ \ - name: CA10__credReportAttributesJson__c\n value: \n JSON_FROM:\n\ \ arg:\n FIELD:\n path: CA10__credReportAttributesJson__c\n\ \ returnType: BYTES\n undeterminedIf:\n isEmpty:\ \ Credential report attributes are empty, this is either permission issue or\ \ the data haven't been populated yet\n undeterminedIf:\n isInvalid:\ \ \"Cred report attributes JSON is invalid\"\n - name: CA10__credReportAccessKey1Active__c\n\ \ value:\n BOOLEAN_FROM:\n arg:\n JSON_QUERY_TEXT:\n\ \ arg:\n EXTRACT: CA10__credReportAttributesJson__c\n\ \ expression: \"to_string(access_key_1_active)\"\n undeterminedIf:\n\ \ evaluationError: \"The JSON query has failed.\"\n \ \ resultTypeMismatch: \"The JSON query did not return text type.\"\n \ \ undeterminedIf:\n isEmpty: Value of 'access_key_1_active' is empty,\ \ unexpected data\n - name: CA10__credReportAccessKey2Active__c\n value:\n\ \ BOOLEAN_FROM:\n arg:\n JSON_QUERY_TEXT:\n \ \ arg:\n EXTRACT: CA10__credReportAttributesJson__c\n \ \ expression: \"to_string(access_key_2_active)\"\n undeterminedIf:\n\ \ evaluationError: \"The JSON query has failed.\"\n \ \ resultTypeMismatch: \"The JSON query did not return text type.\"\n \ \ undeterminedIf:\n isEmpty: Value of 'access_key_1_active' is empty,\ \ unexpected data\n - name: CA10__credReportPasswordLastUsed__c\n value:\n\ \ DATE_TIME_FROM:\n arg:\n JSON_QUERY_TEXT:\n \ \ arg:\n EXTRACT: CA10__credReportAttributesJson__c\n \ \ expression: \"to_string(password_last_used)\"\n undeterminedIf:\n\ \ evaluationError: \"The JSON query has failed.\"\n \ \ resultTypeMismatch: \"The JSON query did not return text type.\"\n \ \ nullValues:\n - \"no_information\"\n - \"N/A\"\n \ \ format: ISO_8601\n undeterminedIf:\n # value CAN be empty,\ \ for example when password was never used.\n #isEmpty: Value of 'password_last_used'\ \ is empty, unexpected data\n invalidFormat: Value of 'password_last_used'\ \ does not match ISO-8601 format\n - name: CA10__credReportAccessKey1LastUsed__c\n\ \ value:\n DATE_TIME_FROM:\n arg:\n JSON_QUERY_TEXT:\n\ \ arg:\n EXTRACT: CA10__credReportAttributesJson__c\n\ \ expression: \"to_string(access_key_1_last_used_date)\"\n \ \ undeterminedIf:\n evaluationError: \"The JSON query has\ \ failed.\"\n resultTypeMismatch: \"The JSON query did not return\ \ text type.\"\n nullValues:\n - \"N/A\"\n format: ISO_8601\n\ \ undeterminedIf:\n # value CAN be empty, for example when password\ \ was never used.\n #isEmpty: Value of 'access_key_1_last_used_date'\ \ is empty, unexpected data\n invalidFormat: Value of 'access_key_1_last_used_date'\ \ does not match ISO-8601 format\n - name: CA10__credReportAccessKey2LastUsed__c\n\ \ value:\n DATE_TIME_FROM:\n arg:\n JSON_QUERY_TEXT:\n\ \ arg:\n EXTRACT: CA10__credReportAttributesJson__c\n\ \ expression: \"to_string(access_key_2_last_used_date)\"\n \ \ undeterminedIf:\n evaluationError: \"The JSON query has\ \ failed.\"\n resultTypeMismatch: \"The JSON query did not return\ \ text type.\"\n nullValues:\n - \"N/A\"\n format: ISO_8601\n\ \ undeterminedIf:\n # value CAN be empty, for example when password\ \ was never used.\n #isEmpty: Value of 'access_key_2_last_used_date'\ \ is empty, unexpected data\n invalidFormat: Value of 'access_key_2_last_used_date'\ \ does not match ISO-8601 format\n - name: CA10__credReportMfaActive__c\n \ \ value:\n BOOLEAN_FROM:\n arg:\n JSON_QUERY_TEXT:\n\ \ arg:\n EXTRACT: CA10__credReportAttributesJson__c\n\ \ expression: \"to_string(mfa_active)\"\n undeterminedIf:\n\ \ evaluationError: \"The JSON query has failed.\"\n \ \ resultTypeMismatch: \"The JSON query did not return text type.\"\n \ \ undeterminedIf:\n isEmpty: Credential report 'mfa_active' key is\ \ empty, unexpected data\n - name: CA10__credReportPasswordEnabled__c\n \ \ value:\n BOOLEAN_FROM:\n arg:\n JSON_QUERY_TEXT:\n \ \ arg:\n EXTRACT: CA10__credReportAttributesJson__c\n\ \ expression: \"to_string(password_enabled)\"\n undeterminedIf:\n\ \ evaluationError: \"The JSON query has failed.\"\n \ \ resultTypeMismatch: \"The JSON query did not return text type.\"\n \ \ undeterminedIf:\n isEmpty: Value of 'password_enabled' is empty,\ \ unexpected data\n - name: CA10__credReportPasswordLastChanged__c\n value:\n\ \ DATE_TIME_FROM:\n arg:\n JSON_QUERY_TEXT:\n \ \ arg:\n EXTRACT: CA10__credReportAttributesJson__c\n \ \ expression: \"to_string(password_last_changed)\"\n undeterminedIf:\n\ \ evaluationError: \"The JSON query has failed.\"\n \ \ resultTypeMismatch: \"The JSON query did not return text type.\"\n \ \ nullValues:\n - \"N/A\"\n format: ISO_8601\n undeterminedIf:\n\ \ # value CAN be empty, for example when password was never changed.\n\ \ #isEmpty: Value of 'password_last_changed' is empty, unexpected data\n\ \ invalidFormat: Value of 'password_last_changed' does not match ISO-8601\ \ format\n - name: CA10__credReportAccessKey1LastRotated__c\n value:\n \ \ DATE_TIME_FROM:\n arg:\n JSON_QUERY_TEXT:\n \ \ arg:\n EXTRACT: CA10__credReportAttributesJson__c\n \ \ expression: \"to_string(access_key_1_last_rotated)\"\n undeterminedIf:\n\ \ evaluationError: \"The JSON query has failed.\"\n \ \ resultTypeMismatch: \"The JSON query did not return text type.\"\n \ \ nullValues:\n - \"N/A\"\n format: ISO_8601\n undeterminedIf:\n\ \ # value CAN be empty, for example when key was never changed.\n \ \ #isEmpty: Value of 'access_key_1_last_rotated' is empty, unexpected\ \ data\n invalidFormat: Value of 'access_key_1_last_rotated' does not\ \ match ISO-8601 format\n - name: CA10__credReportAccessKey2LastRotated__c\n\ \ value:\n DATE_TIME_FROM:\n arg:\n JSON_QUERY_TEXT:\n\ \ arg:\n EXTRACT: CA10__credReportAttributesJson__c\n\ \ expression: \"to_string(access_key_2_last_rotated)\"\n \ \ undeterminedIf:\n evaluationError: \"The JSON query has failed.\"\ \n resultTypeMismatch: \"The JSON query did not return text type.\"\ \n nullValues:\n - \"N/A\"\n format: ISO_8601\n \ \ undeterminedIf:\n # value CAN be empty, for example when key\ \ was never changed.\n #isEmpty: Value of 'access_key_2_last_rotated'\ \ is empty, unexpected data\n invalidFormat: Value of 'access_key_2_last_rotated'\ \ does not match ISO-8601 format\n - name: CA10__credReportCert1Active__c\n\ \ value:\n BOOLEAN_FROM:\n arg:\n JSON_QUERY_TEXT:\n\ \ arg:\n EXTRACT: CA10__credReportAttributesJson__c\n\ \ expression: \"to_string(cert_1_active)\"\n undeterminedIf:\n\ \ evaluationError: \"The JSON query has failed.\"\n \ \ resultTypeMismatch: \"The JSON query did not return text type.\"\n \ \ undeterminedIf:\n isEmpty: Value of 'cert_1_active' is empty, unexpected\ \ data\n - name: CA10__credReportCert2Active__c\n value:\n BOOLEAN_FROM:\n\ \ arg:\n JSON_QUERY_TEXT:\n arg:\n EXTRACT:\ \ CA10__credReportAttributesJson__c\n expression: \"to_string(cert_2_active)\"\ \n undeterminedIf:\n evaluationError: \"The JSON query\ \ has failed.\"\n resultTypeMismatch: \"The JSON query did not\ \ return text type.\"\n undeterminedIf:\n isEmpty: Value of\ \ 'cert_1_active' is empty, unexpected data" - path: /types/CA10__CaAwsUser__c/object.extracts.yaml md5Hash: 131CCD980BE5290B2C296CE093A686DC content: "---\nextracts:\n - name: CA10__mfaDeviceType__c\n # Acceptable values\ \ are: null, \"Hardware\", \"Virtual\"\n value:\n FIELD: \n path:\ \ CA10__mfaDeviceType__c\n undeterminedIf:\n noAccessDelegate:\n\ \ path: CA10__virtualMfaState__c\n currentStateMessage:\ \ Possible access issue with iam:GetAccountSummary, iam:ListVirtualMFADevices\ \ or iam:ListMFADevices\n# Not Nullable. Can't have no access, retrieved via\ \ iam:ListUsers\n - name: \"CA10__userName__c\"\n value:\n FIELD:\n\ \ path: \"CA10__userName__c\"\n - name: \"CA10__accessKeysCount__c\"\ \n value:\n FIELD:\n path: \"CA10__accessKeysCount__c\"\n# Not\ \ nullable\n - name: \"CA10__createDate__c\"\n value:\n FIELD:\n \ \ path: \"CA10__createDate__c\"\n" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test1", "expectedResult" : { "status" : "DISAPPEARED", "conditionIndex" : "99", "conditionText" : "isDisappeared(CA10__disappearanceTime__c)", "runtimeError" : null } }, { "Id" : "test2", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "199", "conditionText" : "extract('CA10__userName__c') != 'root'", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "UNDETERMINED", "conditionIndex" : "201", "conditionText" : "CA10__credReportAttributesJson__c.isEmpty()", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "499", "conditionText" : "extract('CA10__credReportPasswordLastUsed__c').withinLastDays(30)", "runtimeError" : null } }, { "Id" : "test5", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "500", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test6", "expectedResult" : { "status" : "UNDETERMINED", "conditionIndex" : "201", "conditionText" : "CA10__credReportAttributesJson__c.isEmpty()", "runtimeError" : null } }, { "Id" : "test7", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "299", "conditionText" : "extract('CA10__credReportAccessKey1LastUsed__c').withinLastDays(30)", "runtimeError" : null } }, { "Id" : "test8", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "399", "conditionText" : "extract('CA10__credReportAccessKey2LastUsed__c').withinLastDays(30)", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsUser__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2024-12-06T07:21:54Z") }, "CA10__disappearanceTime__c" : new Date("2024-12-06T07:21:54Z"), "CA10__userName__c" : "root", "CA10__credReportAttributesJson__c" : "{\"password_last_used\":\"2024-11-29T17:56:06Z\",\"access_key_1_last_used_region\":\"N/A\",\"password_enabled\":\"true\",\"access_key_1_last_used_date\":\"N/A\",\"access_key_1_last_used_service\":\"N/A\",\"mfa_active\":\"false\",\"access_key_2_last_used_date\":\"N/A\",\"user_creation_time\":\"2021-05-06T14:51:01Z\",\"cert_2_active\":\"false\",\"cert_1_active\":\"false\",\"cert_1_last_rotated\":\"N/A\",\"access_key_2_last_used_service\":\"N/A\",\"access_key_2_active\":\"false\",\"access_key_1_active\":\"false\",\"password_next_rotation\":\"not_supported\",\"access_key_2_last_rotated\":\"N/A\",\"arn\":\"arn:aws:iam::012345678910:root\",\"access_key_1_last_rotated\":\"N/A\",\"access_key_2_last_used_region\":\"N/A\",\"user\":\"root\",\"password_last_changed\":\"2021-05-06T14:55:07Z\",\"cert_2_last_rotated\":\"N/A\"}", "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2024-12-06T07:21:54Z") }, "CA10__userName__c" : "User", "CA10__credReportAttributesJson__c" : "{\"password_last_used\":\"N/A\",\"access_key_1_last_used_region\":\"N/A\",\"password_enabled\":\"false\",\"access_key_1_last_used_date\":\"N/A\",\"access_key_1_last_used_service\":\"N/A\",\"mfa_active\":\"false\",\"access_key_2_last_used_date\":\"N/A\",\"user_creation_time\":\"2023-03-07T15:23:41Z\",\"cert_2_active\":\"false\",\"cert_1_active\":\"false\",\"cert_1_last_rotated\":\"N/A\",\"access_key_2_last_used_service\":\"N/A\",\"access_key_2_active\":\"false\",\"access_key_1_active\":\"false\",\"password_next_rotation\":\"N/A\",\"access_key_2_last_rotated\":\"N/A\",\"arn\":\"arn:aws:iam::012345678910:user/User\",\"access_key_1_last_rotated\":\"N/A\",\"access_key_2_last_used_region\":\"N/A\",\"user\":\"User\",\"password_last_changed\":\"N/A\",\"cert_2_last_rotated\":\"N/A\"}", "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2024-12-06T07:21:54Z") }, "CA10__userName__c" : "root", "CA10__credReportAttributesJson__c" : "", "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2024-12-06T07:21:54Z") }, "CA10__userName__c" : "root", "CA10__credReportAttributesJson__c" : "{\"password_last_used\":\"2024-11-29T17:56:06Z\",\"access_key_1_last_used_region\":\"N/A\",\"password_enabled\":\"true\",\"access_key_1_last_used_date\":\"N/A\",\"access_key_1_last_used_service\":\"N/A\",\"mfa_active\":\"false\",\"access_key_2_last_used_date\":\"N/A\",\"user_creation_time\":\"2021-05-06T14:51:01Z\",\"cert_2_active\":\"false\",\"cert_1_active\":\"false\",\"cert_1_last_rotated\":\"N/A\",\"access_key_2_last_used_service\":\"N/A\",\"access_key_2_active\":\"false\",\"access_key_1_active\":\"false\",\"password_next_rotation\":\"not_supported\",\"access_key_2_last_rotated\":\"N/A\",\"arn\":\"arn:aws:iam::012345678910:root\",\"access_key_1_last_rotated\":\"N/A\",\"access_key_2_last_used_region\":\"N/A\",\"user\":\"root\",\"password_last_changed\":\"2021-05-06T14:55:07Z\",\"cert_2_last_rotated\":\"N/A\"}", "Id" : "test4" }, { "context" : { "snapshotTime" : new Date("2024-12-06T07:21:54Z") }, "CA10__userName__c" : "root", "CA10__credReportAttributesJson__c" : "{\"password_last_used\":\"2021-10-15T16:30:24Z\",\"access_key_1_last_used_region\":\"us-east-1\",\"password_enabled\":\"true\",\"access_key_1_last_used_date\":\"2020-02-27T12:03:00Z\",\"access_key_1_last_used_service\":\"s3\",\"mfa_active\":\"false\",\"access_key_2_last_used_date\":\"N/A\",\"user_creation_time\":\"2008-06-17T18:41:41Z\",\"cert_2_active\":\"false\",\"cert_1_active\":\"true\",\"cert_1_last_rotated\":\"2011-04-27T13:23:57Z\",\"access_key_2_last_used_service\":\"N/A\",\"access_key_2_active\":\"false\",\"access_key_1_active\":\"false\",\"password_next_rotation\":\"not_supported\",\"access_key_2_last_rotated\":\"2014-07-03T15:12:24Z\",\"arn\":\"arn:aws:iam::012345678910:root\",\"access_key_1_last_rotated\":\"2011-04-27T13:20:07Z\",\"access_key_2_last_used_region\":\"N/A\",\"user\":\"root\",\"password_last_changed\":\"2023-02-07T18:24:40Z\",\"cert_2_last_rotated\":\"N/A\"}", "Id" : "test5" }, { "context" : { "snapshotTime" : new Date("2024-12-06T07:21:54Z") }, "CA10__userName__c" : "root", "CA10__credReportAttributesJson__c" : null, "Id" : "test6" }, { "context" : { "snapshotTime" : new Date("2024-12-06T07:21:54Z") }, "CA10__userName__c" : "root", "CA10__credReportAttributesJson__c" : "{\"password_last_used\":\"2021-11-29T17:56:06Z\",\"access_key_1_last_used_region\":\"N/A\",\"password_enabled\":\"true\",\"access_key_1_last_used_date\":\"2024-11-29T17:56:06Z\",\"access_key_1_last_used_service\":\"N/A\",\"mfa_active\":\"false\",\"access_key_2_last_used_date\":\"N/A\",\"user_creation_time\":\"2021-05-06T14:51:01Z\",\"cert_2_active\":\"false\",\"cert_1_active\":\"false\",\"cert_1_last_rotated\":\"N/A\",\"access_key_2_last_used_service\":\"N/A\",\"access_key_2_active\":\"false\",\"access_key_1_active\":\"false\",\"password_next_rotation\":\"not_supported\",\"access_key_2_last_rotated\":\"N/A\",\"arn\":\"arn:aws:iam::012345678910:root\",\"access_key_1_last_rotated\":\"N/A\",\"access_key_2_last_used_region\":\"N/A\",\"user\":\"root\",\"password_last_changed\":\"2021-05-06T14:55:07Z\",\"cert_2_last_rotated\":\"N/A\"}", "Id" : "test7" }, { "context" : { "snapshotTime" : new Date("2024-12-06T07:21:54Z") }, "CA10__userName__c" : "root", "CA10__credReportAttributesJson__c" : "{\"password_last_used\":\"2021-11-29T17:56:06Z\",\"access_key_1_last_used_region\":\"N/A\",\"password_enabled\":\"true\",\"access_key_1_last_used_date\":\"N/A\",\"access_key_1_last_used_service\":\"N/A\",\"mfa_active\":\"false\",\"access_key_2_last_used_date\":\"2024-11-29T17:56:06Z\",\"user_creation_time\":\"2021-05-06T14:51:01Z\",\"cert_2_active\":\"false\",\"cert_1_active\":\"false\",\"cert_1_last_rotated\":\"N/A\",\"access_key_2_last_used_service\":\"N/A\",\"access_key_2_active\":\"false\",\"access_key_1_active\":\"false\",\"password_next_rotation\":\"not_supported\",\"access_key_2_last_rotated\":\"N/A\",\"arn\":\"arn:aws:iam::012345678910:root\",\"access_key_1_last_rotated\":\"N/A\",\"access_key_2_last_used_region\":\"N/A\",\"user\":\"root\",\"password_last_changed\":\"2021-05-06T14:55:07Z\",\"cert_2_last_rotated\":\"N/A\"}", "Id" : "test8" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsUser__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__userName__c STRING, CA10__credReportAttributesJson__c STRING, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js OPTIONS (library=['gs://compliance-platform-public/jmespath.min.js']) AS r""" var TemporalLib = new function () { var iso8601regex = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/ this.checkIso8601 = function(arg) { return arg == null || iso8601regex.test(arg); }; this.parseIso8601 = function(arg) { return arg == null ? null: new Date(arg); }; this.replaceNullValues = function(arg, nullValues) { for (var i = 0; i < nullValues.length; i++) { if (TextLib.equal(arg, nullValues[i])) { return null; } } return arg; }; }(); var BytesLib = new function () { this.normalize = function(arg) { return arg == null ? '' : arg; }; 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 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 todayMinus30Day = new Date(snapshotTime.toISOString().substr(0,10)+'T00:00:00.000Z').getTime() + (-30 * 86400000); var todayPlus1Day = new Date(snapshotTime.toISOString().substr(0,10)+'T00:00:00.000Z').getTime() + (1 * 86400000); 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__userName__c; } return this.out; }; references1.push('User Name [obj.CA10__userName__c]: ' + obj.CA10__userName__c); if (TextLib.notEqual(extract3.call(extract3), 'root')) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__userName__c') != 'root'", currentStateMessage: "This is not a root user.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function dateChecked7() { var dateTimeFrom8 = jsonQueryChecked9(); dateTimeFrom8 = TemporalLib.replaceNullValues(dateTimeFrom8, ['N/A']); if (!TemporalLib.checkIso8601(dateTimeFrom8)) { throw new Error("UNDETERMINED condition:205", {cause: {status: 'UNDETERMINED', conditionIndex: 205, conditionText: "extract('CA10__credReportAttributesJson__c').jsonQueryText('to_string(access_key_1_last_used_date)').checkIso8601()", currentStateMessage: "Value of 'access_key_1_last_used_date' does not match ISO-8601 format", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return TemporalLib.parseIso8601(dateTimeFrom8); } function jsonQueryChecked9() { var input = extract11.call(extract11); var out; try { out = jmespath.search(input, 'to_string(access_key_1_last_used_date)'); if (out != null && typeof out != 'string') { throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extract('CA10__credReportAttributesJson__c').jsonQueryText('to_string(access_key_1_last_used_date)').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('CA10__credReportAttributesJson__c').jsonQueryText('to_string(access_key_1_last_used_date)').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function jsonChecked12() { var input = fieldChecked13(); 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: "CA10__credReportAttributesJson__c.asJson().isInvalid()", currentStateMessage: "Cred report attributes JSON is invalid", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function fieldChecked13() { if (BytesLib.isEmpty(obj.CA10__credReportAttributesJson__c)) { throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__credReportAttributesJson__c.isEmpty()", currentStateMessage: "Credential report attributes are empty, this is either permission issue or the data haven't been populated yet", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10__credReportAttributesJson__c; } function extract11() { if (!this.out) { this.out = jsonChecked12(); } return this.out; }; function extract6() { if (!this.out) { this.out = dateChecked7(); } return this.out; }; references1.push('Cred Report: Attributes JSON [obj.CA10__credReportAttributesJson__c]: ' + obj.CA10__credReportAttributesJson__c); try { if (extract6.call(extract6) != null && extract6.call(extract6).getTime() >= todayMinus30Day && extract6.call(extract6).getTime() < todayPlus1Day) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__credReportAccessKey1LastUsed__c').withinLastDays(30)", currentStateMessage: "The root user's access key was used within the last 30 days.", currentStateReferences: references1.join('\n'), remediation: "Delete the access key for the root user.", runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } // condition[3], conditionIndex:[300..399] function dateChecked17() { var dateTimeFrom18 = jsonQueryChecked19(); dateTimeFrom18 = TemporalLib.replaceNullValues(dateTimeFrom18, ['N/A']); if (!TemporalLib.checkIso8601(dateTimeFrom18)) { throw new Error("UNDETERMINED condition:305", {cause: {status: 'UNDETERMINED', conditionIndex: 305, conditionText: "extract('CA10__credReportAttributesJson__c').jsonQueryText('to_string(access_key_2_last_used_date)').checkIso8601()", currentStateMessage: "Value of 'access_key_2_last_used_date' does not match ISO-8601 format", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return TemporalLib.parseIso8601(dateTimeFrom18); } function jsonQueryChecked19() { var input = extract21.call(extract21); var out; try { out = jmespath.search(input, 'to_string(access_key_2_last_used_date)'); if (out != null && typeof out != 'string') { throw new Error("UNDETERMINED condition:303", {cause: {status: 'UNDETERMINED', conditionIndex: 303, conditionText: "extract('CA10__credReportAttributesJson__c').jsonQueryText('to_string(access_key_2_last_used_date)').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('CA10__credReportAttributesJson__c').jsonQueryText('to_string(access_key_2_last_used_date)').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function jsonChecked22() { var input = fieldChecked23(); 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: "CA10__credReportAttributesJson__c.asJson().isInvalid()", currentStateMessage: "Cred report attributes JSON is invalid", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function fieldChecked23() { if (BytesLib.isEmpty(obj.CA10__credReportAttributesJson__c)) { throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "CA10__credReportAttributesJson__c.isEmpty()", currentStateMessage: "Credential report attributes are empty, this is either permission issue or the data haven't been populated yet", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10__credReportAttributesJson__c; } function extract21() { if (!this.out) { this.out = jsonChecked22(); } return this.out; }; function extract16() { if (!this.out) { this.out = dateChecked17(); } return this.out; }; try { if (extract16.call(extract16) != null && extract16.call(extract16).getTime() >= todayMinus30Day && extract16.call(extract16).getTime() < todayPlus1Day) { return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__credReportAccessKey2LastUsed__c').withinLastDays(30)", currentStateMessage: "The root user's access key was used within the last 30 days.", currentStateReferences: references1.join('\n'), remediation: "Delete the access key for the root user.", runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } // condition[4], conditionIndex:[400..499] function dateChecked27() { var dateTimeFrom28 = jsonQueryChecked29(); dateTimeFrom28 = TemporalLib.replaceNullValues(dateTimeFrom28, ['no_information', 'N/A']); if (!TemporalLib.checkIso8601(dateTimeFrom28)) { throw new Error("UNDETERMINED condition:405", {cause: {status: 'UNDETERMINED', conditionIndex: 405, conditionText: "extract('CA10__credReportAttributesJson__c').jsonQueryText('to_string(password_last_used)').checkIso8601()", currentStateMessage: "Value of 'password_last_used' does not match ISO-8601 format", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return TemporalLib.parseIso8601(dateTimeFrom28); } function jsonQueryChecked29() { var input = extract31.call(extract31); var out; try { out = jmespath.search(input, 'to_string(password_last_used)'); if (out != null && typeof out != 'string') { throw new Error("UNDETERMINED condition:403", {cause: {status: 'UNDETERMINED', conditionIndex: 403, conditionText: "extract('CA10__credReportAttributesJson__c').jsonQueryText('to_string(password_last_used)').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('CA10__credReportAttributesJson__c').jsonQueryText('to_string(password_last_used)').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function jsonChecked32() { var input = fieldChecked33(); 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: "CA10__credReportAttributesJson__c.asJson().isInvalid()", currentStateMessage: "Cred report attributes JSON is invalid", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function fieldChecked33() { if (BytesLib.isEmpty(obj.CA10__credReportAttributesJson__c)) { throw new Error("UNDETERMINED condition:401", {cause: {status: 'UNDETERMINED', conditionIndex: 401, conditionText: "CA10__credReportAttributesJson__c.isEmpty()", currentStateMessage: "Credential report attributes are empty, this is either permission issue or the data haven't been populated yet", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10__credReportAttributesJson__c; } function extract31() { if (!this.out) { this.out = jsonChecked32(); } return this.out; }; function extract26() { if (!this.out) { this.out = dateChecked27(); } return this.out; }; try { if (extract26.call(extract26) != null && extract26.call(extract26).getTime() >= todayMinus30Day && extract26.call(extract26).getTime() < todayPlus1Day) { return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "extract('CA10__credReportPasswordLastUsed__c').withinLastDays(30)", currentStateMessage: "The root user's password was used within the last 30 days.", currentStateReferences: references1.join('\n'), remediation: "Avoid logging in as the root user.", runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } return {status: 'COMPLIANT', conditionIndex: 500, conditionText: "otherwise", currentStateMessage: "The root user's password has not been used within the last 30 days.", 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__userName__c AS CA10__userName__c, sObject.CA10__credReportAttributesJson__c AS CA10__credReportAttributesJson__c, sObject.Id AS Id, process_CA10__CaAwsUser__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__userName__c AS CA10__userName__c, sObject.CA10__credReportAttributesJson__c AS CA10__credReportAttributesJson__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsUser__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;