Skip to content

Add size constraints to CTIM collection fields (XDR-46972)#483

Open
ereteog wants to merge 4 commits intothreatgrid:masterfrom
ereteog:add-collection-size-limits
Open

Add size constraints to CTIM collection fields (XDR-46972)#483
ereteog wants to merge 4 commits intothreatgrid:masterfrom
ereteog:add-collection-size-limits

Conversation

@ereteog
Copy link
Contributor

@ereteog ereteog commented Mar 12, 2026

Epic XDR-46972
Related flanders#58
Related ctia#1514

Add pred/max-len constraints to collection fields in sighting, incident, and common schemas.

Changes

  • Bump flanders to 1.1.1-SNAPSHOT (adds :spec support on SequenceOfType, SetOfType, and MapType)
  • Add default-collection-max-len (500) constant in common.cljc for shared collection fields
  • Constrain external_ids and external_references in base entity entries
  • Add specific limits for sighting fields:
    • columns: 100, rows: 10,000
    • targets: 2,000, observables: 5,000, relations: 10,000
  • Constrain incident fields (categories, assignees, tactics, techniques) to 500
  • Add relation_info.actions limit of 1,000
  • Add {:max-len len} metadata to pred/max-len for downstream 413 error reporting
  • Replace unbounded f/any-str with typed string constraints (ShortString, MedString, LongString)

§ QA

No QA is needed. All 139 existing tests (including generative tests) pass.

§ Release Notes

intern: Add size constraints to CTIM collection fields.

§ Squashed Commits

Copy link
Contributor

@yogsototh yogsototh left a comment

Choose a reason for hiding this comment

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

I have only two concerns:

  • why these numbers, to me they are a bit like "magic numbers" and it will eventually breaks in PROD refusing the creation of many entities suddenly without a warning which may create issues with already working integrations. Personally, I think it may be a bit too much to constrain statically here instead of directly into the CTIA application where we could apply different size constraints depending on the source for example. Which will give the time for an integration to adapt to the new constraints. And perhaps instead of a hard reject, we may also integrate a mechanism to just cut the strings/arrays to keep the first one.

  • We should check if adding these constraints does not affect Swagger and Swagger UI. From memory plumatic/schemas and swagger do not support very well certain kind of external constraints like this one. So while the API will work, Swagger UI may be broken, or not show the correct schemas anymore.

ereteog and others added 4 commits March 19, 2026 08:18
Add pred/max-len constraints to seq-of/set-of collection fields in
sighting, incident, and common schemas to prevent oversized documents
causing ES bulk write failures.

- Bump flanders to 1.1.1-SNAPSHOT (adds :spec support on collection types)
- Add default-collection-max-len (500) for common collection fields
- Add specific limits for sighting fields (observables, relations, targets, data tables)
- Constrain external_ids and external_references in base entity entries

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace f/any-str with ShortString (1024), MedString (2048), or
LongString (5000) across all CTIM schemas based on field semantics
and production data analysis (831K sightings, 388K incidents from NAM).

- ShortString: identifiers, names, IPs, labels, type fields
- MedString: indicator specs (snort, SIOC, OpenIOC), metadata values
- LongString: casebook text content
- seq-of ShortString: hashes, variables, permissible_IPs

Observable :value intentionally kept as f/any-str — production data
shows process_args up to 32K chars (6376 values > 1024).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…onstraint

- observables: 2000 → 5000 (P99.9 = 4128)
- targets: 1000 → 2000 (P99.9 = 1841)
- relations: 10000 (unchanged, P99.9 = 9814)
- relation_info.actions: new limit of 1000 (addresses 142K action accumulation pattern)
- pred/max-len: add metadata for downstream 413 error reporting

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants