Skip to content

Commit

Permalink
Merge pull request #182 from safedep/fix/auth-reporting-experience
Browse files Browse the repository at this point in the history
fix: Auth and Reporting Experience (#180)
  • Loading branch information
abhisek authored Jan 1, 2024
2 parents 875d96b + b08c8a4 commit f6e055d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
20 changes: 17 additions & 3 deletions pkg/reporter/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,10 @@ func (r *summaryReporter) renderRemediationAdvice() {
break
}

insight := utils.SafelyGetValue(sp.pkg.Insights)

tbl.AppendRow(table.Row{
string(sp.pkg.Ecosystem),
r.packageNameForRemediationAdvice(sp.pkg),
utils.SafelyGetValue(insight.PackageCurrentVersion),
r.packageUpdateVersionForRemediationAdvice(sp.pkg),
sp.score,
})

Expand Down Expand Up @@ -368,6 +366,22 @@ func (r *summaryReporter) packageNameForRemediationAdvice(pkg *models.Package) s
pkg.PackageDetails.Version)
}

func (r *summaryReporter) packageUpdateVersionForRemediationAdvice(pkg *models.Package) string {
insight := utils.SafelyGetValue(pkg.Insights)
insightsCurrentVersion := utils.SafelyGetValue(insight.PackageCurrentVersion)

if insightsCurrentVersion == "" {
return "Not Available"
}

sver, _ := semver.Diff(pkg.PackageDetails.Version, insightsCurrentVersion)
if sver.IsNone() {
return "-"
}

return insightsCurrentVersion
}

func (r *summaryReporter) vulnSummaryStatement() string {
return fmt.Sprintf("%d critical, %d high and %d other vulnerabilities were identified",
r.summary.vulns.critical, r.summary.vulns.high,
Expand Down
9 changes: 7 additions & 2 deletions scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,14 @@ func listParsersCommand() *cobra.Command {

func startScan() {
if !disableAuthVerifyBeforeScan {
failOnError("auth/verify", auth.Verify(&auth.VerifyConfig{
err := auth.Verify(&auth.VerifyConfig{
ControlPlaneApiUrl: auth.DefaultControlPlaneApiUrl(),
}))
})

if err != nil {
failOnError("auth/verify", fmt.Errorf("failed to verify auth token: %v. "+
"You may want to setup community mode using: vet auth configure --community", err))
}
}

if auth.CommunityMode() {
Expand Down

0 comments on commit f6e055d

Please sign in to comment.