chore: Render malysis report URL in console (#302)

This commit is contained in:
Abhisek Datta 2025-01-02 18:50:37 +05:30 committed by GitHub
parent 141e984067
commit 3fab4697a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 2 deletions

View File

@ -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"
)
@ -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 {
@ -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()
@ -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
pkg/malysis/url.go Normal file
View File

@ -0,0 +1,7 @@
package malysis
import "fmt"
func ReportURL(reportId string) string {
return fmt.Sprintf("https://platform.safedep.io/community/malysis/%s", reportId)
}