Skip to content

Composition Refactor - #1258

Open
stevespringett wants to merge 3 commits into
2.0-devfrom
2.0-dev-composition-update
Open

stevespringett wants to merge 3 commits into
2.0-devfrom
2.0-dev-composition-update

Conversation

@stevespringett

Copy link
Copy Markdown
Member

Closes #1159

…and fields. Removal of legacy enums. (#1159)

Signed-off-by: Steve Springett <steve@springett.us>
@stevespringett stevespringett added this to the 2.0 milestone Nov 30, 2026
@stevespringett
stevespringett requested a review from a team as a code owner November 30, 2026 03:25
@stevespringett stevespringett linked an issue Nov 30, 2026 that may be closed by this pull request
@stevespringett stevespringett added request for comment RFC notice sent A public RFC notice was distributed to the CycloneDX mailing list for consideration labels Nov 30, 2026
@lsmith77

Copy link
Copy Markdown

Thanks, this covers everything #1159 asked for.

Three points:

  • describedIn. I'd recommend a hash, since a TEA URL can serve a different file later. It would also help to say whether resolving a reference requires fetching it, as checkers fetching URLs from untrusted BOMs is an SSRF risk.
  • A typed componentTypes criterion in 2.0. A tender check has to find the entry for a type even when no such component is present, so evaluating the expression gives it nothing. It would have to parse the expression text instead. One typed criterion fixes the common case and the expression stays for the rest.
  • Overlap wording. "Two compositions without fields shall not cover the same array" rules out valid-composition-filter-component-types, where three filters split one array. Maybe "the same item" is meant here?

@StanimirTenev

Copy link
Copy Markdown

A view from the producer side, in case it's useful for review. We maintain qrp-mcp, a source-code scanner that writes a CBOM. Its CycloneDX 1.6 export carries a coverage block as private qrp:coverage:* properties, because 1.6 has nowhere else to put it. I mapped that block onto #1258 at 600b605. With one exception, all of it now has a place in the standard.

What maps directly

qrp-mcp 0.54.0 #1258
coverage.claims.out_of_scope_by_design: "symmetric ciphers (AES, ChaCha20) and their key sizes", "hashes and MACs for integrity", "key derivation", "random number generation as a finding", with named exceptions ("MD5, SHA-1, DES, 3DES and RC4 are named where found") a composition over that class with aggregate: not-assessed
coverage.claims.second_axis_not_claimed: whether what was present was found is not measurable by the tool itself the rule that absence "shall not be read as evidence that none exists"
our 1.6 compositions[{aggregate, assemblies}] select + filter. assemblies is gone, and the 2.0 form says more

The input side, which I expected to be missing and isn't

Our main coverage figure is about the input. On shorlist/shorlist at f5ca75c, coverage.scope.files_present = 2432 and files_examined = 2363. coverage.not_examined lists 69 files as type_not_claimed and 0 as unreadable, each with its path. At first I thought a filter over BOM items couldn't reach a file that produced no item. With 2.0 it can: list each input as a file component in the inventory, and put a composition on that file's components through roots.

As a concrete addition, here is a fixture for that pattern. It validates against the 2.0 modules at 600b605 with jsonschema, and the same validator rejects the PR's invalid-composition-old-assemblies and invalid-composition-not-assessed-reason. JSON Schema can't check the non-overlap rule, so I checked that part by reading it:

"inventories": [{
  "subject": { "refId": "scanned-tree", "type": "application", "name": "shorlist", "version": "f5ca75c" },
  "components": [
    { "refId": "file:app/sign.py", "type": "file", "name": "app/sign.py", "components": [ { "ref": "crypto:rsa" } ] },
    { "refId": "file:app/util.py", "type": "file", "name": "app/util.py" },
    { "refId": "file:README.md", "type": "file", "name": "README.md" },
    { "refId": "file:keys/broken.pem", "type": "file", "name": "keys/broken.pem" }
  ]
}],
"compositions": [
  { "select": "$.inventories[*].components", "subjects": ["scanned-tree"],
    "filter": { "expression": "$[?@.type == 'file']" }, "aggregate": "complete" },
  { "roots": ["file:app/sign.py", "file:app/util.py"], "select": "$.components", "aggregate": "unknown" },
  { "roots": ["file:README.md"], "select": "$.components", "aggregate": "not-assessed" },
  { "roots": ["file:keys/broken.pem"], "select": "$.components", "aggregate": "not-assessed" }
]

Reading it: every file in the tree is listed. For the files that were read, the cryptography in them is unknown, because a scanner can't establish its own recall. For the other two, it was not assessed. Happy to open this as a fixture in the PR if that helps.

Two things building it raised

  1. Two input states end up with the same value. README.md was not read by design: the tool does not claim that type. keys/broken.pem was opened and failed. Both are not-assessed. For a consumer they need different fixes, extending the tool in one case and re-running on a fixed input in the other. The summary on [FEATURE]: Fine-grained completeness assertions #1159 puts further reasons in an annotation, but annotation.text is free text, so a checker can't count failed inputs separately from declared boundaries. Is that split meant to be out of scope, or would a typed form be considered later, the way typed filter criteria are?
  2. Cost. The pattern needs one file component per input, 2432 for this small repository. That's fine for us. Is this the intended way for discovery tools to state input coverage, or is something lighter expected?

Reproduce the numbers: uvx qrp-mcp==0.54.0 scan <shorlist checkout at f5ca75c> --no-config --out scan.json, then read .coverage.

@jkowalleck

Copy link
Copy Markdown
Member

RFC period ends 28. Dezember 2026

@Rul1an

Rul1an commented Nov 30, 2026

Copy link
Copy Markdown

Nice to see #1159 implemented here as filter plus a separate aggregate. Reading the new filter text next to the component schema, I ran into an interaction that I think deserves a sentence in the spec.

The filter.expression description says "Absent properties have no default values", while isExternal on a component has "default": false. Under RFC 9535 a comparison with a missing member is only equal to another missing value, so $[?@.isExternal == false] does not select a component that leaves isExternal out, even though the schema says that component is internal. $[?@.isExternal != true], which is what valid-composition-filter-external uses, does select it.

That makes it easy to write a composition that leaves out part of its own inventory without noticing:

{
  "specFormat": "CycloneDX",
  "specVersion": "2.0",
  "inventories": [
    {
      "subject": { "refId": "acme-agent", "type": "application", "name": "Acme Agent" },
      "components": [
        { "refId": "fs", "type": "service", "name": "fs" },
        { "refId": "gh", "type": "service", "name": "gh", "isExternal": true }
      ]
    }
  ],
  "compositions": [
    {
      "select": "$.inventories[*].components",
      "subjects": ["acme-agent"],
      "filter": { "expression": "$[?@.type == 'service' && @.isExternal == false]" },
      "aggregate": "complete"
    },
    {
      "select": "$.inventories[*].components",
      "subjects": ["acme-agent"],
      "filter": { "expression": "$[?@.type == 'service' && @.isExternal == true]" },
      "aggregate": "not-assessed"
    }
  ]
}

This validates against the 2.0 schemas at 600b605. Strictly the first composition covers services whose isExternal is explicitly false, and fs is not in that class. But a producer who reads the component schema and means "all our internal services" will write exactly this, and fs, internal by the schema default, ends up under neither composition.

The filter text already settles which reading is right, so this is about making the consequence visible where people will trip on it. scope has the same shape, and its description even says a consumer SHOULD assume "required" when it is absent: $[?@.scope == 'required'] misses components that rely on the default, while $[?@.scope != 'optional' && @.scope != 'excluded'] includes them. A short note in the filter description (or next to properties that carry a default) saying that defaults are not applied during evaluation, so a filter for the default value should exclude the other values rather than match the default, plus a fixture like the one above, would probably be enough.

@lsmith77

Copy link
Copy Markdown

The filter.expression description says "Absent properties have no default values", while isExternal on a component has "default": false.

This is another case for typed criteria: a typed criterion can apply schema defaults, while an expression over the raw JSON sees only what the producer wrote.

@eshaanjain26

Copy link
Copy Markdown

Thank you for the summary table, and for taking the disjointness point into the design as a normative rule. I read the PR against the asks in your table, and the coverage is real: the aggregate values are all there, the silence rule is stated, delegated with describedIn covers the externally held case, and the attestation test file shows claims citing compositions as evidence against a named perspective. That is the procurement use case working end to end.

Two things I would ask about before this lands.

First, "Compositions shall not overlap" is normative in the schema description, which is the right call, but JSON Schema cannot enforce it, and the PR has no negative test case for two overlapping compositions. A checker has to implement overlap detection itself, and two checkers could disagree on what counts as overlap. Is that a checker responsibility you are happy to leave unstated, or would a note in the spec plus one invalid test file help?

Second, redacted tells the recipient to ask the security contact the document declares, but nothing requires the document to declare one. A BOM can say redacted with no security contact anywhere, and the recipient has nowhere to ask. Should a redacted composition require a security contact, or at least warn when none is declared?

The four fragments below are the cases I checked the design against. I am happy to turn them into test resources if that would help.

Eshaan Jain, independent researcher (IEEE Senior Member)


Example BOM fragments with checker verdicts

All four use the same subject, acme-portal, and the same class, machine-learning-model components. Each fragment is one composition entry from a BOM whose inventories hold acme-portal components.

1. Missing: no composition covers the class

{
  "compositions": [
    {
      "select": "$.inventories[*].components",
      "subjects": ["acme-portal"],
      "filter": { "expression": "$[?@.type == 'library']" },
      "aggregate": "complete"
    }
  ]
}

Expected checker verdict: not-specified. No composition covers machine-learning-model components, so their completeness is not specified. The checker must report "coverage not specified", not "no models exist" and not "non-conformant", unless a perspective or requirement demands coverage of that class.

2. Not-assessed: the class was not examined

{
  "compositions": [
    {
      "select": "$.inventories[*].components",
      "subjects": ["acme-portal"],
      "filter": { "expression": "$[?@.type == 'machine-learning-model']" },
      "aggregate": "not-assessed"
    }
  ]
}

Expected checker verdict: not-assessed. The producer states the class was not assessed. A missing model component must not be read as "the product uses no models". A checker enforcing a procurement perspective that requires this class would report non-conformant here, with the reason "not assessed", which is a different failure from a missing class.

3. Redacted: the class was assessed but the items are withheld

{
  "compositions": [
    {
      "select": "$.inventories[*].components",
      "subjects": ["acme-portal"],
      "filter": { "expression": "$[?@.type == 'machine-learning-model']" },
      "aggregate": "redacted"
    }
  ]
}

Expected checker verdict: redacted. Completeness was assessed and some or all items are withheld. The checker must report "withheld" and point the recipient at the document's security contact. If the document declares no security contact, the checker should flag that the redaction has nowhere to be resolved, which is the open question in the review comment above.

4. Externally covered: the class is described in another BOM

{
  "compositions": [
    {
      "select": "$.inventories[*].components",
      "subjects": ["acme-portal"],
      "filter": { "expression": "$[?@.type == 'machine-learning-model']" },
      "aggregate": "delegated",
      "describedIn": [
        {
          "type": "bom",
          "url": "urn:tei:uuid:acme.example:5f1b6c0e-6a2b-4c1e-9d2a-7b3f0c9e1a44"
        }
      ]
    }
  ]
}

Expected checker verdict: delegated. Completeness is stated in the referenced document. The checker must follow describedIn and must not treat the class as complete or as empty on the strength of this BOM alone. A delegated composition without describedIn is invalid, which the PR already covers with a negative test case.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-changes proposed core enhancement request for comment RFC notice sent A public RFC notice was distributed to the CycloneDX mailing list for consideration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Fine-grained completeness assertions

6 participants