Skip to content

Add configurable output mode: Report (default) or Incident#26

Merged
notdodo merged 3 commits into
mainfrom
claude/separate-event-reports-HNyMZ
Mar 18, 2026
Merged

Add configurable output mode: Report (default) or Incident#26
notdodo merged 3 commits into
mainfrom
claude/separate-event-reports-HNyMZ

Conversation

@luca-m
Copy link
Copy Markdown
Contributor

@luca-m luca-m commented Mar 18, 2026

Summary

This PR introduces a configurable output mode for the DEP connector, allowing announcements to be modeled as either STIX Reports (new default) or Incidents (legacy mode). The Report mode wraps all correlated entities and relationships in a single STIX Report container, while Incident mode creates standalone Incident objects with explicit relationship edges.

Key Changes

  • New configuration option: DEP_OUTPUT_MODE (default: report)

    • report: Each announcement becomes a STIX Report with all entities and relationships in object_refs
    • incident: Each announcement becomes a STIX Incident with explicit targets, attributed-to, and indicates relationships
  • Report creation: New _create_report() method generates STIX 2.1 Report objects with:

    • Deterministic ID based on DEP hashid (uuid5)
    • Name format: DEP announcement - <victim> (with fallbacks)
    • Custom properties for actor and country when present
    • External references and labels matching incident behavior
  • Refactored processing logic:

    • _process_item() now dispatches to _process_item_as_incident() or _process_item_as_report() based on output mode
    • _build_optional_entities() now accepts optional incident_id parameter instead of full incident object, enabling reuse for both modes
    • New _build_cross_entity_relationships() method extracts cross-entity relationship logic (intrusion set → sector/country, sector → country)
  • Label generation: Renamed _build_incident_labels() to _build_labels() for mode-agnostic use

  • Type annotations: Added explicit type hints for external reference dictionaries

  • Documentation updates:

    • Updated AGENTS.md with output mode behavior, Report data model mappings, and relationship differences between modes
    • Updated README.md to reflect Report as default and clarify mode-specific behavior
    • Updated config.yml.sample with new output_mode configuration
    • Updated connector scope to include report

Notable Implementation Details

  • Report mode is the new default, providing a cleaner Knowledge Graph structure for analysis
  • Both modes maintain deterministic IDs for idempotent updates under update=True
  • In Report mode, indicators are included in object_refs without separate indicates edges; in Incident mode, explicit indicates relationships are created
  • The attributed-to relationship (intrusion set → incident) is only created in Incident mode; Report mode includes the intrusion set in object_refs instead
  • Cross-entity relationships (intrusion set → sector/country, sector → country) are created in both modes but handled differently (explicit edges in Incident mode, implicit via object_refs in Report mode)

https://claude.ai/code/session_01RM1YrEYNTjThrpgLftgW2D

Introduces a new `DEP_OUTPUT_MODE` configuration variable (env:
`DEP_OUTPUT_MODE`, YAML: `dep.output_mode`, default: `report`).

In `report` mode (new default) each DEP announcement is wrapped in a
STIX 2.1 `Report` container whose `object_refs` includes all correlated
entities and relationships (victim, indicators, intrusion set, country,
sector). This matches how other connectors/feeds work and produces a
pre-correlated Knowledge Graph view directly in OpenCTI.

In `incident` mode (previous behaviour) a standalone STIX `Incident`
is created with explicit `targets`, `attributed-to`, and `indicates`
relationship edges, preserving full backward compatibility.

Key implementation details:
- `_create_report()` produces a deterministic `report--uuid5` ID from
  the DEP `hashid` namespace, identical logic to the former incident.
- `_build_optional_entities()` now takes an optional `incident_id`
  parameter; the `attributed-to` edge is only emitted when it is set
  (incident mode only).
- Cross-entity relationships extracted to `_build_cross_entity_relationships()`
  to keep cyclomatic complexity within the ruff C901 limit.
- `_process_item` dispatches to `_process_item_as_report()` or
  `_process_item_as_incident()` based on `output_mode`.
- Connector scope updated to `report,incident,identity,indicator`.
- `config.yml.sample`, `README.md`, and `AGENTS.md` updated accordingly.

https://claude.ai/code/session_01RM1YrEYNTjThrpgLftgW2D
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 18, 2026

kics-logo

KICS version: v2.1.20

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 0
LOW LOW 0
INFO INFO 0
TRACE TRACE 0
TOTAL TOTAL 0
Metric Values
Files scanned placeholder 4
Files parsed placeholder 3
Files failed to scan placeholder 0
Total executed queries placeholder 360
Queries failed to execute placeholder 0
Execution time placeholder 11

Queries Results

|
|

…eanup_inconsistent_bundle

- Apply TLP:AMBER object_marking_refs to all emitted STIX objects (Identity,
  IntrusionSet, Location, Incident, Report, Indicator, Relationship) for
  conformance with standard connector practice
- Track work lifecycle via helper.api.work.initiate_work / to_processed in
  _run_cycle so runs appear in the OpenCTI Works panel; use try/finally to
  guarantee to_processed is always called even on fetch failure
- Replace manual while/time.sleep loop in run() with helper.schedule_iso()
  using ISO 8601 duration derived from CONNECTOR_RUN_INTERVAL seconds
- Add cleanup_inconsistent_bundle=True and work_id to send_stix2_bundle calls
  for more robust bundle delivery

https://claude.ai/code/session_01RM1YrEYNTjThrpgLftgW2D
@luca-m luca-m requested a review from notdodo March 18, 2026 14:13
@notdodo notdodo merged commit d040b40 into main Mar 18, 2026
7 checks passed
@notdodo notdodo deleted the claude/separate-event-reports-HNyMZ branch March 18, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants