Skip to content

fix(scoring): detect primaryPurpose/suppliedBy so completeness profiles can reach Standard and Advanced (#124) - #126

Open
drk-ram wants to merge 1 commit into
GenAI-Security-Project:mainfrom
drk-ram:fix/124-completeness-profile-paths
Open

drk-ram wants to merge 1 commit into
GenAI-Security-Project:mainfrom
drk-ram:fix/124-completeness-profile-paths

Conversation

@drk-ram

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

Copy link
Copy Markdown

Summary

Fixes #124.

determine_completeness_profile() could never classify a BOM as Standard or Advanced. primaryPurpose and suppliedBy were not detectable by the legacy helper (the generator emits them as modelCard.modelParameters.task and supplier.name), and several registry jsonpath entries pointed at a root-level $.component object that does not exist in a CycloneDX document.

Changes

  • field_registry.json: the six $.component.* jsonpaths (datasets, primaryPurpose, suppliedBy, ethicalConsiderations, technicalLimitations, intendedUse) now use $.components[0].*. ethicalConsiderations reads [0].name, which is what _create_model_card_section() emits. The externalReferences locations are left to fix(scoring): align externalReferences registry paths with emitted BOM (#76) #120.
  • scoring.py: check_field_in_aibom() resolves primaryPurpose (modelParameters.task) and suppliedBy (supplier.name).
  • scoring.py: determine_completeness_profile() takes an optional extraction_results and goes through check_field_with_enhanced_results(), so the profile and the per-field checklist use one detection path. calculate_completeness_score() passes it through.

Tests (tests/test_completeness_profile.py)

  • emitted task / supplier.name are detected by both the legacy and the enhanced check, and removing them flips the result
  • a BOM with all Standard fields and score >= 70 yields Standard; a score below 70, or a missing supplier, stays Basic
  • a BOM with all Advanced fields and score >= 85 yields Advanced
  • calculate_completeness_score() checks both fields off and does not list them as missing

Four of the seven tests fail on origin/main (the profile stays Basic).

Validation

  • pytest -q --no-cov: all passed
  • pytest tests/test_completeness_profile.py --no-cov on origin/main sources: 4 failed, 3 passed; with this change: 7 passed

…Standard and Advanced (GenAI-Security-Project#124)

determine_completeness_profile() checked each required field with the
legacy check_field_in_aibom() helper, which had no mapping for
primaryPurpose (emitted as modelCard.modelParameters.task) or suppliedBy
(emitted as supplier.name). The registry jsonpaths for these fields, and
for datasets, ethicalConsiderations, technicalLimitations and
intendedUse, pointed at a root-level `$.component` object that does not
exist in a CycloneDX document, so the registry-driven path could not
find them either. A fully populated BOM therefore never left Basic.

- field_registry.json: point the six `$.component.` jsonpaths at
  `$.components[0]`; ethicalConsiderations now reads the emitted `name`.
- scoring.py: add primaryPurpose and suppliedBy aliases to
  check_field_in_aibom().
- scoring.py: determine_completeness_profile() accepts extraction_results
  and uses check_field_with_enhanced_results(), so the profile and the
  per-field checklist share one detection path.
- tests: Standard and Advanced profiles are reachable, absent fields
  keep the profile at Basic, and the checklist marks both fields present.

Fixes GenAI-Security-Project#124

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.

Completeness profile can never reach Standard or Advanced: primaryPurpose/suppliedBy are undetectable by determine_completeness_profile

1 participant