Skip to content

Commit

Permalink
chore: Render malysis report URL in console (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhisek authored Jan 2, 2025
1 parent 141e984 commit 3fab469
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cmd/inspect/malware.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/safedep/dry/utils"
"github.com/safedep/vet/internal/auth"
"github.com/safedep/vet/internal/ui"
"github.com/safedep/vet/pkg/malysis"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -120,7 +121,8 @@ func executeMalwareAnalysis() error {
ui.PrintError("Failed to render malware analysis report in JSON format: %v", err)
}

return renderMalwareAnalysisReport(malwareAnalysisPackageUrl, report)
return renderMalwareAnalysisReport(malwareAnalysisPackageUrl,
analyzePackageResponse.GetAnalysisId(), report)
}

func renderToJSON(report *malysisv1pb.Report) error {
Expand All @@ -136,7 +138,7 @@ func renderToJSON(report *malysisv1pb.Report) error {
return os.WriteFile(malwareAnalysisReportJSON, []byte(data), 0644)
}

func renderMalwareAnalysisReport(purl string, report *malysisv1pb.Report) error {
func renderMalwareAnalysisReport(purl string, analysisId string, report *malysisv1pb.Report) error {
ui.PrintMsg("Malware analysis report for package: %s", purl)

tbl := table.NewWriter()
Expand All @@ -156,5 +158,14 @@ func renderMalwareAnalysisReport(purl string, report *malysisv1pb.Report) error
tbl.AppendRow(table.Row{purl, status, confidence})
tbl.Render()

fmt.Println()
fmt.Println(text.FgHiYellow.Sprintf("** The full report is available at: %s",
reportVisualizationUrl(analysisId)))
fmt.Println()

return nil
}

func reportVisualizationUrl(analysisId string) string {
return malysis.ReportURL(analysisId)
}
7 changes: 7 additions & 0 deletions pkg/malysis/url.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package malysis

import "fmt"

func ReportURL(reportId string) string {
return fmt.Sprintf("https://platform.safedep.io/community/malysis/%s", reportId)
}

0 comments on commit 3fab469

Please # to comment.