Merge pull request #182 from safedep/fix/auth-reporting-experience

fix: Auth and Reporting Experience (#180)
This commit is contained in:
Abhisek Datta 2024-01-01 11:11:03 +05:30 committed by GitHub
commit f6e055d5c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 5 deletions

View File

@ -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,
})
@ -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,

View File

@ -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() {