Skip to content

Add Elastic ECS threat indicator Bulk NDJSON export - #945

Merged
adulau merged 2 commits into
mainfrom
codex/elastic-ecs-export
Oct 18, 2026
Merged

adulau merged 2 commits into
mainfrom
codex/elastic-ecs-export

Conversation

@adulau

@adulau adulau commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

MISP events and objects can now be downloaded through elastic_ecs_export as Elasticsearch Bulk NDJSON containing ECS 9.2 threat.indicator.* documents. The module reads every supplied event in standard, bare or legacy format and supports IPs, domains/hostnames, URLs, emails, filenames, file hashes, AS numbers and composite indicators.

Bulk index actions have stable IDs derived from source event/object/attribute identifiers and component position. Reimporting updates existing sources while keeping distinct provenance separate. Only to_ids attributes are exported by default; include_non_ids enables contextual attributes. Deleted data is excluded. Unsupported or malformed indicators and invalid optional timestamps are counted in API warnings.

The exporter preserves original MISP values and source context under a custom misp namespace, combines scoped tags, selects the most restrictive recognized TLP marking, and retains source modification/observation timestamps without inventing confidence or expiry. IPs and hashes are normalized for matching; composite file names/hashes remain in one indicator, while domain/IP composites produce two typed documents.

Includes a minimal index template and usage guide covering Bulk import, item-level errors, indicator-match fields, timestamp semantics, and lifecycle limitations. The starter template bounds keyword, wildcard and flattened values with ignore_above=4096, preserving oversized values in _source without indexing oversized terms. MISP reference URLs reject all userinfo, including password-only and empty credentials. The exporter requires no new dependencies or remote credentials. Existing domain-ip, file and email templates work without changes, so no misp-objects PR is needed.

Validation:

  • 99 tests pass in tests/test_elastic_ecs_export.py, including real /modules and /query handlers, existing strict PyMISP objects, legacy fixture data, composites, source stability, scoped tags/TLP, dates, filtering and malformed input.
  • Every test document is checked against the shipped index template's field types.
  • All 35 ECS field mappings in the template were checked against the official v9.2.0 generated schema.
  • Black, isort, flake8 and git diff --check pass; generated module documentation matches metadata.

No live Elasticsearch cluster was used for validation. This targets regular indices via Bulk index actions; it does not upload data, install detection rules, or reconcile expiry/deletions. The guide calls out cleanup requirements and that re-exporting refreshes @timestamp (export time).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T16:19:26.203183Z 80f705f PR opened
🔒 Security Review ✅ Completed 2026-10-18T16:21:34.197014Z 80f705f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 80f705fdf1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +9 to +11
"template": {
"mappings": {
"dynamic": false,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound keyword terms in the starter template

When a valid MISP comment, tag, or raw provenance value exceeds Lucene's 32,766-byte term limit, this template's keyword, wildcard, and flattened fields have no ignore_above, so Bulk rejects the entire indicator instead of merely leaving the oversized field unindexed. Elasticsearch documents this behavior and recommends a limit of 8,191 or less; add an index-wide index.mapping.ignore_above setting or equivalent field-level limits so large MISP metadata does not make otherwise valid indicators unimportable.

Useful? React with 👍 / 👎.

or not parsed.hostname
or parsed.query
or parsed.fragment
or parsed.username

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject password-only credentials in misp_url

When misp_url is shaped like https://:secret@misp.example, urlsplit().username is an empty, falsy string while .password is set, so this condition accepts credentials despite the documented prohibition. Reference construction then copies the complete URL into every exported document, exposing the password in Elasticsearch; reject when either parsed.username or parsed.password is not None.

Useful? React with 👍 / 👎.

@adulau
adulau merged commit d4302d0 into main Oct 18, 2026
7 checks passed
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.

1 participant