--- policy: /ce/ca/aws/account/password-policy-number-of-passwords-to-remember-24 logic: /ce/ca/aws/account/password-policy-number-of-passwords-to-remember-24/prod.logic.yaml executionTime: 2026-06-06T12:02:26.685674342Z generationMs: 63 executionMs: 1106 rows: - id: a01 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: CA10__AWS_IAM_Password_Policies__r.has(COMPLIANT) actual: CA10__AWS_IAM_Password_Policies__r.has(COMPLIANT) runtimeError: {} - id: a02 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: CA10__AWS_IAM_Password_Policies__r.has(INCOMPLIANT) actual: CA10__AWS_IAM_Password_Policies__r.has(INCOMPLIANT) runtimeError: {} - id: a03 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 300 actual: 300 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/aws/account/password-policy-number-of-passwords-to-remember-24/policy.yaml md5Hash: 78299D096DA4A4CA5B54CE4762AB4F27 content: | --- names: full: "AWS Account IAM Password Policy Number of passwords to remember is not set to 24" contextual: "IAM Password Policy Number of passwords to remember is not set to 24" description: "IAM password policies can prevent the reuse of a given password by \ the same user. It is recommended that the password policy prevent the reuse of passwords." type: "COMPLIANCE_POLICY" categories: - "SECURITY" frameworkMappings: - "/frameworks/cis-aws-v7.0.0/02/09" - "/frameworks/cloudaware/identity-and-access-governance/credential-lifecycle-management" - "/frameworks/aws-fsbp-v1.0.0/iam/07" similarPolicies: internal: - dec-x-f7c2faac cloudConformity: # One policy for 1.8 and 1.9. Checks are combined into one policy - url: "https://www.trendmicro.com/cloudoneconformity-staging/knowledge-base/aws/IAM/password-policy.html" name: "IAM Password Policy" - path: /ce/ca/aws/account/password-policy-number-of-passwords-to-remember-24/prod.logic.yaml md5Hash: 4F41FF95757BFE65C86364BD6FDF88AC content: | --- inputType: "CA10__CaAwsAccount__c" testData: - file: test-data.json conditions: - status: "COMPLIANT" currentStateMessage: "The number of passwords to remember is set to at least 24." check: RELATED_LIST_HAS: relationshipName: "CA10__AWS_IAM_Password_Policies__r" status: "COMPLIANT" - status: "INCOMPLIANT" currentStateMessage: "The number of passwords to remember is not set to at least 24." remediationMessage: "Set the number of passwords to remember to 24 or more." check: RELATED_LIST_HAS: relationshipName: "CA10__AWS_IAM_Password_Policies__r" status: "INCOMPLIANT" otherwise: status: "INCOMPLIANT" currentStateMessage: "The AWS account password policy does not exist." relatedLists: - relationshipName: "CA10__AWS_IAM_Password_Policies__r" importExtracts: - file: /types/CA10__CaAwsPasswordPolicy__c/object.extracts.yaml conditions: - status: "INCOMPLIANT" currentStateMessage: "The password policy does not have 'Number of passwords to remember' set to at least 24." remediationMessage: "Set 'Number of passwords to remember' to 24 or more." check: LESS_THAN: left: EXTRACT: "CA10__passwordReusePrevention__c" right: NUMBER: 24.0 - status: "COMPLIANT" currentStateMessage: "The password policy has 'Number of passwords to remember' set to at least 24." check: GREATER_THAN_EQUAL: left: EXTRACT: "CA10__passwordReusePrevention__c" right: NUMBER: 24.0 otherwise: status: "UNDETERMINED" currentStateMessage: "Unexpected value in the field." - path: /ce/ca/aws/account/password-policy-number-of-passwords-to-remember-24/test-data.json md5Hash: 25BB5521D4542C8238D6A3CEDA81A189 content: | [ { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "199", "conditionText": "CA10__AWS_IAM_Password_Policies__r.has(COMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2024-06-09T19:33:20Z" }, "Id": "a01", "CA10__AWS_IAM_Password_Policies__r": [ { "Id": "a31", "CA10__disappearanceTime__c": null, "CA10__passwordReusePrevention__c": 24, "CA10__account__c": "a01" } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "299", "conditionText": "CA10__AWS_IAM_Password_Policies__r.has(INCOMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2024-06-09T19:33:20Z" }, "Id": "a02", "CA10__AWS_IAM_Password_Policies__r": [ { "Id": "a32", "CA10__disappearanceTime__c": null, "CA10__passwordReusePrevention__c": 20, "CA10__account__c": "a02" } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "300", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2024-06-09T19:33:20Z" }, "Id": "a03", "CA10__AWS_IAM_Password_Policies__r": [] } ] - path: /types/CA10__CaAwsPasswordPolicy__c/object.extracts.yaml md5Hash: 2C1D97EF4F574F9BE1A9C1EB7CAE6A9C content: "---\nextracts:\n - name: CA10__minimumPasswordLength__c\n # Should\ \ not be null if the policy itself exists? Needs additional research\n #TODO:\ \ research if CA10__minimumPasswordLength__c can be null\n value:\n \ \ FIELD: \n path: CA10__minimumPasswordLength__c\n undeterminedIf:\n\ \ isEmpty: Possibly corrupted data. Minimum password length should\ \ not be empty\n - name: CA10__passwordReusePrevention__c\n value: \n \ \ FIELD:\n path: CA10__passwordReusePrevention__c\n undeterminedIf:\n\ \ isEmpty: Possibly corrupted data. Number of passwords to remember\ \ should not be empty" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "a01", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "199", "conditionText" : "CA10__AWS_IAM_Password_Policies__r.has(COMPLIANT)", "runtimeError" : null } }, { "Id" : "a02", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "299", "conditionText" : "CA10__AWS_IAM_Password_Policies__r.has(INCOMPLIANT)", "runtimeError" : null } }, { "Id" : "a03", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "300", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsPasswordPolicy__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2024-06-09T19:33:20Z") }, "CA10__passwordReusePrevention__c" : 24, "CA10__account__c" : "a01", "Id" : "a31" }, { "context" : { "snapshotTime" : new Date("2024-06-09T19:33:20Z") }, "CA10__passwordReusePrevention__c" : 20, "CA10__account__c" : "a02", "Id" : "a32" } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsAccount__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2024-06-09T19:33:20Z") }, "Id" : "a01" }, { "context" : { "snapshotTime" : new Date("2024-06-09T19:33:20Z") }, "Id" : "a02" }, { "context" : { "snapshotTime" : new Date("2024-06-09T19:33:20Z") }, "Id" : "a03" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsAccount__c( obj STRUCT< CA10__AWS_IAM_Password_Policies__r ARRAY >>, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var references1 = []; // condition[0], conditionIndex:[0..99] if (false) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared()", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } var count_CA10__AWS_IAM_Password_Policies__r_COMPLIANT2 = 0; if (obj.CA10__AWS_IAM_Password_Policies__r != null) { for (var i3 = 0; i3 < obj.CA10__AWS_IAM_Password_Policies__r.length; i3++) { if (typeof(obj.CA10__AWS_IAM_Password_Policies__r[i3].status) !== 'undefined') { if (obj.CA10__AWS_IAM_Password_Policies__r[i3].status == 'COMPLIANT') { count_CA10__AWS_IAM_Password_Policies__r_COMPLIANT2 += obj.CA10__AWS_IAM_Password_Policies__r[i3].count; } } else { if (obj.CA10__AWS_IAM_Password_Policies__r[i3].result.status == 'COMPLIANT') { count_CA10__AWS_IAM_Password_Policies__r_COMPLIANT2 += 1; } } } } // condition[1], conditionIndex:[100..199] references1.push('Related list [CA10__AWS_IAM_Password_Policies__r] ' + (count_CA10__AWS_IAM_Password_Policies__r_COMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in COMPLIANT status'); if (count_CA10__AWS_IAM_Password_Policies__r_COMPLIANT2 > 0) { return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "CA10__AWS_IAM_Password_Policies__r.has(COMPLIANT)", currentStateMessage: "The number of passwords to remember is set to at least 24.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } var count_CA10__AWS_IAM_Password_Policies__r_INCOMPLIANT4 = 0; if (obj.CA10__AWS_IAM_Password_Policies__r != null) { for (var i5 = 0; i5 < obj.CA10__AWS_IAM_Password_Policies__r.length; i5++) { if (typeof(obj.CA10__AWS_IAM_Password_Policies__r[i5].status) !== 'undefined') { if (obj.CA10__AWS_IAM_Password_Policies__r[i5].status == 'INCOMPLIANT') { count_CA10__AWS_IAM_Password_Policies__r_INCOMPLIANT4 += obj.CA10__AWS_IAM_Password_Policies__r[i5].count; } } else { if (obj.CA10__AWS_IAM_Password_Policies__r[i5].result.status == 'INCOMPLIANT') { count_CA10__AWS_IAM_Password_Policies__r_INCOMPLIANT4 += 1; } } } } // condition[2], conditionIndex:[200..299] if (count_CA10__AWS_IAM_Password_Policies__r_INCOMPLIANT4 > 0) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "CA10__AWS_IAM_Password_Policies__r.has(INCOMPLIANT)", currentStateMessage: "The number of passwords to remember is not set to at least 24.", currentStateReferences: references1.join('\n'), remediation: "Set the number of passwords to remember to 24 or more.", runtimeError: null}; } return {status: 'INCOMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "The AWS account password policy does not exist.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; CREATE TEMP FUNCTION process_CA10__AWS_IAM_Password_Policies__r( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__passwordReusePrevention__c FLOAT64, CA10__account__c STRING, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var IsEmptyLib = new function () { this.simpleIsEmpty = function(arg) { return arg == null; }; this.simpleIsNotEmpty = function(arg) { return arg != null; }; }(); 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 fieldChecked5() { if (IsEmptyLib.simpleIsEmpty(obj.CA10__passwordReusePrevention__c)) { throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__passwordReusePrevention__c.isEmpty()", currentStateMessage: "Possibly corrupted data. Number of passwords to remember should not be empty", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10__passwordReusePrevention__c; } function extract4() { if (!this.out) { this.out = fieldChecked5(); } return this.out; }; references1.push('Password Reuse Prevention [obj.CA10__passwordReusePrevention__c]: ' + obj.CA10__passwordReusePrevention__c); try { if (extract4.call(extract4) != null && 24.0 != null && extract4.call(extract4) < 24.0) { return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__passwordReusePrevention__c') < number(24.0)", currentStateMessage: "The password policy does not have 'Number of passwords to remember' set to at least 24.", currentStateReferences: references1.join('\n'), remediation: "Set 'Number of passwords to remember' to 24 or more.", runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } // condition[2], conditionIndex:[200..299] function fieldChecked9() { if (IsEmptyLib.simpleIsEmpty(obj.CA10__passwordReusePrevention__c)) { throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__passwordReusePrevention__c.isEmpty()", currentStateMessage: "Possibly corrupted data. Number of passwords to remember should not be empty", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10__passwordReusePrevention__c; } function extract8() { if (!this.out) { this.out = fieldChecked9(); } return this.out; }; try { if (extract8.call(extract8) != null && 24.0 != null && extract8.call(extract8) >= 24.0) { return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__passwordReusePrevention__c') >= number(24.0)", currentStateMessage: "The password policy has 'Number of passwords to remember' set to at least 24.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } return {status: 'UNDETERMINED', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "Unexpected value in the field.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; SELECT expectedResult.Id as Id, IF ( IFNULL(expectedResult.expectedResult.status, '') = IFNULL(sObject.result.status, '') AND IFNULL(expectedResult.expectedResult.conditionIndex, -1) = IFNULL(sObject.result.conditionIndex, -1) AND IFNULL(expectedResult.expectedResult.conditionText, '') = IFNULL(sObject.result.conditionText, '') AND IFNULL(expectedResult.expectedResult.runtimeError, '') = IFNULL(sObject.result.runtimeError, ''), "MATCH", "FAIL" ) as match, expectedResult.expectedResult.status as expectedStatus, sObject.result.status as actualStatus, expectedResult.expectedResult.conditionIndex as expectedConditionIndex, sObject.result.conditionIndex as actualConditionIndex, expectedResult.expectedResult.conditionText as expectedConditionText, sObject.result.conditionText as actualConditionText, expectedResult.expectedResult.runtimeError as expectedRuntimeError, sObject.result.runtimeError as actualRuntimeError FROM UNNEST(mock_ExpectedResult()) expectedResult LEFT JOIN ( SELECT `CA10__AWS_IAM_Password_Policies__r`.arr AS CA10__AWS_IAM_Password_Policies__r, sObject.Id AS Id, process_CA10__CaAwsAccount__c( STRUCT( `CA10__AWS_IAM_Password_Policies__r`.arr AS CA10__AWS_IAM_Password_Policies__r, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsAccount__c()) AS sObject LEFT JOIN ( SELECT sObject.CA10__account__c, ARRAY_AGG( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__passwordReusePrevention__c AS CA10__passwordReusePrevention__c, sObject.CA10__account__c AS CA10__account__c, sObject.Id AS Id, process_CA10__AWS_IAM_Password_Policies__r( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__passwordReusePrevention__c AS CA10__passwordReusePrevention__c, sObject.CA10__account__c AS CA10__account__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result ) ) AS arr FROM UNNEST(mock_CA10__CaAwsPasswordPolicy__c()) AS sObject GROUP BY sObject.CA10__account__c ) AS `CA10__AWS_IAM_Password_Policies__r` ON sObject.Id = `CA10__AWS_IAM_Password_Policies__r`.CA10__account__c ) sObject ON sObject.Id = expectedResult.Id;