Skip to content

Commit

Permalink
static analysis: return error if archive extraction is not implemente…
Browse files Browse the repository at this point in the history
…d and log unserialisable JSON as warning (#877)

Signed-off-by: Max Fisher <[email protected]>
Co-authored-by: Caleb Brown <[email protected]>
  • Loading branch information
maxfisher-g and calebbrown authored Sep 12, 2023
1 parent 92541c7 commit 8b19e90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion internal/pkgmanager/ecosystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ func (p *PkgManager) DownloadArchive(name, version, directory string) (string, e
}

func (p *PkgManager) ExtractArchive(archivePath, outputDir string) error {
return p.extractArchive(archivePath, outputDir)
if p.extractArchive != nil {
return p.extractArchive(archivePath, outputDir)
}
return fmt.Errorf("archive extraction not implemented for %s", p.Ecosystem())
}

func normalizePkgName(pkg string) string {
Expand Down
2 changes: 1 addition & 1 deletion sandboxes/staticanalysis/staticanalyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func run() (err error) {

jsonResult, err := json.Marshal(results)
if err != nil {
slog.DebugContext(ctx, fmt.Sprintf("unserialisable JSON: %v", results))
slog.WarnContext(ctx, fmt.Sprintf("unserialisable JSON: %v", results))
return fmt.Errorf("JSON marshal error: %w", err)
}

Expand Down

0 comments on commit 8b19e90

Please sign in to comment.