Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add archive checksum #978

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/staticanalysis/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
// Result (staticanalysis.Result) is the top-level internal data structure
// that stores all data produced by static analysis performed on a package artifact.
type Result struct {
Files []SingleResult
ArchiveSHA256 string
Files []SingleResult
}

/*
Expand Down
11 changes: 10 additions & 1 deletion sandboxes/staticanalysis/staticanalyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ func run() (err error) {
return fmt.Errorf("static analysis error: %w", err)
}

startHashTime := time.Now()
archiveHash, err := utils.SHA256Hash(archivePath)
if err != nil {
return fmt.Errorf("archive checksum calculation failed: %w", err)
h0x0er marked this conversation as resolved.
Show resolved Hide resolved
}
results.ArchiveSHA256 = archiveHash
hashTime := time.Since(startHashTime)

startWritingResultsTime := time.Now()

jsonResult, err := json.Marshal(results)
Expand Down Expand Up @@ -209,11 +217,12 @@ func run() (err error) {
writingResultsTime := time.Since(startWritingResultsTime)

totalTime := time.Since(startTime)
otherTime := totalTime - writingResultsTime - analysisTime - extractionTime
otherTime := totalTime - writingResultsTime - analysisTime - extractionTime - hashTime

slog.InfoContext(ctx, "Execution times",
"download and extraction", extractionTime,
"analysis", analysisTime,
"sha256Hash calculation", hashTime,
"writing results", writingResultsTime,
"other", otherTime,
"total", totalTime)
Expand Down