mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-08 05:40:49 -08:00
* Support Amazon Linux * amazon: Add tests for Scanner Detect functionality * amazon: Add more test cases for unhappy paths. This commit also asserts the logged output via observer. Signed-off-by: Simarpreet Singh <simar@linux.com> * amazon: Add a test case for invalid fixed pkg version Signed-off-by: Simarpreet Singh <simar@linux.com> * mod: go mod tidy Signed-off-by: Simarpreet Singh <simar@linux.com> * amazon: Inject dependency seams for exposed db interface and logger. This commit also exposes an interface for doing db operations. Signed-off-by: Simarpreet Singh <simar@linux.com> * amazon: Use injected logger for scanner. Signed-off-by: Simarpreet Singh <simar@linux.com> * amazon_test: Add a sample testdata dir Signed-off-by: Simarpreet Singh <simar@linux.com> * amazon: Add tests for for Get() for amazon vulns. Signed-off-by: Simarpreet Singh <simar@linux.com> * vulnsrc_test: Fix invocation call to SetVersion() Signed-off-by: Simarpreet Singh <simar@linux.com> * amazon_test: Add a test for severirtyFromPriority Signed-off-by: Simarpreet Singh <simar@linux.com> * amazon_test: Add tests for constructVersion() Signed-off-by: Simarpreet Singh <simar@linux.com> * amazon: Refactor walkFunc outside for testability purposes Signed-off-by: Simarpreet Singh <simar@linux.com> * amazon: Refactor walkFn and add tests for it. Signed-off-by: Simarpreet Singh <simar@linux.com> * amazon: Refactor commitFunc closure and add tests This commit also introduces an interface for the vulnerability package to be used as a seam. Signed-off-by: Simarpreet Singh <simar@linux.com> * Revert "amazon: Use injected logger for scanner." This reverts commit 5a81e4d824a95f4de4aae2e2b903eedd0f7e241f. * test(amazon): fix failed tests * fix(vulnerability): trim references * test(amazon): add integration test
65 lines
950 B
Go
65 lines
950 B
Go
package utils
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/briandowns/spinner"
|
|
pb "gopkg.in/cheggaaa/pb.v1"
|
|
)
|
|
|
|
var (
|
|
Quiet = false
|
|
)
|
|
|
|
type Spinner struct {
|
|
client *spinner.Spinner
|
|
}
|
|
|
|
func NewSpinner(suffix string) *Spinner {
|
|
if Quiet {
|
|
return &Spinner{}
|
|
}
|
|
s := spinner.New(spinner.CharSets[36], 100*time.Millisecond)
|
|
s.Suffix = suffix
|
|
return &Spinner{client: s}
|
|
}
|
|
|
|
func (s *Spinner) Start() {
|
|
if s.client == nil {
|
|
return
|
|
}
|
|
s.client.Start()
|
|
}
|
|
func (s *Spinner) Stop() {
|
|
if s.client == nil {
|
|
return
|
|
}
|
|
s.client.Stop()
|
|
}
|
|
|
|
// TODO: Expose an interface for progressbar
|
|
type ProgressBar struct {
|
|
client *pb.ProgressBar
|
|
}
|
|
|
|
func PbStartNew(total int) *ProgressBar {
|
|
if Quiet {
|
|
return &ProgressBar{}
|
|
}
|
|
bar := pb.StartNew(total)
|
|
return &ProgressBar{client: bar}
|
|
}
|
|
|
|
func (p *ProgressBar) Increment() {
|
|
if p.client == nil {
|
|
return
|
|
}
|
|
p.client.Increment()
|
|
}
|
|
func (p *ProgressBar) Finish() {
|
|
if p.client == nil {
|
|
return
|
|
}
|
|
p.client.Finish()
|
|
}
|