---
policy: /ce/ca/aws/mq/broker-public-access
logic: /ce/ca/aws/mq/broker-public-access/prod.logic.yaml
executionTime: 2026-01-31T12:02:07.067639771Z
generationMs: 54
executionMs: 900
rows:
  - id: '001'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__publiclyAccessible__c') == true
      actual: extract('CA10__publiclyAccessible__c') == true
    runtimeError: {}
  - id: '002'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/mq/broker-public-access/policy.yaml
    md5Hash: 33253209054F79C56FEC3B3A5E310129
    content: "---\nnames:\n  full: \"AWS MQ Broker is publicly accessible\"\n  contextual:\
      \ \"Broker is publicly accessible\"\ndescription: >\n  Identify Amazon MQ brokers\
      \ that are configured with public accessibility. \n  Publicly accessible brokers\
      \ are exposed to the internet, increasing the \n  attack surface and potential\
      \ for unauthorized access.\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n  - \"\
      SECURITY\"\nframeworkMappings:\n  - \"/frameworks/cloudaware/resource-security/public-and-anonymous-access\"\
      \n  - \"/frameworks/aws-well-architected/sec/08/04\"\nsimilarPolicies:\n  cloudConformity:\n\
      \    - url: \"https://www.trendmicro.com/cloudoneconformity/knowledge-base/aws/MQ/publicly-accessible.html\"\
      \n      name: \"Publicly Accessible MQ Brokers\"\n"
  - path: /ce/ca/aws/mq/broker-public-access/prod.logic.yaml
    md5Hash: 3DC576EF3778BB68642873EE0C9D1501
    content: |
      ---
      inputType: "CA10__CaAwsMqBroker__c"
      testData:
        - file: "test-data.json"
      importExtracts:
        - file: "/types/CA10__CaAwsMqBroker__c/object.extracts.yaml"
      conditions:
        - status: "INCOMPLIANT"
          currentStateMessage: "The broker is not configured to block public access."
          remediationMessage: "Consider configuring the broker to block public access."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__publiclyAccessible__c"
              right:
                BOOLEAN: true
      otherwise:
        status: "COMPLIANT"
        currentStateMessage: "The broker is configured to block public access."
  - path: /ce/ca/aws/mq/broker-public-access/test-data.json
    md5Hash: 6870D4536C51769CFF975456E13EAD8F
    content: |
      [
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "199",
            "conditionText": "extract('CA10__publiclyAccessible__c') == true",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-16T12:12:52Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__publiclyAccessible__c": true,
          "Id": "001"
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-16T12:12:52Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__publiclyAccessible__c": false,
          "Id": "002"
        }
      ]
  - path: /types/CA10__CaAwsMqBroker__c/object.extracts.yaml
    md5Hash: 1D91E5184493B4B1AF50FC5A1E53B744
    content: "---\nextracts:\n  # Checkbox.\n  - name: CA10__publiclyAccessible__c\n\
      \    value: \n      FIELD:\n        path: CA10__publiclyAccessible__c\n  # Checkbox.\n\
      \  - name: CA10__autoMinorVersionUpgrade__c\n    value: \n      FIELD:\n   \
      \     path: CA10__autoMinorVersionUpgrade__c\n  # Text.\n  - name: CA10__deploymentMode__c\n\
      \    value: \n      FIELD:\n        path: CA10__deploymentMode__c\n# Values:\
      \ Enabled | Disabled. Nullable.\n  - name: \"CA10__logsAudit__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10__logsAudit__c\"\n# Values: ACTIVEMQ |\
      \ RABBITMQ. Not nullable. \n  - name: \"CA10__engineType__c\"\n    value: \n\
      \      FIELD:\n        path: \"CA10__engineType__c\"\n        undeterminedIf:\n\
      \          noAccessDelegate:\n            path: \"CA10__engineType__c\"\n  \
      \          currentStateMessage: \"Broker Engine type cannot be empty. Possible\
      \ permission issue with mq:DescribeBroker.\"\n"
script: |-
  CREATE TEMP FUNCTION mock_ExpectedResult()
  RETURNS ARRAY<STRUCT<
          Id STRING,
          expectedResult STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, runtimeError STRING>
      >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "Id" : "001",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__publiclyAccessible__c') == true",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsMqBroker__c()
  RETURNS ARRAY<STRUCT<
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__publiclyAccessible__c BOOLEAN,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-12-16T12:12:52Z")
    },
    "CA10__publiclyAccessible__c" : true,
    "Id" : "001"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-16T12:12:52Z")
    },
    "CA10__publiclyAccessible__c" : false,
    "Id" : "002"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsMqBroker__c(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__publiclyAccessible__c BOOLEAN,
          Id STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
      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__publiclyAccessible__c; } return this.out; };
      references1.push('Publicly Accessible [obj.CA10__publiclyAccessible__c]: ' + obj.CA10__publiclyAccessible__c);
      if (extract3.call(extract3) == true) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__publiclyAccessible__c') == true", currentStateMessage: "The broker is not configured to block public access.", currentStateReferences: references1.join('\n'), remediation: "Consider configuring the broker to block public access.", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "The broker is configured to block public access.", 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__publiclyAccessible__c AS CA10__publiclyAccessible__c,
          sObject.Id AS Id,
          process_CA10__CaAwsMqBroker__c(
              STRUCT(
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__publiclyAccessible__c AS CA10__publiclyAccessible__c,
                  sObject.Id AS Id
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsMqBroker__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
