Skip to content

STIX export: omit null properties and empty lists - #7

Merged
simonmorley merged 4 commits into
mainfrom
stix-valid
Oct 8, 2026
Merged

simonmorley merged 4 commits into
mainfrom
stix-valid

Conversation

@simonmorley

@simonmorley simonmorley commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Same defect, same fix as the API side (NullRabbitLabs/nrdax-api#38): attack_pattern() emitted x_nrdax_family / x_nrdax_surface / x_nrdax_bound_failure as null for a pending technique and x_nrdax_chains as [] for one with no instances. STIX 2.1 forbids both, so any bundle exported through this package fails the OASIS stix2-validator. The shipped test fixture carried the defect too.

Change

  • Properties with no value are omitted. That covers x_nrdax_producer_family when it is absent; x_nrdax_classification: "pending" still says why the axes are missing.
  • validate_bundle now rejects a null property or an empty list at any depth.
  • The fixture drops the three nulls, exactly as the backend golden does in #38.
  • Red then green: 2d14fa6 adds the failing tests, 9e8ea26 fixes them.

Verified

  • I exported all 523 live techniques (NRDAX.from_api()) through the patched exporter and ran stix2-validator 3.3.1: 0 invalid objects.
  • pytest, ruff (src, tests) and mypy all pass.

Compatibility: the STIX reader (sources/stix.py) already reads these properties with .get(), so an omitted property reads as the None it replaces.

License marking (second fix, 4945bb4 red, 1099987 green). The fixture is again the backend's golden stix.json (post-#38). The backend leads every bundle with a CC-BY-4.0 marking-definition that each attack-pattern references through object_marking_refs; this exporter never did, so the "byte-identical to the backend" test was passing against a stale fixture. It now emits the same marking with the same deterministic id, and the export is byte-identical to the backend's golden again.

Verified again. The full live registry exported through this branch is 524 objects (523 techniques plus the marking), with 0 invalid under stix2-validator.

Still not modelled. The Python Technique has no scope or AADAPT crosswalk, so this exporter cannot emit x_nrdax_out_of_scope or mitre-aadapt references the way the backend does. That is a model gap, not this bug. No release is cut here.

Simon Morley added 4 commits October 8, 2026 12:22
The exporter emits null x_nrdax_family/surface/bound_failure for a pending
technique and [] for x_nrdax_chains when there are no instances. STIX 2.1
forbids both, and the OASIS validator rejects them. The fixture drops the three
nulls, matching the backend fix (nrdax-api #38).
A pending technique now omits x_nrdax_family/surface/bound_failure (and
x_nrdax_producer_family when absent); one with no instances omits
x_nrdax_chains. validate_bundle rejects a null property or an empty list at any
depth. Matches the backend (nrdax-api #38); the reader already used .get(), so
absence reads as the null it replaces.
The fixture is the backend's golden stix.json again (post nrdax-api #38). The
backend has led every bundle with a CC-BY-4.0 marking-definition referenced by
each attack-pattern's object_marking_refs; this exporter never did, so its
'byte-identical to the backend' claim had silently stopped being true.
…end does

A statement marking-definition (deterministic UUIDv5 id, fixed created) leads
every bundle and each attack-pattern references it via object_marking_refs.
The export is byte-identical to the backend's golden again.
@simonmorley
simonmorley merged commit 57ffcfe into main Oct 8, 2026
6 checks passed
@simonmorley
simonmorley deleted the stix-valid branch October 8, 2026 11:40
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