From e7be2cb62273c7f7a5024a90a0be8f467861f400 Mon Sep 17 00:00:00 2001 From: gziv Date: Wed, 8 Jul 2026 14:33:07 +0300 Subject: [PATCH] fix: correct certification.json to use actual LevelResult attributes LevelResult doesn't have failure_reasons - compute failed_checks from checks list instead. Also add checks_total and checks_passed counts. Co-authored-by: Cursor --- scripts/aggregate_scorecard.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/scripts/aggregate_scorecard.py b/scripts/aggregate_scorecard.py index b07931c..971ec10 100644 --- a/scripts/aggregate_scorecard.py +++ b/scripts/aggregate_scorecard.py @@ -395,26 +395,24 @@ def write_certification(scorecard: Scorecard, reports_dir: Path) -> Path | None: reports_dir.mkdir(parents=True, exist_ok=True) output_path = reports_dir / "certification.json" + def _level_data(level_result): + failed_checks = [c.check_id.value for c in level_result.checks if not c.passed] + return { + "passed": level_result.passed, + "checks_total": level_result.checks_total, + "checks_passed": level_result.checks_passed, + "checks": [c.model_dump() for c in level_result.checks], + "failed_checks": failed_checks, + } + cert_data = { "submission_name": scorecard.submission_name, "pipeline_run_id": scorecard.pipeline_run_id, "highest_level": scorecard.highest_certification.value, "levels": { - "foundational": { - "passed": scorecard.certification.foundational.passed, - "checks": [c.model_dump() for c in scorecard.certification.foundational.checks], - "failure_reasons": scorecard.certification.foundational.failure_reasons, - }, - "trusted": { - "passed": scorecard.certification.trusted.passed, - "checks": [c.model_dump() for c in scorecard.certification.trusted.checks], - "failure_reasons": scorecard.certification.trusted.failure_reasons, - }, - "certified": { - "passed": scorecard.certification.certified.passed, - "checks": [c.model_dump() for c in scorecard.certification.certified.checks], - "failure_reasons": scorecard.certification.certified.failure_reasons, - }, + "foundational": _level_data(scorecard.certification.foundational), + "trusted": _level_data(scorecard.certification.trusted), + "certified": _level_data(scorecard.certification.certified), }, "created_at": scorecard.created_at.isoformat(), }