--- policy: /ce/ca/aws/iam/access-key-unused logic: /ce/ca/aws/iam/access-key-unused/prod.logic.yaml executionTime: 2026-06-06T12:02:58.777722936Z generationMs: 47 executionMs: 909 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__status__c') != 'Active' actual: extract('CA10__status__c') != 'Active' runtimeError: {} - id: test3 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10__lastUsedDate__c').isNotEmpty() && extract('CA10__lastUsedDate__c').beyondLastDays(90) actual: extract('CA10__lastUsedDate__c').isNotEmpty() && extract('CA10__lastUsedDate__c').beyondLastDays(90) runtimeError: {} - id: test4 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 399 actual: 399 conditionText: expected: extract('CA10__lastUsedDate__c').isEmpty() && extract('CA10__createDate__c').beyondLastDays(90) actual: extract('CA10__lastUsedDate__c').isEmpty() && extract('CA10__createDate__c').beyondLastDays(90) runtimeError: {} - id: test5 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 400 actual: 400 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/aws/iam/access-key-unused/policy.yaml md5Hash: F8AA6A1593E4DF95675C29EB1C02DF41 content: "---\nnames:\n full: AWS IAM Access Key is unused\n contextual: IAM\ \ Access Key is unused\ndescription: >\n Identify and remove active IAM access\ \ keys that have not been used for 90 days \n or more. Reducing the number\ \ of active, unused credentials minimizes the risk \n of unauthorized access\ \ if a key is compromised.\ntype: \"BEST_PRACTICE\"\ncategories:\n - \"SECURITY\"\ \nframeworkMappings:\n - \"/frameworks/cloudaware/identity-and-access-governance/credential-lifecycle-management\"\ \n - \"/frameworks/aws-fsbp-v1.0.0/iam/08\"\nsimilarPolicies:\n awsSecurityHub:\n\ \ - name: \"[IAM.8] Unused IAM user credentials should be removed\"\n \ \ url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/iam-controls.html#iam-8\"\ \n cloudConformity:\n - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/aws/IAM/unnecessary-access-keys.html\n\ \ name: Unnecessary Access Keys\n" - path: /ce/ca/aws/iam/access-key-unused/prod.logic.yaml md5Hash: 95EA2DB7F31A01B60A20552E3F99997C content: | --- inputType: CA10__CaAwsAccessKey__c testData: - file: "test-data.json" importExtracts: - file: "/types/CA10__CaAwsAccessKey__c/object.extracts.yaml" conditions: - status: "INAPPLICABLE" currentStateMessage: "The access key is currently inactive." check: NOT_EQUAL: left: EXTRACT: "CA10__status__c" right: TEXT: "Active" - status: "INCOMPLIANT" currentStateMessage: "The access key is active but has not been used in over 90 days." remediationMessage: "Deactivate the unused access key." check: AND: args: - NOT_EMPTY: arg: EXTRACT: "CA10__lastUsedDate__c" - IS_BEYOND_LAST_DAYS: offsetDays: 90 arg: EXTRACT: "CA10__lastUsedDate__c" - status: "INCOMPLIANT" currentStateMessage: "The access key is active, has never been used, and was created over 90 days ago." remediationMessage: "Deactivate the unused access key." check: AND: args: - IS_EMPTY: arg: EXTRACT: "CA10__lastUsedDate__c" - IS_BEYOND_LAST_DAYS: offsetDays: 90 arg: EXTRACT: "CA10__createDate__c" otherwise: status: "COMPLIANT" currentStateMessage: "The access key is active and has been used within the last 90 days (or was created recently)." - path: /ce/ca/aws/iam/access-key-unused/test-data.json md5Hash: 1D2A1B5E99B5D4B6BC2CBF6B249A127D content: |- [ { "expectedResult": { "runtimeError": null, "conditionText": "isDisappeared(CA10__disappearanceTime__c)", "conditionIndex": 99, "status": "DISAPPEARED" }, "context": { "snapshotTime": "2025-12-19T02:21:26Z" }, "CA10__createDate__c": "2025-11-05T14:18:01Z", "Id": "test1", "CA10__disappearanceTime__c": "2025-12-12T21:58:51Z", "CA10__lastUsedDate__c": "2025-11-05T14:20:00Z", "CA10__status__c": "Active" }, { "expectedResult": { "runtimeError": null, "conditionText": "extract('CA10__status__c') != 'Active'", "conditionIndex": 199, "status": "INAPPLICABLE" }, "context": { "snapshotTime": "2025-12-19T02:21:26Z" }, "CA10__createDate__c": "2023-08-04T18:46:57Z", "Id": "test2", "CA10__disappearanceTime__c": null, "CA10__lastUsedDate__c": null, "CA10__status__c": "Inactive" }, { "expectedResult": { "runtimeError": null, "conditionText": "extract('CA10__lastUsedDate__c').isNotEmpty() && extract('CA10__lastUsedDate__c').beyondLastDays(90)", "conditionIndex": 299, "status": "INCOMPLIANT" }, "context": { "snapshotTime": "2025-12-19T02:21:26Z" }, "CA10__createDate__c": "2025-08-06T17:01:57Z", "Id": "test3", "CA10__disappearanceTime__c": null, "CA10__lastUsedDate__c": "2025-08-26T20:22:00Z", "CA10__status__c": "Active" }, { "expectedResult": { "runtimeError": null, "conditionText": "extract('CA10__lastUsedDate__c').isEmpty() && extract('CA10__createDate__c').beyondLastDays(90)", "conditionIndex": 399, "status": "INCOMPLIANT" }, "context": { "snapshotTime": "2025-12-19T02:21:26Z" }, "CA10__createDate__c": "2025-05-07T20:33:32Z", "Id": "test4", "CA10__disappearanceTime__c": null, "CA10__lastUsedDate__c": null, "CA10__status__c": "Active" }, { "expectedResult": { "runtimeError": null, "conditionText": "otherwise", "conditionIndex": 400, "status": "COMPLIANT" }, "context": { "snapshotTime": "2025-12-19T02:21:26Z" }, "CA10__createDate__c": "2025-07-25T20:46:37Z", "Id": "test5", "CA10__disappearanceTime__c": null, "CA10__lastUsedDate__c": "2025-12-18T21:39:00Z", "CA10__status__c": "Active" } ] - path: /types/CA10__CaAwsAccessKey__c/object.extracts.yaml md5Hash: 40ECF1BF559EC81799BEDCBB6DEAAC0B content: "---\nextracts:\n# Date/Time. Nullable.\n - name: CA10__lastUsedDate__c\n\ \ value: \n FIELD:\n path: CA10__lastUsedDate__c\n# Values: Active\ \ | Inactive. Not nullable.\n - name: CA10__status__c\n value: \n FIELD:\n\ \ path: CA10__status__c\n# Date/Time. 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" : { "runtimeError" : null, "conditionText" : "isDisappeared(CA10__disappearanceTime__c)", "conditionIndex" : 99, "status" : "DISAPPEARED" } }, { "Id" : "test2", "expectedResult" : { "runtimeError" : null, "conditionText" : "extract('CA10__status__c') != 'Active'", "conditionIndex" : 199, "status" : "INAPPLICABLE" } }, { "Id" : "test3", "expectedResult" : { "runtimeError" : null, "conditionText" : "extract('CA10__lastUsedDate__c').isNotEmpty() && extract('CA10__lastUsedDate__c').beyondLastDays(90)", "conditionIndex" : 299, "status" : "INCOMPLIANT" } }, { "Id" : "test4", "expectedResult" : { "runtimeError" : null, "conditionText" : "extract('CA10__lastUsedDate__c').isEmpty() && extract('CA10__createDate__c').beyondLastDays(90)", "conditionIndex" : 399, "status" : "INCOMPLIANT" } }, { "Id" : "test5", "expectedResult" : { "runtimeError" : null, "conditionText" : "otherwise", "conditionIndex" : 400, "status" : "COMPLIANT" } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsAccessKey__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__disappearanceTime__c" : new Date("2025-12-12T21:58:51Z"), "CA10__status__c" : "Active", "CA10__lastUsedDate__c" : new Date("2025-11-05T14:20:00Z"), "CA10__createDate__c" : new Date("2025-11-05T14:18:01Z"), "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__status__c" : "Inactive", "CA10__createDate__c" : new Date("2023-08-04T18:46:57Z"), "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__status__c" : "Active", "CA10__lastUsedDate__c" : new Date("2025-08-26T20:22:00Z"), "CA10__createDate__c" : new Date("2025-08-06T17:01:57Z"), "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__status__c" : "Active", "CA10__createDate__c" : new Date("2025-05-07T20:33:32Z"), "Id" : "test4" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__status__c" : "Active", "CA10__lastUsedDate__c" : new Date("2025-12-18T21:39:00Z"), "CA10__createDate__c" : new Date("2025-07-25T20:46:37Z"), "Id" : "test5" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsAccessKey__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__status__c STRING, CA10__lastUsedDate__c TIMESTAMP, CA10__createDate__c TIMESTAMP, 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 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 todayMinus90Day = new Date(snapshotTime.toISOString().substr(0,10)+'T00:00:00.000Z').getTime() + (-90 * 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__status__c; } return this.out; }; references1.push('Status [obj.CA10__status__c]: ' + obj.CA10__status__c); if (TextLib.notEqual(extract3.call(extract3), 'Active')) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__status__c') != 'Active'", currentStateMessage: "The access key is currently inactive.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function extract6() { if (!this.out) { this.out = obj.CA10__lastUsedDate__c; } return this.out; }; references1.push('Last Used: Date [obj.CA10__lastUsedDate__c]: ' + obj.CA10__lastUsedDate__c); if (IsEmptyLib.simpleIsNotEmpty(extract6.call(extract6)) && (extract6.call(extract6) != null && extract6.call(extract6).getTime() < todayMinus90Day)) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__lastUsedDate__c').isNotEmpty() && extract('CA10__lastUsedDate__c').beyondLastDays(90)", currentStateMessage: "The access key is active but has not been used in over 90 days.", currentStateReferences: references1.join('\n'), remediation: "Deactivate the unused access key.", runtimeError: null}; } // condition[3], conditionIndex:[300..399] function extract11() { if (!this.out) { this.out = obj.CA10__lastUsedDate__c; } return this.out; }; function extract14() { if (!this.out) { this.out = obj.CA10__createDate__c; } return this.out; }; references1.push('Create Date [obj.CA10__createDate__c]: ' + obj.CA10__createDate__c); if (IsEmptyLib.simpleIsEmpty(extract11.call(extract11)) && (extract14.call(extract14) != null && extract14.call(extract14).getTime() < todayMinus90Day)) { return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__lastUsedDate__c').isEmpty() && extract('CA10__createDate__c').beyondLastDays(90)", currentStateMessage: "The access key is active, has never been used, and was created over 90 days ago.", currentStateReferences: references1.join('\n'), remediation: "Deactivate the unused access key.", runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "The access key is active and has been used within the last 90 days (or was created recently).", 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__status__c AS CA10__status__c, sObject.CA10__lastUsedDate__c AS CA10__lastUsedDate__c, sObject.CA10__createDate__c AS CA10__createDate__c, sObject.Id AS Id, process_CA10__CaAwsAccessKey__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__status__c AS CA10__status__c, sObject.CA10__lastUsedDate__c AS CA10__lastUsedDate__c, sObject.CA10__createDate__c AS CA10__createDate__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsAccessKey__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;