Skip to content

scorecard: Add results file output for scorecard-monitor integration#800

Merged
jeffmendoza merged 2 commits intomainfrom
results-json-output
Mar 30, 2026
Merged

scorecard: Add results file output for scorecard-monitor integration#800
jeffmendoza merged 2 commits intomainfrom
results-json-output

Conversation

@justaugustus
Copy link
Copy Markdown
Member

@justaugustus justaugustus commented Mar 28, 2026

Summary

Add a -results-file flag that writes Scorecard results in Scorecard JSON v2 format, enabling integration with scorecard-monitor for org-wide dashboard reporting.

Motivation

After implementing SARIF upload to GitHub Code Scanning (the evidence-upload branch), the next integration point is feeding Allstar results into scorecard-monitor for trend tracking and reporting. scorecard-monitor is adding a results-path input (ossf/scorecard-monitor#90) that can consume Scorecard results from a file instead of querying the public API.

Design

Uses Scorecard's own JSONScorecardResultV2 format via Result.AsJSON2() — no custom format. This ensures compatibility with scorecard-monitor and any other tool that consumes Scorecard JSON output.

Results are collected at the policy level (scorecard package) using a mutex-protected collector, following the same pattern as sarifHashMap. The main binary calls WriteResults() after EnforceAll() completes.

Usage

./allstar -once -results-file /tmp/results.json

Output is an array of Scorecard JSON v2 objects — one per scanned repo.

Related PRs

  • ossf/scorecard-monitor#90 — adds results-path input to scorecard-monitor (consuming end)
  • Based on the evidence-upload branch (SARIF upload feature)

Test plan

  • Build passes
  • All existing tests pass (18 tests)
  • go vet clean
  • Single-repo results file output verified
  • Multi-repo results file output verified (11 repos, all with valid aggregate scores and checks)
  • End-to-end: Allstar produces results.json (11 repos) -> scorecard-monitor consumes it -> valid Markdown report with all repos

🤖 Generated with Claude Code

@justaugustus justaugustus requested a review from a team as a code owner March 28, 2026 10:36
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 28, 2026
@justaugustus justaugustus changed the title scorecard: add results file output for scorecard-monitor integration scorecard: Add results file output for scorecard-monitor integration Mar 28, 2026
Base automatically changed from evidence-upload to main March 30, 2026 16:41
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Mar 30, 2026
jeffmendoza
jeffmendoza previously approved these changes Mar 30, 2026
Copy link
Copy Markdown
Member

@jeffmendoza jeffmendoza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

justaugustus and others added 2 commits March 30, 2026 12:50
Add a -results-file flag that writes all Scorecard results as a JSON
array in Scorecard's native JSON v2 format. This enables integration
with scorecard-monitor's local-results-path input for org-wide
dashboard reporting.

Implementation:
- collectResult() serializes each repo's sc.Result via AsJSON2() and
  stores it in a package-level collector (mutex-protected, same
  pattern as sarifHashMap)
- WriteResults(path) writes all collected results as a JSON array
- main.go calls WriteResults() after EnforceAll() when -results-file
  is set

Uses Scorecard's own JSONScorecardResultV2 type — no custom format.
The output includes aggregate scores (computed via GetAggregateScore),
per-check scores, repo name, commit SHA, and timestamps.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Remove unnecessary comments that reference downstream tools or
restate obvious Go conventions.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Mar 30, 2026
@justaugustus
Copy link
Copy Markdown
Member Author

Thanks @jeffmendoza!
(Rebased this on the recent merges to get the PR out of that weird state.)

@jeffmendoza jeffmendoza merged commit ef2c73e into main Mar 30, 2026
7 checks passed
@jeffmendoza jeffmendoza deleted the results-json-output branch March 30, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants