--- policy: /ce/ca/oracle/cloud-guard/cloud-guard-in-root-compartment logic: /ce/ca/oracle/cloud-guard/cloud-guard-in-root-compartment/prod.logic.yaml executionTime: 2026-05-02T12:07:20.466398757Z generationMs: 56 executionMs: 2387 rows: - id: test1 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: CA10O1__Oracle_Cloud_Guard_Targets__r.has(COMPLIANT) actual: CA10O1__Oracle_Cloud_Guard_Targets__r.has(COMPLIANT) runtimeError: {} - id: test2 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test3 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test4 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/oracle/cloud-guard/cloud-guard-in-root-compartment/policy.yaml md5Hash: FB5D751BBA27A04668EE8E1A3B65D6AD content: | --- names: full: "Oracle Cloud Guard is not enabled in the root compartment" contextual: "Cloud Guard is not enabled in the root compartment" description: > Oracle Cloud Guard should be enabled with an active target for the root compartment to provide tenancy-wide security posture monitoring and threat detection coverage. type: "COMPLIANCE_POLICY" categories: - "SECURITY" frameworkMappings: - "/frameworks/cloudaware/resource-security/threat-protection" - "/frameworks/cis-oracle-v3.1.0/04/14" similarPolicies: internal: - "dec-x-dcb56f35" - path: /ce/ca/oracle/cloud-guard/cloud-guard-in-root-compartment/prod.logic.yaml md5Hash: FBABF9B0A9700CA8A561990578101F44 content: | --- inputType: "CA10O1__CaOracleTenancy__c" testData: - file: "test-data.json" conditions: - status: "COMPLIANT" currentStateMessage: "Cloud Guard is enabled for the root compartment of this tenancy." check: RELATED_LIST_HAS: status: "COMPLIANT" relationshipName: "CA10O1__Oracle_Cloud_Guard_Targets__r" otherwise: status: "INCOMPLIANT" currentStateMessage: "Cloud Guard is not enabled for the root compartment of this tenancy." remediationMessage: "Enable Oracle Cloud Guard and configure an active target for the root compartment." relatedLists: - relationshipName: "CA10O1__Oracle_Cloud_Guard_Targets__r" importExtracts: - file: /types/CA10O1__CaOracleCloudGuardTarget__c/object.extracts.yaml conditions: - status: "COMPLIANT" currentStateMessage: "This active Cloud Guard target monitors the root compartment." check: AND: args: - IS_EQUAL: left: EXTRACT: "CA10O1__lifecycleState__c" right: TEXT: "ACTIVE" - STARTS_WITH: arg: EXTRACT: "CA10O1__targetResourceOcid__c" search: TEXT: "ocid1.tenancy." otherwise: status: "INAPPLICABLE" currentStateMessage: "This Cloud Guard target is inactive or does not monitor the root compartment." - path: /ce/ca/oracle/cloud-guard/cloud-guard-in-root-compartment/test-data.json md5Hash: 7CE9ACA7D374548CDDA1E6703D219455 content: | [ { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "199", "conditionText": "CA10O1__Oracle_Cloud_Guard_Targets__r.has(COMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2026-04-12T00:00:00Z" }, "Id": "test1", "CA10O1__disappearanceTime__c": null, "CA10O1__Oracle_Cloud_Guard_Targets__r": [ { "Id": "test1_1", "CA10O1__disappearanceTime__c": null, "CA10O1__lifecycleState__c": "ACTIVE", "CA10O1__targetResourceOcid__c": "ocid1.tenancy.oc1..root", "CA10O1__tenancy__c": "test1" } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-04-12T00:00:00Z" }, "Id": "test2", "CA10O1__disappearanceTime__c": null, "CA10O1__Oracle_Cloud_Guard_Targets__r": [ { "Id": "test2_1", "CA10O1__disappearanceTime__c": null, "CA10O1__lifecycleState__c": "ACTIVE", "CA10O1__targetResourceOcid__c": "ocid1.compartment.oc1..child", "CA10O1__tenancy__c": "test2" } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-04-12T00:00:00Z" }, "Id": "test3", "CA10O1__disappearanceTime__c": null, "CA10O1__Oracle_Cloud_Guard_Targets__r": [] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-04-12T00:00:00Z" }, "Id": "test4", "CA10O1__disappearanceTime__c": null, "CA10O1__Oracle_Cloud_Guard_Targets__r": [ { "Id": "test4_1", "CA10O1__disappearanceTime__c": null, "CA10O1__lifecycleState__c": "INACTIVE", "CA10O1__targetResourceOcid__c": "ocid1.tenancy.oc1..root", "CA10O1__tenancy__c": "test4" } ] } ] - path: /types/CA10O1__CaOracleCloudGuardTarget__c/object.extracts.yaml md5Hash: D827D8548A380C25217ECE7BD35304D1 content: | --- extracts: - name: "CA10O1__lifecycleState__c" value: FIELD: path: "CA10O1__lifecycleState__c" - name: "CA10O1__targetResourceOcid__c" value: FIELD: path: "CA10O1__targetResourceOcid__c" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test1", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "199", "conditionText" : "CA10O1__Oracle_Cloud_Guard_Targets__r.has(COMPLIANT)", "runtimeError" : null } }, { "Id" : "test2", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "200", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "200", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test4", "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" : "test1" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "Id" : "test4" } ]; """; CREATE TEMP FUNCTION mock_CA10O1__CaOracleCloudGuardTarget__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "CA10O1__lifecycleState__c" : "ACTIVE", "CA10O1__targetResourceOcid__c" : "ocid1.tenancy.oc1..root", "CA10O1__tenancy__c" : "test1", "Id" : "test1_1" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "CA10O1__lifecycleState__c" : "ACTIVE", "CA10O1__targetResourceOcid__c" : "ocid1.compartment.oc1..child", "CA10O1__tenancy__c" : "test2", "Id" : "test2_1" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "CA10O1__lifecycleState__c" : "INACTIVE", "CA10O1__targetResourceOcid__c" : "ocid1.tenancy.oc1..root", "CA10O1__tenancy__c" : "test4", "Id" : "test4_1" } ]; """; CREATE TEMP FUNCTION process_CA10O1__CaOracleTenancy__c( obj STRUCT< Id STRING, CA10O1__Oracle_Cloud_Guard_Targets__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_Cloud_Guard_Targets__r_COMPLIANT2 = 0; if (obj.CA10O1__Oracle_Cloud_Guard_Targets__r != null) { for (var i3 = 0; i3 < obj.CA10O1__Oracle_Cloud_Guard_Targets__r.length; i3++) { if (typeof(obj.CA10O1__Oracle_Cloud_Guard_Targets__r[i3].status) !== 'undefined') { if (obj.CA10O1__Oracle_Cloud_Guard_Targets__r[i3].status == 'COMPLIANT') { count_CA10O1__Oracle_Cloud_Guard_Targets__r_COMPLIANT2 += obj.CA10O1__Oracle_Cloud_Guard_Targets__r[i3].count; } } else { if (obj.CA10O1__Oracle_Cloud_Guard_Targets__r[i3].result.status == 'COMPLIANT') { count_CA10O1__Oracle_Cloud_Guard_Targets__r_COMPLIANT2 += 1; } } } } // condition[1], conditionIndex:[100..199] references1.push('Related list [CA10O1__Oracle_Cloud_Guard_Targets__r] ' + (count_CA10O1__Oracle_Cloud_Guard_Targets__r_COMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in COMPLIANT status'); if (count_CA10O1__Oracle_Cloud_Guard_Targets__r_COMPLIANT2 > 0) { return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "CA10O1__Oracle_Cloud_Guard_Targets__r.has(COMPLIANT)", currentStateMessage: "Cloud Guard is enabled for the root compartment of this tenancy.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'INCOMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "Cloud Guard is not enabled for the root compartment of this tenancy.", currentStateReferences: references1.join('\n'), remediation: "Enable Oracle Cloud Guard and configure an active target for the root compartment.", runtimeError: null}; """; CREATE TEMP FUNCTION process_CA10O1__Oracle_Cloud_Guard_Targets__r( obj STRUCT< CA10O1__disappearanceTime__c TIMESTAMP, CA10O1__lifecycleState__c STRING, CA10O1__targetResourceOcid__c 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] references1.push('Deleted From Oracle [CA10O1__disappearanceTime__c]: ' + obj.CA10O1__disappearanceTime__c); if (obj.CA10O1__disappearanceTime__c != null) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10O1__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.CA10O1__lifecycleState__c; } return this.out; }; function extract6() { if (!this.out) { this.out = obj.CA10O1__targetResourceOcid__c; } return this.out; }; references1.push('Lifecycle State [obj.CA10O1__lifecycleState__c]: ' + obj.CA10O1__lifecycleState__c); references1.push('Target Resource OCID [obj.CA10O1__targetResourceOcid__c]: ' + obj.CA10O1__targetResourceOcid__c); if (TextLib.equal(extract3.call(extract3), 'ACTIVE') && TextLib.startsWith(extract6.call(extract6), 'ocid1.tenancy.')) { return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10O1__lifecycleState__c') == 'ACTIVE' && extract('CA10O1__targetResourceOcid__c').startsWith('ocid1.tenancy.')", currentStateMessage: "This active Cloud Guard target monitors the root compartment.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'INAPPLICABLE', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "This Cloud Guard target is inactive or does not monitor the root 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_Cloud_Guard_Targets__r`.arr AS CA10O1__Oracle_Cloud_Guard_Targets__r, process_CA10O1__CaOracleTenancy__c( STRUCT( sObject.Id AS Id, `CA10O1__Oracle_Cloud_Guard_Targets__r`.arr AS CA10O1__Oracle_Cloud_Guard_Targets__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__disappearanceTime__c AS CA10O1__disappearanceTime__c, sObject.CA10O1__lifecycleState__c AS CA10O1__lifecycleState__c, sObject.CA10O1__targetResourceOcid__c AS CA10O1__targetResourceOcid__c, sObject.CA10O1__tenancy__c AS CA10O1__tenancy__c, sObject.Id AS Id, process_CA10O1__Oracle_Cloud_Guard_Targets__r( STRUCT( sObject.CA10O1__disappearanceTime__c AS CA10O1__disappearanceTime__c, sObject.CA10O1__lifecycleState__c AS CA10O1__lifecycleState__c, sObject.CA10O1__targetResourceOcid__c AS CA10O1__targetResourceOcid__c, sObject.CA10O1__tenancy__c AS CA10O1__tenancy__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result ) ) AS arr FROM UNNEST(mock_CA10O1__CaOracleCloudGuardTarget__c()) AS sObject GROUP BY sObject.CA10O1__tenancy__c ) AS `CA10O1__Oracle_Cloud_Guard_Targets__r` ON sObject.Id = `CA10O1__Oracle_Cloud_Guard_Targets__r`.CA10O1__tenancy__c ) sObject ON sObject.Id = expectedResult.Id;