feat(sbom): add --json output to fossa sbom analyze - #1736
Draft
zlav wants to merge 2 commits into
Draft
Conversation
Add a `--json` flag to `fossa sbom analyze` that, on a successful upload, prints project metadata as JSON to stdout using the same renderer and schema as `fossa analyze --json`, so downstream tooling parses both identically. The emitted locator carries the SBOM project locator (`sbom+<orgId>/<name>`) and full id needed for follow-up `fossa project edit` calls. Reuse analyze's `buildProjectSummary` (now exported) and the existing `JsonOutput` flag helper; the human "View FOSSA Report" banner is kept alongside the JSON, matching analyze's behavior. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Add a
--jsonflag tofossa sbom analyzethat, on a successful upload, prints project metadata as JSON to stdout — reusing the exact renderer/schema asfossa analyze --jsonso downstream tooling parses both identically.src/App/Fossa/Config/SBOM/Analyze.hs— add--jsonflag (analyze'sJsonOutputhelper + identical help text); thread it throughSBOMAnalyzeOptions→SBOMAnalyzeConfig.src/App/Fossa/SBOM/Analyze.hs— after upload, emitbuildProjectSummaryJSON to stdout when--jsonis set. The human "View FOSSA Report" banner is kept alongside the JSON, matching analyze.src/App/Fossa/Analyze/Upload.hs— exportbuildProjectSummaryfor reuse (no schema change).sbom.md) andChangelog.mdupdated.Parity: emits the same object as
fossa analyze --json(project,projectId,revision,branch,url,id). SBOM projects use thesbomfetcher, soidissbom+<orgId>/<name>$<rev>(notcustom).Acceptance criteria
fossa sbom analyze <file> --jsonprints a JSON object with the project locator/id and report URL in the same schema asfossa analyze --json, enabling scriptedfossa project edit --project-locator ...follow-ups.Testing plan
cabal build lib:spectrometer— compiles.cabal test unit-tests --test-options='--match "SBOM Analyze"'— passes, including newcliParsercases asserting--jsonparses on/off.fourmolu --mode checkon changed files — clean.Risks
Low. Locator uses the
sbomfetcher (verified) rather thancustom; JSON shape is unchanged from analyze.Metrics
N/A.
References
--project-labelgap, which is not addressed here).Checklist
docs/.Changelog.mdunder## Unreleased..fossa.ymlorfossa-deps.{json.yml}, I updated schemas. (N/A)docs/references/subcommands/<subcommand>.md.