Implementation:7onez Cti expert SH Misp Publish
| Knowledge Sources | |
|---|---|
| Domains | OSINT, MISP, Threat_Intel_Sharing |
| Last Updated | 2026-10-28 14:00 GMT |
Overview
Concrete tool for publishing a staged MISP event by raising its distribution level, gated by both analyst confirmation and a human-set environment lock that an agent cannot set for itself, provided by the cti-expert IntelShare module.
Description
The publish function in sh_misp.py raises the event's distribution and publishes it — the irreversible step. It requires both gates:
- confirm=True: the analyst explicitly confirmed for this event.
- INTEL_MISP_PUBLISH=1: an environment lock that is a human's act, not an agent's. The agent cannot set this for itself — re-launching with the env lock is the deliberate step.
Without both, it returns publish_briefing() — the irreversibility warning, the audience, the to_ids count, the personal data in the event, and blocked_by if the lock is absent.
Distribution levels: 0=organisation, 1=community, 3=connected, 4=sharing group (requires sharing_group_id). Publishing triggers MISP sync to all connected servers and subscriber notifications — it cannot be undone.
A dry_run mode prints the exact requests (set-distribution + publish) without sending. If the publish POST fails after the distribution was raised, the result warns that the event is now visible at the new level on this instance even though no sync was triggered.
Usage
Import this when you need to:
- Publish a staged MISP event (raise distribution + trigger sync).
- Get a pre-publish briefing without actually publishing.
- Enforce both confirmation and env-lock gates.
- Dry-run the publish to inspect the exact requests.
Code Reference
Source Location
- Repository: cti-expert
- File: intel_engine/IntelShare/tools/sh_misp.py
- Lines: L558-612 (publish), L521-557 (publish_briefing)
Signature
def publish(event_id, *, distribution: int = 1, confirm: bool = False, case: str = "",
sharing_group_id=None, dry_run: bool = False) -> dict:
"""Raise the event's distribution and publish it. The irreversible step.
Requires both confirm=True AND INTEL_MISP_PUBLISH=1 env lock."""
def publish_briefing(event_id, distribution: int, *, event: dict | None = None) -> dict:
"""What publishing would do. Returned when confirmation or env lock is absent."""
Import
from sh_misp import publish, publish_briefing
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| event_id | int | Yes /// MISP event ID (from push step) | |
| distribution | int | No /// Target distribution (1=community, 3=connected, 4=sharing group) | |
| confirm | bool | Yes /// Gate flag (False = briefing only) | |
| sharing_group_id | int | No /// Required for distribution=4 | |
| dry_run | bool | No /// Print requests without sending |
Outputs
| Name | Type | Description |
|---|---|---|
| (no confirm/lock) | dict | publish_briefing (irreversibility, audience, blocked_by?) |
| (confirm+lock) | dict | {ok, sent, published:true, event_id, distribution, audience, url, irreversible} |
Usage Examples
Pre-Publish Briefing
from sh_misp import publish
briefing = publish(42, distribution=1, confirm=False)
print(briefing["action"]) # "CONFIRMATION REQUIRED — the event is NOT published"
print(briefing["irreversible"]) # True
print(briefing["attributes"]) # {total, by_type, to_ids}
Publish (With Env Lock)
# Requires INTEL_MISP_PUBLISH=1 in the environment (human-set)
import os
os.environ["INTEL_MISP_PUBLISH"] = "1"
result = publish(42, distribution=1, confirm=True)
if result.get("published"):
print(f"Published to {result['audience']} at {result['url']}")
print("This is IRREVERSIBLE.")