--- policy: /ce/ca/oracle/tenancy/tenancy-without-compartments logic: /ce/ca/oracle/tenancy/tenancy-without-compartments/prod.logic.yaml executionTime: 2026-05-02T12:07:27.797072689Z generationMs: 55 executionMs: 2003 rows: - id: tenancy-comp-1 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: CA10O1__Oracle_Compartments__r.has(COMPLIANT) actual: CA10O1__Oracle_Compartments__r.has(COMPLIANT) runtimeError: {} - id: tenancy-comp-2 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: tenancy-comp-3 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/oracle/tenancy/tenancy-without-compartments/policy.yaml md5Hash: 98C1AD1BBA1E69F04BDB104A80CB78D3 content: | --- names: full: "Oracle Tenancy has no active customer-managed compartments" contextual: "Tenancy has no active customer-managed compartments" description: > Ensure that each OCI tenancy contains at least one active customer-managed compartment to support resource isolation, delegated administration, least-privilege IAM policy scoping, and clear tenancy governance boundaries. type: "COMPLIANCE_POLICY" categories: - "SECURITY" frameworkMappings: - "/frameworks/cloudaware/identity-and-access-governance/general-access-controls" - "/frameworks/cis-oracle-v3.1.0/06/01" - path: /ce/ca/oracle/tenancy/tenancy-without-compartments/prod.logic.yaml md5Hash: 82EC51DFF161AC9CB2156A34D570C75A content: | --- inputType: "CA10O1__CaOracleTenancy__c" testData: - file: "test-data.json" conditions: - status: "COMPLIANT" currentStateMessage: "This tenancy has at least one active customer-managed compartment." check: RELATED_LIST_HAS: status: "COMPLIANT" relationshipName: "CA10O1__Oracle_Compartments__r" otherwise: status: "INCOMPLIANT" currentStateMessage: "This tenancy does not have any active customer-managed compartments." remediationMessage: "Create at least one active customer-managed compartment and use it to organize OCI resources." relatedLists: - relationshipName: "CA10O1__Oracle_Compartments__r" importExtracts: - file: "/types/CA10O1__CaOracleCompartment__c/object.extracts.yaml" conditions: - status: "INAPPLICABLE" currentStateMessage: "This Oracle compartment is not active." check: NOT_EQUAL: left: EXTRACT: "CA10O1__lifecycleState__c" right: TEXT: "ACTIVE" - status: "INAPPLICABLE" currentStateMessage: "This is the OCI-managed ManagedCompartmentForPaaS compartment." check: IS_EQUAL: left: EXTRACT: "Name" right: TEXT: "ManagedCompartmentForPaaS" otherwise: status: "COMPLIANT" currentStateMessage: "This is an active customer-managed compartment." - path: /ce/ca/oracle/tenancy/tenancy-without-compartments/test-data.json md5Hash: 073ADF69A5E306580DD0851271AC2114 content: | [ { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "199", "conditionText": "CA10O1__Oracle_Compartments__r.has(COMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2026-04-12T00:00:00Z" }, "Id": "tenancy-comp-1", "CA10O1__disappearanceTime__c": null, "CA10O1__Oracle_Compartments__r": [ { "Id": "compartment-1", "CA10O1__disappearanceTime__c": null, "CA10O1__tenancy__c": "tenancy-comp-1", "Name": "Operations", "CA10O1__lifecycleState__c": "ACTIVE" } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-04-12T00:00:00Z" }, "Id": "tenancy-comp-2", "CA10O1__disappearanceTime__c": null, "CA10O1__Oracle_Compartments__r": [ { "Id": "compartment-2", "CA10O1__disappearanceTime__c": null, "CA10O1__tenancy__c": "tenancy-comp-2", "Name": "ManagedCompartmentForPaaS", "CA10O1__lifecycleState__c": "ACTIVE" }, { "Id": "compartment-3", "CA10O1__disappearanceTime__c": null, "CA10O1__tenancy__c": "tenancy-comp-2", "Name": "Legacy", "CA10O1__lifecycleState__c": "INACTIVE" } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-04-12T00:00:00Z" }, "Id": "tenancy-comp-3", "CA10O1__disappearanceTime__c": null, "CA10O1__Oracle_Compartments__r": [] } ] - path: /types/CA10O1__CaOracleCompartment__c/object.extracts.yaml md5Hash: 258990DCA94BE45FB107CEC97D44D89F content: | --- extracts: - name: "Name" value: FIELD: path: "Name" - name: "CA10O1__lifecycleState__c" value: FIELD: path: "CA10O1__lifecycleState__c" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "tenancy-comp-1", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "199", "conditionText" : "CA10O1__Oracle_Compartments__r.has(COMPLIANT)", "runtimeError" : null } }, { "Id" : "tenancy-comp-2", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "200", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "tenancy-comp-3", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "200", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10O1__CaOracleTenancy__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "Id" : "tenancy-comp-1" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "Id" : "tenancy-comp-2" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "Id" : "tenancy-comp-3" } ]; """; CREATE TEMP FUNCTION mock_CA10O1__CaOracleCompartment__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "CA10O1__lifecycleState__c" : "ACTIVE", "Name" : "Operations", "CA10O1__tenancy__c" : "tenancy-comp-1", "Id" : "compartment-1" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "CA10O1__lifecycleState__c" : "ACTIVE", "Name" : "ManagedCompartmentForPaaS", "CA10O1__tenancy__c" : "tenancy-comp-2", "Id" : "compartment-2" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "CA10O1__lifecycleState__c" : "INACTIVE", "Name" : "Legacy", "CA10O1__tenancy__c" : "tenancy-comp-2", "Id" : "compartment-3" } ]; """; CREATE TEMP FUNCTION process_CA10O1__CaOracleTenancy__c( obj STRUCT< Id STRING, CA10O1__Oracle_Compartments__r ARRAY >> >, 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_CA10O1__Oracle_Compartments__r_COMPLIANT2 = 0; if (obj.CA10O1__Oracle_Compartments__r != null) { for (var i3 = 0; i3 < obj.CA10O1__Oracle_Compartments__r.length; i3++) { if (typeof(obj.CA10O1__Oracle_Compartments__r[i3].status) !== 'undefined') { if (obj.CA10O1__Oracle_Compartments__r[i3].status == 'COMPLIANT') { count_CA10O1__Oracle_Compartments__r_COMPLIANT2 += obj.CA10O1__Oracle_Compartments__r[i3].count; } } else { if (obj.CA10O1__Oracle_Compartments__r[i3].result.status == 'COMPLIANT') { count_CA10O1__Oracle_Compartments__r_COMPLIANT2 += 1; } } } } // condition[1], conditionIndex:[100..199] references1.push('Related list [CA10O1__Oracle_Compartments__r] ' + (count_CA10O1__Oracle_Compartments__r_COMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in COMPLIANT status'); if (count_CA10O1__Oracle_Compartments__r_COMPLIANT2 > 0) { return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "CA10O1__Oracle_Compartments__r.has(COMPLIANT)", currentStateMessage: "This tenancy has at least one active customer-managed compartment.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'INCOMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "This tenancy does not have any active customer-managed compartments.", currentStateReferences: references1.join('\n'), remediation: "Create at least one active customer-managed compartment and use it to organize OCI resources.", runtimeError: null}; """; CREATE TEMP FUNCTION process_CA10O1__Oracle_Compartments__r( obj STRUCT< CA10O1__lifecycleState__c STRING, Name STRING, CA10O1__tenancy__c STRING, 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] if (false) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared()", 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.CA10O1__lifecycleState__c; } return this.out; }; references1.push('Lifecycle State [obj.CA10O1__lifecycleState__c]: ' + obj.CA10O1__lifecycleState__c); if (TextLib.notEqual(extract3.call(extract3), 'ACTIVE')) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10O1__lifecycleState__c') != 'ACTIVE'", currentStateMessage: "This Oracle compartment is not active.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function extract6() { if (!this.out) { this.out = obj.Name; } return this.out; }; references1.push('Name [obj.Name]: ' + obj.Name); if (TextLib.equal(extract6.call(extract6), 'ManagedCompartmentForPaaS')) { return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "extract('Name') == 'ManagedCompartmentForPaaS'", currentStateMessage: "This is the OCI-managed ManagedCompartmentForPaaS compartment.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "This is an active customer-managed compartment.", 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.Id AS Id, `CA10O1__Oracle_Compartments__r`.arr AS CA10O1__Oracle_Compartments__r, process_CA10O1__CaOracleTenancy__c( STRUCT( sObject.Id AS Id, `CA10O1__Oracle_Compartments__r`.arr AS CA10O1__Oracle_Compartments__r ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10O1__CaOracleTenancy__c()) AS sObject LEFT JOIN ( SELECT sObject.CA10O1__tenancy__c, ARRAY_AGG( STRUCT( sObject.CA10O1__lifecycleState__c AS CA10O1__lifecycleState__c, sObject.Name AS Name, sObject.CA10O1__tenancy__c AS CA10O1__tenancy__c, sObject.Id AS Id, process_CA10O1__Oracle_Compartments__r( STRUCT( sObject.CA10O1__lifecycleState__c AS CA10O1__lifecycleState__c, sObject.Name AS Name, sObject.CA10O1__tenancy__c AS CA10O1__tenancy__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result ) ) AS arr FROM UNNEST(mock_CA10O1__CaOracleCompartment__c()) AS sObject GROUP BY sObject.CA10O1__tenancy__c ) AS `CA10O1__Oracle_Compartments__r` ON sObject.Id = `CA10O1__Oracle_Compartments__r`.CA10O1__tenancy__c ) sObject ON sObject.Id = expectedResult.Id;