Proofpoint Cloud Threat Response

Fetches Proofpoint Cloud Threat Response (CTR) incidents into Cortex XSOAR for case management, and exposes commands to list and retrieve incident details.

Case Management · Proofpoint Cloud Threat Response

Details

IDProofpoint Cloud Threat Response
ProviderProofpoint
CategoryCase Management
From Version6.10.0
Docker Imagedemisto/fastapi:0.125.0.10158186
Supported ModulesAgentix XSIAM

README

Fetches Proofpoint Cloud Threat Response (CTR) incidents into Cortex XSOAR for case management, and exposes commands to list and retrieve incident details.
This integration was integrated and tested with version 1.0 of Proofpoint Cloud Threat Response.

Configure Proofpoint Cloud Threat Response in Cortex

Parameter Description Required
Server URL The base URL of the Proofpoint Cloud Threat Response API. True
Client ID The Client ID and Client Secret generated from your Proofpoint Threat Response account (API Key Management). True
Client Secret   True
Fetch incidents   False
Incident type   False
First fetch timestamp (<number> <time unit>, e.g., 12 hours, 7 days)   False
Maximum number of incidents per fetch The maximum number of incidents to fetch each interval. Default and maximum is 200. False
Fetch delta (minutes) An additional buffer (in minutes) subtracted from the start of each fetch window to mitigate clock drift and ensure no incidents are missed. False
Fetch incidents with specific states Must be set when fetch is enabled. Selecting both `open_incidents` and `closed_incidents` returns an empty result from the upstream API. False
Enrich incidents during fetch When enabled, each fetched incident is enriched with full details (activities, comments, message source data) by calling the GET /incidents/{id} endpoint once per incident. Disable when fetching large volumes to avoid rate limits. False
Trust any certificate (not secure)   False
Use system proxy settings   False

Commands

You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.

proofpoint-ctr-incidents-list


Returns a list of Proofpoint Cloud Threat Response incidents matching the supplied filters.

Base Command

proofpoint-ctr-incidents-list

Input

Argument Name Description Required
start_time The start of the time range filter. Accepts a free text date (e.g., 3 days, 2024-11-26T16:18:07Z). Optional
end_time The end of the time range filter. Accepts a free text date. Defaults to now when omitted. Optional
incident_id_filters A comma-separated list of incident displayId values (numeric). For example, 781,782. Optional
source_filters Filter incidents by source. Possible values are: abuse_mailbox, tap, smart_search, message_csv_upload. Optional
other_filters Filter incidents by state or VAP. Selecting both open_incidents and closed_incidents returns an empty result from the upstream API. Possible values are: open_incidents, closed_incidents, vap. Optional
verdict_filters Filter incidents by verdict. Possible values are: verdict_failed, verdict_low_risk, verdict_manual_review, verdict_threat. Optional
disposition Filter incidents by disposition. Possible values are: bulk, clean, impostor, in_progress, internal, low_risk, malware, manual_review, not_set, phish, scam, simulated_phish, spam, suspicious, tap_false_positive, toad, vendor. Optional
confidence_filters Filter incidents by confidence level. Possible values are: confidence_high, confidence_medium, confidence_low. Optional
limit The maximum number of incidents to return. Default is 50. Optional

Context Output

Path Type Description
ProofPointCloud.Incident.id String The internal UUID of the incident.
ProofPointCloud.Incident.displayId Number The numeric display ID of the incident.
ProofPointCloud.Incident.title String The incident title.
ProofPointCloud.Incident.state String The state of the incident (open/closed).
ProofPointCloud.Incident.createdAt Date The creation timestamp of the incident.
ProofPointCloud.Incident.updatedAt Date The last update timestamp of the incident.
ProofPointCloud.Incident.messageCount Number The number of messages associated with the incident.
ProofPointCloud.Incident.assignedTeamName String The name of the team the incident is assigned to.
ProofPointCloud.Incident.priority String The priority of the incident.
ProofPointCloud.Incident.closedAt Date The timestamp when the incident was closed, if applicable.
ProofPointCloud.Incident.assignedUserName String The username of the individual the incident is assigned to.
ProofPointCloud.Incident.sourceTypes Array The list of source types that produced the incident.
ProofPointCloud.Incident.dispositions Array The list of dispositions assigned to the incident.
ProofPointCloud.Incident.clearVerdicts Array The list of clear verdicts for the incident.
ProofPointCloud.Incident.clearConfidences Array The list of confidence values for the incident.
ProofPointCloud.Incident.sourcesData Array The raw sources data array for the incident.

Command Example

!proofpoint-ctr-incidents-list limit=2

Context Example

[
    {
        "id": "00000000-0000-0000-0000-000000000001",
        "createdAt": "2024-01-01T10:00:00.000+00:00",
        "updatedAt": "2024-01-01T10:05:00.000+00:00",
        "displayId": 12345,
        "priority": "high",
        "title": "user[@]example[.]com reported a message \"Suspicious phishing attempt\"",
        "state": "open",
        "assignedTeamName": "SOC_Analyst",
        "messageCount": 1,
        "sourceTypes": ["abuse_mailbox"],
        "sourcesData": [{"type": "AbuseMailbox", "name": "Proofpoint CLEAR"}],
        "dispositions": ["manual_review"],
        "clearVerdicts": ["manual_review"],
        "clearConfidences": ["low"]
    },
    {
        "id": "00000000-0000-0000-0000-000000000002",
        "createdAt": "2024-01-01T09:00:00.000+00:00",
        "updatedAt": "2024-01-01T09:30:00.000+00:00",
        "closedAt": "2024-01-01T09:30:00.000+00:00",
        "displayId": 12344,
        "priority": null,
        "title": "other[@]example[.]com reported a message \"Low risk email review\"",
        "state": "closed",
        "assignedTeamName": "SOC_Analyst",
        "messageCount": 18,
        "sourceTypes": ["abuse_mailbox"],
        "sourcesData": [{"type": "AbuseMailbox", "name": "Proofpoint CLEAR"}],
        "dispositions": ["low_risk"],
        "clearVerdicts": ["low_risk"],
        "clearConfidences": ["high"]
    }
]

Human Readable Output

Proofpoint Cloud Threat Response Incidents

ID Created At Type State Message Count Assigned Team Name Title Source Types
00000000-0000-0000-0000-000000000001 2024-01-01T10:00:00.000+00:00 AbuseMailbox open 1 SOC_Analyst user[@]example[.]com reported a message “Suspicious phishing attempt” abuse_mailbox
00000000-0000-0000-0000-000000000002 2024-01-01T09:00:00.000+00:00 AbuseMailbox closed 18 SOC_Analyst other[@]example[.]com reported a message “Low risk email review” abuse_mailbox

proofpoint-ctr-incident-get


Returns full details for a specific Proofpoint Cloud Threat Response incident.

Base Command

proofpoint-ctr-incident-get

Input

Argument Name Description Required
incident_id A comma-separated list of incident UUIDs (e.g., 440def43-c322-42ba-a6d6-a2306128ea3b). Required

Context Output

Path Type Description
ProofPointCloud.Incident.id String The internal UUID of the incident.
ProofPointCloud.Incident.displayId Number The numeric display ID of the incident.
ProofPointCloud.Incident.title String The incident title.
ProofPointCloud.Incident.state String The state of the incident.
ProofPointCloud.Incident.createdAt Date The creation timestamp of the incident.
ProofPointCloud.Incident.updatedAt Date The last update timestamp of the incident.
ProofPointCloud.Incident.priority String The priority of the incident.
ProofPointCloud.Incident.messageCount Number The number of messages associated with the incident.
ProofPointCloud.Incident.assignedTeamName String The name of the team the incident is assigned to.
ProofPointCloud.Incident.assignedApplicationUserName String The user the incident is assigned to.
ProofPointCloud.Incident.closedAt Date The timestamp when the incident was closed, if applicable.
ProofPointCloud.Incident.openedAt Date The timestamp when the incident was opened.
ProofPointCloud.Incident.messageSourceData Unknown Breakdown of message sources (TAP, abuse mailbox, smart search, etc.) for the incident.
ProofPointCloud.Incident.comments Array The comments associated with the incident.
ProofPointCloud.Incident.activities Array The activities associated with the incident.

Command Example

!proofpoint-ctr-incident-get incident_id=00000000-0000-0000-0000-000000000001

Context Example

{
    "id": "00000000-0000-0000-0000-000000000001",
    "createdAt": "2024-01-01T10:00:00.000+00:00",
    "updatedAt": "2024-01-01T10:05:00.000+00:00",
    "displayId": 12345,
    "priority": "high",
    "state": "open",
    "title": "user[@]example[.]com reported a message \"Suspicious phishing attempt\"",
    "closedAt": null,
    "openedAt": "2024-01-01T10:00:00.000+00:00",
    "assignedTeamName": "SOC_Analyst",
    "assignedApplicationUserName": null,
    "messageCount": 1,
    "messageSourceData": {
        "hasTapAlert": false,
        "hasAbuseAlert": true,
        "hasSmartSearchImport": false,
        "hasMessageCsvUpload": false,
        "hasWorkbenchEvent": false,
        "hasImdAlert": false,
        "hasMailBombAlert": false
    },
    "comments": [],
    "activities": [
        {
            "id": "00000000-0000-0000-0000-000000000006",
            "cause_type": "system",
            "created_at": "2024-01-01T10:00:00.000",
            "occurred_at": "2024-01-01T10:00:00.000000",
            "activity_type": "incident_creation",
            "activity_details": {
                "source_name": "Proofpoint CLEAR",
                "initial_priority": null,
                "initial_team_name": "SOC_Analyst"
            },
            "causing_user_name": null,
            "causing_workflow_name": null
        },
        {
            "id": "00000000-0000-0000-0000-000000000008",
            "cause_type": "history",
            "created_at": "2024-01-01T10:00:10.000",
            "activity_type": "quarantine",
            "activity_details": {
                "quarantine_attempts": [
                    {
                        "state": "complete",
                        "disposition": "message_moved"
                    }
                ]
            },
            "causing_workflow_name": "Official Manual Review"
        }
    ]
}

Human Readable Output

Proofpoint Cloud Threat Response Incident: 12345

ID Created At State Message Count Assigned Team Name Title
00000000-0000-0000-0000-000000000001 2024-01-01T10:00:00.000+00:00 open 1 SOC_Analyst user[@]example[.]com reported a message “Suspicious phishing attempt”

Known Limitations

Fetch Enrichment and API Rate Limits

By default, the “Enrich incidents during fetch” parameter is disabled. When disabled, each fetch cycle makes a single API call to retrieve the incident list, and the raw JSON stored per incident contains only the fields returned by the list endpoint (summary fields such as id, title, state, createdAt, messageCount, etc.).

When enrichment is enabled, the integration makes one additional GET /api/v1/tric/incidents/{id} call per incident in every fetch cycle. This provides richer data immediately (activities, comments, messageSourceData) but multiplies API call volume proportionally to the number of incidents fetched. In environments with high incident volume this can trigger Proofpoint API rate limits (HTTP 429).

Recommended approach for high-volume environments:

  1. Keep “Enrich incidents during fetch” disabled (default).
  2. Use the proofpoint-ctr-incident-get command to enrich individual incidents on demand from a playbook or manually from the War Room.
  3. Because both commands write to the same context key (ProofPointCloud.Incident.id), running proofpoint-ctr-incident-get after proofpoint-ctr-incidents-list will enrich the existing context entry rather than creating a duplicate.

Configuration parameters

  • url — Server URL (required)
  • credentials — Client ID (required)
  • insecure — Trust any certificate (not secure)
  • proxy — Use system proxy settings
  • isFetch — Fetch incidents
  • incidentType — Incident type
  • incidentFetchInterval — Incidents Fetch Interval
  • first_fetch — First fetch timestamp (<number> <time unit>, e.g., 12 hours, 7 days)
  • max_fetch — Maximum number of incidents per fetch
  • fetch_delta — Fetch delta (minutes)
  • fetch_states — Fetch incidents with specific states
  • fetch_enrich — Enrich incidents during fetch

Commands (2)

  • proofpoint-ctr-incident-get

    Returns full details for a specific Proofpoint Cloud Threat Response incident.

  • proofpoint-ctr-incidents-list

    Returns a list of Proofpoint Cloud Threat Response incidents matching the supplied filters.

"""Unit tests for the Proofpoint Cloud Threat Response integration."""

import json
from pathlib import Path
from typing import Any

import pytest

from ProofpointCloudThreatResponse import (
    Client,
    ProofpointCTRAuthHandler,
    build_filters_body,
    fetch_incidents,
    format_ctr_date,
    parse_ctr_date,
    proofpoint_ctr_incident_get_command,
    proofpoint_ctr_incidents_list_command,
    run_test_module,
)

TEST_DATA = Path(__file__).parent / "test_data"
BASE_URL = "https://threatprotection-api.proofpoint.com"


def _load(name: str) -> dict:
    with (TEST_DATA / name).open() as fp:
        return json.load(fp)


@pytest.fixture()
def _patch_context(mocker):
    """Patch context-store I/O so the auth handler never hits the runtime."""
    mocker.patch.object(ProofpointCTRAuthHandler, "_load_token_from_context")
    mocker.patch.object(ProofpointCTRAuthHandler, "_save_token_to_context")


@pytest.fixture()
def client(_patch_context, mocker) -> Client:
    """Return a Client whose ``_http_request`` is mock-able per test."""
    # Avoid initializing the underlying ContentClient (httpx etc.) - we mock the
    # I/O surface exposed by Client.list_incidents / Client.get_incident.
    mocker.patch("ProofpointCloudThreatResponse.ContentClient.__init__", return_value=None)
    instance = Client.__new__(Client)
    # Provide just enough state for the test:
    instance.timeout = 60.0  # type: ignore[attr-defined]
    return instance


# --------------------------------------------------------------------------- helpers


def test_format_ctr_date_strips_timezone():
    from datetime import datetime

    formatted = format_ctr_date(datetime(2024, 11, 26, 16, 18, 7))
    assert formatted == "2024-11-26 16:18:07"


def test_parse_ctr_date_handles_freetext():
    parsed = parse_ctr_date("2024-11-26 16:18:07")
    assert parsed is not None
    assert parsed.year == 2024
    assert parsed.month == 11


def test_build_filters_body_omits_empty_filters():
    from datetime import datetime

    body = build_filters_body(
        start_time=datetime(2024, 11, 26, 16, 18, 7),
        end_time=datetime(2024, 11, 26, 16, 19, 7),
        end_row=10,
    )
    assert body == {
        "filters": {
            "time_range_filter": {
                "start": "2024-11-26 16:18:07",
                "end": "2024-11-26 16:19:07",
            },
        },
        "startRow": 0,
        "endRow": 10,
        "sortParams": [{"sort": "desc", "colId": "createdAt"}],
    }


def test_build_filters_body_validates_allowed_values():
    with pytest.raises(Exception, match="source_filters"):
        build_filters_body(source_filters=["bogus"])


# --------------------------------------------------------------------------- auth


def test_auth_handler_rejects_empty_credentials():
    from ProofpointCloudThreatResponse import ProofpointCTRAuthHandler

    with pytest.raises(Exception, match="Client ID"):
        ProofpointCTRAuthHandler(client_id="", client_secret="x")
    with pytest.raises(Exception, match="Client Secret"):
        ProofpointCTRAuthHandler(client_id="x", client_secret="")


def test_auth_handler_token_validity(mocker):
    import time as _time

    mocker.patch.object(ProofpointCTRAuthHandler, "_load_token_from_context")
    handler = ProofpointCTRAuthHandler(client_id="id", client_secret="secret")

    handler._access_token = "abc"
    handler._expires_at = int(_time.time()) + 3600
    assert handler._token_is_valid() is True

    handler._expires_at = int(_time.time()) - 1
    assert handler._token_is_valid() is False

    handler._access_token = None
    handler._expires_at = int(_time.time()) + 3600
    assert handler._token_is_valid() is False


# --------------------------------------------------------------------------- commands


def test_list_incidents_command_builds_output(client: Client, mocker):
    mocker.patch.object(Client, "list_incidents", return_value=_load("incidents_list.json"))

    result = proofpoint_ctr_incidents_list_command(
        client,
        {"limit": "10", "source_filters": "abuse_mailbox"},
    )
    assert result.outputs_prefix == "ProofPointCloud.Incident"
    assert len(result.outputs) == 2
    assert result.outputs[0]["id"] == "00000000-0000-0000-0000-000000000001"
    assert "Suspicious phishing attempt" in result.readable_output


def test_list_incidents_rejects_invalid_filter(client: Client):
    with pytest.raises(Exception, match="other_filters"):
        proofpoint_ctr_incidents_list_command(client, {"other_filters": "bogus"})


def test_get_incident_command_iterates_ids(client: Client, mocker):
    calls: list[str] = []

    def _fake_get(self, incident_id: str) -> dict[str, Any]:
        calls.append(incident_id)
        return _load("incident_get.json")

    mocker.patch.object(Client, "get_incident", _fake_get)

    result = proofpoint_ctr_incident_get_command(client, {"incident_id": "aaa,bbb"})
    assert calls == ["aaa", "bbb"]
    assert len(result.outputs) == 2
    # The get command flattens the summary fields to the top level so that
    # outputs_key_field="id" matches the list command and XSOAR can enrich
    # the existing context entry rather than creating a duplicate.
    assert result.outputs[0]["displayId"] == 12345


def test_get_incident_requires_id(client: Client):
    with pytest.raises(Exception, match="incident_id"):
        proofpoint_ctr_incident_get_command(client, {})


# --------------------------------------------------------------------------- test_module


def test_test_module_ok(client: Client, mocker):
    mocker.patch.object(Client, "list_incidents", return_value={"incidents": []})
    assert run_test_module(client, {"isFetch": False}) == "ok"


def test_test_module_rejects_both_states(client: Client):
    msg = run_test_module(
        client,
        {"isFetch": True, "fetch_states": "open_incidents,closed_incidents"},
    )
    assert "empty result" in msg


def test_test_module_requires_state_when_fetching(client: Client):
    msg = run_test_module(client, {"isFetch": True, "fetch_states": ""})
    assert "must select at least one" in msg


# --------------------------------------------------------------------------- fetch


def test_fetch_incidents_first_run(client: Client, mocker):
    mocker.patch.object(Client, "list_incidents", return_value=_load("incidents_list.json"))
    mocker.patch.object(Client, "get_incident", return_value=_load("incident_get.json"))

    next_run, incidents = fetch_incidents(
        client,
        {
            "first_fetch": "3 days",
            "max_fetch": "50",
            "fetch_delta": "1",
            "fetch_states": "open_incidents",
        },
        last_run={},
    )
    assert len(incidents) == 2
    assert incidents[0]["dbotMirrorId"] == "00000000-0000-0000-0000-000000000001"
    assert "last_fetch" in next_run
    assert "last_fetched_ids" in next_run
    # last_fetch must be the createdAt of the latest incident (incident 1: 2024-01-01T10:00:00)
    assert next_run["last_fetch"] == "2024-01-01 10:00:00"


def test_fetch_incidents_dedupes_seen_ids(client: Client, mocker):
    mocker.patch.object(Client, "list_incidents", return_value=_load("incidents_list.json"))
    mocker.patch.object(Client, "get_incident", return_value=_load("incident_get.json"))

    next_run, incidents = fetch_incidents(
        client,
        {
            "first_fetch": "3 days",
            "max_fetch": "50",
            "fetch_delta": "1",
            "fetch_states": "open_incidents",
        },
        last_run={
            "last_fetch": "2024-01-01 08:00:00",
            "last_fetched_ids": ["00000000-0000-0000-0000-000000000001"],
        },
    )
    assert len(incidents) == 1
    assert incidents[0]["dbotMirrorId"] == "00000000-0000-0000-0000-000000000002"
    # last_fetch should advance to the createdAt of the latest new incident (incident 2)
    assert next_run["last_fetch"] == "2024-01-01 09:00:00"


def test_fetch_incidents_rejects_both_states(client: Client):
    with pytest.raises(Exception, match="empty result"):
        fetch_incidents(
            client,
            {
                "first_fetch": "3 days",
                "fetch_states": "open_incidents,closed_incidents",
            },
            last_run={},
        )


def test_fetch_incidents_caps_max_fetch(client: Client, mocker):
    captured: dict = {}

    def _capture(self, body):
        captured.update(body)
        return {"incidents": []}

    mocker.patch.object(Client, "list_incidents", _capture)

    fetch_incidents(
        client,
        {
            "first_fetch": "3 days",
            "max_fetch": "9999",
            "fetch_delta": "0",
            "fetch_states": "open_incidents",
        },
        last_run={},
    )
    # max_fetch is capped at MAX_PAGE_SIZE (200) -> endRow = 200 (exclusive upper bound)
    assert captured["endRow"] == 200
    assert captured["startRow"] == 0
    assert captured["sortParams"] == [{"sort": "asc", "colId": "createdAt"}]
    assert captured["filters"]["other_filters"] == ["open_incidents"]