--- policy: /ce/ca/aws/iam/detach-aws-cloudshell-full-access-policy logic: /ce/ca/aws/iam/detach-aws-cloudshell-full-access-policy/prod.logic.yaml executionTime: 2026-06-06T12:03:00.438049365Z generationMs: 60 executionMs: 918 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__name__c') != 'AWSCloudShellFullAccess' actual: extract('CA10__name__c') != 'AWSCloudShellFullAccess' runtimeError: {} - id: test3 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10__attachmentCount__c') > number(0.0) actual: extract('CA10__attachmentCount__c') > number(0.0) runtimeError: {} - id: test4 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 300 actual: 300 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test5 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 300 actual: 300 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test6 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 300 actual: 300 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/aws/iam/detach-aws-cloudshell-full-access-policy/policy.yaml md5Hash: 236C5BE1878435BDF10C17F97EBC2B45 content: | --- names: full: AWS IAM AWSCloudShellFullAccess Policy is attached contextual: AWSCloudShellFullAccess Policy is attached description: "AWS CloudShell is a convenient way of running CLI commands against AWS\ \ services. AWSCloudShellFullAccess managed IAM policy provides full access to CloudShell,\ \ which allows file upload and download capability between a user's local system\ \ and the CloudShell environment. Within the CloudShell environment a user has sudo\ \ permissions, and can access the internet. So it is feasible to install file transfer\ \ software (for example) and move data from CloudShell to external internet servers." type: COMPLIANCE_POLICY categories: - SECURITY frameworkMappings: - "/frameworks/cis-aws-v7.0.0/02/20" - "/frameworks/cloudaware/identity-and-access-governance/general-access-controls" - path: /ce/ca/aws/iam/detach-aws-cloudshell-full-access-policy/prod.logic.yaml md5Hash: 27EA931619BE841E0E583C15D8EF8E28 content: | --- inputType: "CA10__CaAwsIamPolicy__c" testData: - file: "test-data.json" importExtracts: - file: "/types/CA10__CaAwsIamPolicy__c/object.extracts.yaml" conditions: - status: "INAPPLICABLE" currentStateMessage: "This is not an AWSCloudShellFullAccess policy." check: NOT_EQUAL: left: EXTRACT: "CA10__name__c" right: TEXT: "AWSCloudShellFullAccess" - status: "INCOMPLIANT" currentStateMessage: "AWSCloudShellFullAccess policy is attached to one or more IAM entities." remediationMessage: "Detach the AWSCloudShellFullAccess policy from any users, groups, or roles where it is not required." check: GREATER_THAN: left: EXTRACT: "CA10__attachmentCount__c" right: NUMBER: 0.0 otherwise: status: "COMPLIANT" currentStateMessage: "AWSCloudShellFullAccess policy is not attached to any IAM entities." - path: /ce/ca/aws/iam/detach-aws-cloudshell-full-access-policy/test-data.json md5Hash: 9BBB7E4504F1F139B28B9A2E5FFCF6D9 content: | [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2024-07-10T20:44:00Z" }, "Id": "test1", "CA10__disappearanceTime__c": "2024-07-10T03:39:54Z", "CA10__name__c": "policyName1", "CA10__AWS_IAM_Role_Policy_Attachments__r": [ { "Id": "test1_1", "CA10__disappearanceTime__c": "2024-07-09T21:50:34Z", "CA10__role__c": "role1", "CA10__roleArn__c": "arn:aws:iam::012345678910:role/roleName1", "CA10__policy__c": "test1", "CA10__role__r": { "Id": "role1", "CA10__disappearanceTime__c": "2024-07-09T21:48:35Z" } } ] }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "extract('CA10__name__c') != 'AWSCloudShellFullAccess'", "runtimeError": null }, "context": { "snapshotTime": "2024-07-10T20:44:00Z" }, "Id": "test2", "CA10__disappearanceTime__c": null, "CA10__name__c": "policyName2", "CA10__attachmentCount__c": 1, "CA10__AWS_IAM_Role_Policy_Attachments__r": [ { "Id": "test2_1", "CA10__disappearanceTime__c": null, "CA10__role__c": "role2", "CA10__roleArn__c": "arn:aws:iam::012345678910:role/roleName2", "CA10__policy__c": "test2", "CA10__role__r": { "Id": "role2", "CA10__disappearanceTime__c": null } } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "299", "conditionText": "extract('CA10__attachmentCount__c') > number(0.0)", "runtimeError": null }, "context": { "snapshotTime": "2024-07-10T20:44:00Z" }, "Id": "test3", "CA10__disappearanceTime__c": null, "CA10__name__c": "AWSCloudShellFullAccess", "CA10__attachmentCount__c": 1, "CA10__AWS_IAM_Role_Policy_Attachments__r": [ { "Id": "test3_1", "CA10__disappearanceTime__c": null, "CA10__role__c": "role3", "CA10__roleArn__c": "arn:aws:iam::012345678910:role/roleName3", "CA10__policy__c": "test3", "CA10__role__r": { "Id": "role3", "CA10__disappearanceTime__c": null } } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "300", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2024-07-10T20:44:00Z" }, "Id": "test4", "CA10__disappearanceTime__c": null, "CA10__name__c": "AWSCloudShellFullAccess", "CA10__attachmentCount__c": 0, "CA10__AWS_IAM_Role_Policy_Attachments__r": [ { "Id": "test4_1", "CA10__disappearanceTime__c": null, "CA10__role__c": "role4", "CA10__roleArn__c": "arn:aws:iam::012345678910:role/roleName4", "CA10__policy__c": "test4", "CA10__role__r": { "Id": "role4", "CA10__disappearanceTime__c": "2024-07-10T20:44:00Z" } } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "300", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2024-07-10T20:44:00Z" }, "Id": "test5", "CA10__disappearanceTime__c": null, "CA10__name__c": "AWSCloudShellFullAccess", "CA10__attachmentCount__c": 0, "CA10__AWS_IAM_Role_Policy_Attachments__r": [ { "Id": "test5_1", "CA10__disappearanceTime__c": "2024-07-10T20:44:00Z", "CA10__role__c": null, "CA10__roleArn__c": "arn:aws:iam::012345678910:role/roleName5", "CA10__policy__c": "test5", "CA10__role__r": { "Id": null, "CA10__disappearanceTime__c": "2024-07-10T20:44:00Z" } } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "300", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2024-07-10T20:44:00Z" }, "Id": "test6", "CA10__disappearanceTime__c": null, "CA10__name__c": "AWSCloudShellFullAccess", "CA10__attachmentCount__c": 0, "CA10__AWS_IAM_Role_Policy_Attachments__r": [] } ] - path: /types/CA10__CaAwsIamPolicy__c/object.extracts.yaml md5Hash: 0275D0984133394A8FDEB9F7EF7CF4FC content: "# yaml-language-server: $schema=../../schema/Extracts.schema.json\n\ ---\nextracts:\n# Not Nullable. Can't have no Access, retrieved via iam:ListPolicies\n\ - name: \"CA10__name__c\"\n value: \n FIELD:\n path: \"CA10__name__c\"\ \n undeterminedIf:\n isEmpty: \"Corrupted data. Policy Name cannot\ \ be empty.\"\n# Not Nullable. Can't have no Access, retrieved via iam:ListPolicies\n\ - name: \"CA10__policyType__c\"\n value:\n FIELD:\n path: \"CA10__policyType__c\"\ \n undeterminedIf:\n isEmpty: \"Corrupted data. Policy Type cannot\ \ be empty.\"\n# Checkbox. Can't have no Access, retrieved via iam:ListPolicies\n\ - name: \"CA10__attachable__c\"\n value: \n FIELD:\n path: \"CA10__attachable__c\"\ \n- name: \"CA10__attachmentCount__c\"\n value: \n FIELD:\n path: \"\ CA10__attachmentCount__c\"\n- name: \"CA10__policyDocument__c\"\n value: \n\ \ FIELD:\n path: CA10__policyDocument__c\n returnType: BYTES\n\ \ undeterminedIf:\n noAccessDelegate:\n path: \"CA10__policyDocument__c\"\ \n currentStateMessage: \"Unable to determine the Policy Document.\ \ Possible permission issue with iam:GetPolicyVersion\"\n- name: \"caJsonFrom_policyDocument__c\"\ \n value:\n JSON_FROM:\n arg:\n EXTRACT: \"CA10__policyDocument__c\"\ \n undeterminedIf:\n isInvalid: \"IAM policy document JSON is invalid\"\ \n# Not Nullable. Can't have no Access, retrieved via iam:ListPolicies\n- name:\ \ \"CA10__arn__c\"\n value: \n FIELD:\n path: CA10__arn__c\n undeterminedIf:\n\ \ isEmpty: \"Corrupted data. Policy ARN cannot be empty.\"\n" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> 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__name__c') != 'AWSCloudShellFullAccess'", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "299", "conditionText" : "extract('CA10__attachmentCount__c') > number(0.0)", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "300", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test5", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "300", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test6", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "300", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsIamPolicy__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2024-07-10T20:44:00Z") }, "CA10__disappearanceTime__c" : new Date("2024-07-10T03:39:54Z"), "CA10__name__c" : "policyName1", "CA10__attachmentCount__c" : null, "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2024-07-10T20:44:00Z") }, "CA10__name__c" : "policyName2", "CA10__attachmentCount__c" : 1, "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2024-07-10T20:44:00Z") }, "CA10__name__c" : "AWSCloudShellFullAccess", "CA10__attachmentCount__c" : 1, "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2024-07-10T20:44:00Z") }, "CA10__name__c" : "AWSCloudShellFullAccess", "CA10__attachmentCount__c" : 0, "Id" : "test4" }, { "context" : { "snapshotTime" : new Date("2024-07-10T20:44:00Z") }, "CA10__name__c" : "AWSCloudShellFullAccess", "CA10__attachmentCount__c" : 0, "Id" : "test5" }, { "context" : { "snapshotTime" : new Date("2024-07-10T20:44:00Z") }, "CA10__name__c" : "AWSCloudShellFullAccess", "CA10__attachmentCount__c" : 0, "Id" : "test6" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsIamPolicy__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__name__c STRING, CA10__attachmentCount__c FLOAT64, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var TextLib = new function () { this.normalize = function(arg) { return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase(); }; this.isEmpty = function(arg) { return this.normalize(arg) == ''; }; this.isNotEmpty = function(arg) { return this.normalize(arg) != ''; }; this.equal = function(left, right) { return this.normalize(left) == this.normalize(right); }; this.notEqual = function(left, right) { return this.normalize(left) != this.normalize(right); }; this.startsWith = function(arg, substring) { return this.normalize(arg).startsWith(this.normalize(substring)); }; this.endsWith = function(arg, substring) { return this.normalize(arg).endsWith(this.normalize(substring)); }; this.contains = function(arg, substring) { return this.normalize(arg).includes(this.normalize(substring)); }; 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 fieldChecked4() { if (TextLib.isEmpty(obj.CA10__name__c)) { throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__name__c.isEmpty()", currentStateMessage: "Corrupted data. Policy Name cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10__name__c; } function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; }; references1.push('Name [obj.CA10__name__c]: ' + obj.CA10__name__c); try { if (TextLib.notEqual(extract3.call(extract3), 'AWSCloudShellFullAccess')) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__name__c') != 'AWSCloudShellFullAccess'", currentStateMessage: "This is not an AWSCloudShellFullAccess policy.", 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 extract7() { if (!this.out) { this.out = obj.CA10__attachmentCount__c; } return this.out; }; references1.push('Attachment Count [obj.CA10__attachmentCount__c]: ' + obj.CA10__attachmentCount__c); if (extract7.call(extract7) != null && 0.0 != null && extract7.call(extract7) > 0.0) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__attachmentCount__c') > number(0.0)", currentStateMessage: "AWSCloudShellFullAccess policy is attached to one or more IAM entities.", currentStateReferences: references1.join('\n'), remediation: "Detach the AWSCloudShellFullAccess policy from any users, groups, or roles where it is not required.", runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "AWSCloudShellFullAccess policy is not attached to any IAM entities.", 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__name__c AS CA10__name__c, sObject.CA10__attachmentCount__c AS CA10__attachmentCount__c, sObject.Id AS Id, process_CA10__CaAwsIamPolicy__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__name__c AS CA10__name__c, sObject.CA10__attachmentCount__c AS CA10__attachmentCount__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsIamPolicy__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;