Skip to content

feat(pan-cortex-xdr-intel): implement shared integration foundation and global error handling (#7185) - #7331

Open
Pauline Eustachy (Powlinett) wants to merge 5 commits into
feat/7184-pan-cortex-xdr-intel-api-clientfrom
feat/7185-pan-cortex-xdr-intel-integration-foundation
Open

feat(pan-cortex-xdr-intel): implement shared integration foundation and global error handling (#7185)#7331
Pauline Eustachy (Powlinett) wants to merge 5 commits into
feat/7184-pan-cortex-xdr-intel-api-clientfrom
feat/7185-pan-cortex-xdr-intel-integration-foundation

Conversation

@Powlinett

Copy link
Copy Markdown
Member

Proposed changes

  • Add EventIndicator/IndicatorObservable pydantic models decoupling downstream upsert/delete handlers from OpenCTI's raw STIX stream payload shape (field casting/validation delegated to pydantic to fail fast).
  • Implement Connector._process_message: entity/event guardrails (non-Indicator and unsupported-event stream messages are logged as a warning and skipped), indicator parsing via _parse_indicator, and observable extraction restricted to Cortex XDR's currently-supported types.
  • Add global processing error handling: JSON decode errors, Indicator validation errors, and any other unexpected exception are logged with context and re-raised, letting pycti kill the connector process rather than risk silently missing/corrupting further stream events.
  • Replace the filigran_sseclient.Event typing dependency with a local StreamMessage Protocol declaring only the attributes actually consumed.
  • Add unit tests covering the model's field_validator and the connector's guardrails/parsing/error-handling behavior.
  • Add an anonymized sample stream message fixture under data_samples/ for local/manual reference.

Related issues

Checklist

  • I consider the submitted work as finished
  • I have signed my commits using GPG key.
  • I tested the code for its functionality using different use cases
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

This PR stacks on top of #7309 (#7184 - Cortex XDR API client). Upsert/delete lifecycle logic (#7186/#7187) is intentionally out of scope here; the corresponding try/except block in _process_message currently wraps pass placeholders, documented by a strict=True xfail test that must be removed once real client calls land there.

While investigating the observable → Cortex XDR IOC type mapping (comments left on #7186/#7187), found that the XDR IOC API's type enum has no dedicated URL/EMAIL_ADDRESS value; url/email-addr were dropped from _SUPPORTED_OBSERVABLE_TYPES for this reason, to be revisited when #7186/#7187 land.

Introduce EventIndicator/IndicatorObservable pydantic models to decouple
downstream upsert/delete handlers from OpenCTI's raw STIX stream payload
shape. Field casting/validation is delegated to pydantic to fail fast.

The observables field_validator flattens a StixFile's filename and each
hash algorithm value into separate observables, since Cortex XDR treats
them as distinct IOC types (FILENAME vs HASH).
Implement _process_message: filter unsupported events/entity types (log
+ skip), decode the stream payload, and parse it into an EventIndicator
via _parse_indicator, restricting extracted observables to the types
Cortex XDR can currently consume.

JSON decode errors, Indicator validation errors, and any other
unexpected exception are logged with context and re-raised, letting
pycti kill the connector process instead of silently missing or
corrupting further stream events.

Replace the filigran_sseclient.Event typing dependency with a local
StreamMessage Protocol declaring only the attributes actually consumed.
Cover EventIndicator's observables field_validator (valid/invalid
construction, StixFile hash/filename flattening, missing value/hashes,
None defaulting).
…ling

Cover Connector._process_message's event/entity guardrails, indicator
parsing, and fatal error handling (JSON decode error, validation error,
and a documented xfail for the not-yet-implemented upsert/delete error
path).
Add an anonymized example SSE stream message (Indicator create event
with a StixFile observable) illustrating the payload shape consumed
by Connector._process_message, for local/manual reference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

filigran team Item from the Filigran team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants