Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linter check support #679

Merged
merged 20 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ linters-settings:
misspell:
locale: US
goimports:
local-prefixes: github.com/rahul23/trivy
local-prefixes: github.com/rahul2393/trivy

linters:
disable-all: true
Expand Down Expand Up @@ -65,6 +65,9 @@ issues:
- linters:
- golint
text: "a blank import should be only in a main or test package"
- linters:
- govet
text: "shadow: declaration of"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done,

exclude:
- "should have a package comment, unless it's in another file for this package"
exclude-use-default: false
Expand Down
3 changes: 1 addition & 2 deletions internal/artifact/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ func run(c config.Config, initializeScanner InitializeScanner) error {
vulnClient := initializeVulnerabilityClient()
for i := range results {
vulnClient.FillInfo(results[i].Vulnerabilities, results[i].Type)
var vulns []types.DetectedVulnerability
vulns, err = vulnClient.Filter(ctx, results[i].Vulnerabilities,
vulns, err := vulnClient.Filter(ctx, results[i].Vulnerabilities,
c.Severities, c.IgnoreUnfixed, c.IgnoreFile, c.IgnorePolicy)
if err != nil {
return xerrors.Errorf("unable to filter vulnerabilities: %w", err)
Expand Down
3 changes: 1 addition & 2 deletions internal/client/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ func run(c config.Config) (err error) {

vulnClient := initializeVulnerabilityClient()
for i := range results {
var vulns []types.DetectedVulnerability
vulns, err = vulnClient.Filter(ctx, results[i].Vulnerabilities,
vulns, err := vulnClient.Filter(ctx, results[i].Vulnerabilities,
c.Severities, c.IgnoreUnfixed, c.IgnoreFile, c.IgnorePolicy)
if err != nil {
return err
Expand Down
33 changes: 12 additions & 21 deletions pkg/detector/ospkg/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,36 +64,27 @@ func (d Detector) Detect(_, osFamily, osName string, _ time.Time, pkgs []ftypes.

func newDriver(osFamily, osName string) Driver {
// TODO: use DI and change struct names
var d Driver
switch osFamily {
case fos.Alpine:
d = alpine.NewScanner()
return d
return alpine.NewScanner()
case fos.Debian:
d = debian.NewScanner()
return d
return debian.NewScanner()
case fos.Ubuntu:
d = ubuntu.NewScanner()
return d
return ubuntu.NewScanner()
case fos.RedHat, fos.CentOS:
d = redhat.NewScanner()
return d
return redhat.NewScanner()
case fos.Amazon:
d = amazon.NewScanner()
return d
return amazon.NewScanner()
case fos.Oracle:
d = oracle.NewScanner()
return d
return oracle.NewScanner()
case fos.OpenSUSELeap:
d = suse.NewScanner(suse.OpenSUSE)
return d
return suse.NewScanner(suse.OpenSUSE)
case fos.SLES:
d = suse.NewScanner(suse.SUSEEnterpriseLinux)
return d
return suse.NewScanner(suse.SUSEEnterpriseLinux)
case fos.Photon:
d = photon.NewScanner()
return d
return photon.NewScanner()
default:
log.Logger.Warnf("unsupported os : %s", osFamily)
return nil
}
log.Logger.Warnf("unsupported os : %s", osFamily)
return nil
}