Print excepions statement in summary report

This commit is contained in:
abhisek 2023-02-23 09:59:04 +05:30
parent 4b16c05ff9
commit 2ecc52ef00
No known key found for this signature in database
GPG Key ID: CB92A4990C02A88F
2 changed files with 20 additions and 1 deletions

View File

@ -94,6 +94,14 @@ func Apply(pkg *models.Package) (*exceptionMatchResult, error) {
return globalExceptions.Match(pkg)
}
func ActiveCount() int {
return globalExceptions.ActiveCount()
}
func (s *exceptionStore) ActiveCount() int {
return len(s.rules)
}
func (s *exceptionStore) Match(pkg *models.Package) (*exceptionMatchResult, error) {
result := exceptionMatchResult{}

View File

@ -12,6 +12,7 @@ import (
"github.com/safedep/dry/utils"
"github.com/safedep/vet/gen/insightapi"
"github.com/safedep/vet/pkg/analyzer"
"github.com/safedep/vet/pkg/exceptions"
"github.com/safedep/vet/pkg/models"
"github.com/safedep/vet/pkg/policy"
"github.com/safedep/vet/pkg/readers"
@ -198,9 +199,14 @@ func (r *summaryReporter) Finish() error {
r.renderRemediationAdvice()
fmt.Println()
if exceptions.ActiveCount() > 0 {
fmt.Println(text.Faint.Sprint(summaryListPrependText, r.exceptionsCountStatement()))
fmt.Println()
}
fmt.Println("Run with `vet --filter=\"...\"` for custom filters to identify risky libraries")
fmt.Println()
fmt.Println("For more details", text.Bold.Sprint("https://github.com/safedep/vet"))
fmt.Println()
return nil
}
@ -298,3 +304,8 @@ func (r *summaryReporter) majorVersionDriftStatement() string {
return fmt.Sprintf("%d libraries are out of date with major version drift in direct dependencies",
r.summary.metrics.drifts)
}
func (r *summaryReporter) exceptionsCountStatement() string {
return fmt.Sprintf("%d libraries are exempted from analysis through exception rules",
exceptions.ActiveCount())
}