Skip to content

fix(scoring): align externalReferences registry paths with emitted BOM (#76) - #120

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

drk-ram wants to merge 1 commit into
GenAI-Security-Project:mainfrom
drk-ram:fix/76-external-references-scoring

Conversation

@drk-ram

@drk-ram drk-ram commented Nov 1, 2026

Copy link
Copy Markdown

Summary

Fixes #76.

The two root causes described in #76 were already addressed on main by #85 (external_references jsonpath now $.components[0].externalReferences, plus the externalReferences alias in check_field_in_aibom), but the issue is still open and a few related stale paths remain. This PR finishes the job and adds the missing regression coverage for the scoring outcome.

Changes

  • field_registry.json: replace the remaining singular $.component.externalReferences locations (external_references, downloadLocation) with $.components[0].externalReferences.
  • field_registry.json: the paper jsonpath pointed at $.metadata.component.externalReferences[...], which never carries external references in the emitted BOM, so paper was only ever detected through the fallback. It now uses $.components[0].externalReferences[?(@.type=='documentation')].url, consistent with vcs / website.

Tests (tests/test_scoring.py)

  • registry: every externalReferences path (jsonpath and generation location) uses the components[0] root
  • jsonpath detection of a populated components[0].externalReferences
  • paper jsonpath detects/does not detect a documentation reference
  • a BOM with all seven component_basic fields populated scores the full component_basic points, and external_references is checked off and not listed as missing
  • removing only externalReferences loses exactly one field from component_basic
  • a component built by AIBOMService._create_component_section scores external_references as present

The registry-path and paper tests fail against the previous registry.

Validation

  • pytest --no-cov (Python 3.11): 188 passed
  • pytest tests/test_scoring.py --no-cov: all passed; the two registry-path tests fail when the old field_registry.json is restored

GenAI-Security-Project#76)

The field_registry jsonpath for external_references and the snake/camel
fallback were corrected by GenAI-Security-Project#85, but stale singular `$.component.` /
`$.metadata.component.` externalReferences paths remained:

- external_references and downloadLocation aibom_generation.location
- paper jsonpath (pointed at metadata.component, which never carries
  externalReferences, so paper only scored via the fallback)

Point them at $.components[0].externalReferences to match the emitted
CycloneDX structure, and add regression tests: registry path
consistency, jsonpath detection, full component_basic points when
externalReferences is populated, partial points when absent, and a test
that a component produced by AIBOMService scores the field present.

Fixes GenAI-Security-Project#76

Signed-off-by: Raghuvar Karthik Durga <177662415+drk-ram@users.noreply.github.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