Skip to content

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

Open
justaugustus wants to merge 2 commits intoevidence-uploadfrom
results-json-output
Open

scorecard: Add results file output for scorecard-monitor integration#800
justaugustus wants to merge 2 commits intoevidence-uploadfrom
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

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>
@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
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>
@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
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: No status

Development

Successfully merging this pull request may close these issues.

1 participant