Skip to content

fix(scoring): detect externalReferences under components[0] (#76)#82

Open
Rul1an wants to merge 1 commit into
GenAI-Security-Project:mainfrom
Rul1an:fix/external-references-scoring
Open

fix(scoring): detect externalReferences under components[0] (#76)#82
Rul1an wants to merge 1 commit into
GenAI-Security-Project:mainfrom
Rul1an:fix/external-references-scoring

Conversation

@Rul1an

@Rul1an Rul1an commented Jun 17, 2026

Copy link
Copy Markdown

What

external_references always scored as missing in the component_basic category, even when the generated BOM contained a populated externalReferences array, capping every model at ~17.1/20 there. Fixes #76.

Root cause

Two independent detection issues:

  1. field_registry.json used the singular jsonpath $.component.externalReferences, but CycloneDX 1.6/1.7 place the array under $.components[0] (plural with index). Every other component_basic field already uses $.components[0].*.
  2. The fallback presence check in scoring.py compared the snake_case registry name external_references against the camelCase BOM key externalReferences, so neither path matched a populated field.

Change

  • field_registry.json: jsonpath -> $.components[0].externalReferences (scoring/detection path only).
  • scoring.py: a small registry-name -> BOM-key alias map used by the fallback check, as defense-in-depth (also covers component_version -> version).
  • tests/test_scoring.py: a positive case (detection under components[0] via both the jsonpath and the fallback) and a negative guard (absent -> still False).

With both, a fully populated component_basic scores 20/20 again.

Scope

I left the aibom_generation.location strings untouched. They use a separate singular-$.component. addressing scheme consistently across the registry (the component being generated, not the final BOM array), and generated BOMs already place externalReferences correctly under components[0], so this PR stays limited to the scoring/detection bug. Happy to revisit the generation convention separately if maintainers prefer.

Credit to the reporter for the precise root-cause analysis.

…curity-Project#76)

external_references always scored as missing. Two independent causes:
the field_registry jsonpath used the singular `$.component.externalReferences`
while CycloneDX 1.6/1.7 place the array under `$.components[0]` (plural), and
the fallback presence check compared the snake_case registry name
`external_references` against the camelCase BOM key `externalReferences`, so
neither path matched a populated field.

- field_registry.json: correct the jsonpath to $.components[0].externalReferences
- scoring.py: map registry field names to their CycloneDX keys in the fallback
  (defense-in-depth; also covers component_version -> version)
- tests: detection under components[0] plus a negative guard

A fully populated component_basic category now scores 20/20 again (previously
capped at ~17.1/20). Thanks to the reporter for the precise root-cause analysis.

Signed-off-by: Rul1an <roelschuurkes@gmail.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.

Scoring bug: component_basic/external_references always scores as missing due to jsonpath and key-casing mismatches

1 participant