Skip to content

Commit

Permalink
refactor: move experimental flags into their own struct (#463)
Browse files Browse the repository at this point in the history
This pulls across the experimental struct from #183 which I'm assuming
folks are happy with given that PR is approved - I think it is good to
land this in its own PR as its technically an allowed breaking change
(or "experimental change" if you will), and that way it can be
explicitly linked to in changelogs etc without having to understand #183
as much.
  • Loading branch information
G-Rath authored Aug 2, 2023
1 parent 1898ead commit e6eccc2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
20 changes: 11 additions & 9 deletions cmd/osv-scanner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,17 @@ func run(args []string, stdout, stderr io.Writer) int {
}

vulnResult, err := osvscanner.DoScan(osvscanner.ScannerActions{
LockfilePaths: context.StringSlice("lockfile"),
SBOMPaths: context.StringSlice("sbom"),
DockerContainerNames: context.StringSlice("docker"),
Recursive: context.Bool("recursive"),
SkipGit: context.Bool("skip-git"),
NoIgnore: context.Bool("no-ignore"),
ConfigOverridePath: context.String("config"),
DirectoryPaths: context.Args().Slice(),
ExperimentalCallAnalysis: context.Bool("experimental-call-analysis"),
LockfilePaths: context.StringSlice("lockfile"),
SBOMPaths: context.StringSlice("sbom"),
DockerContainerNames: context.StringSlice("docker"),
Recursive: context.Bool("recursive"),
SkipGit: context.Bool("skip-git"),
NoIgnore: context.Bool("no-ignore"),
ConfigOverridePath: context.String("config"),
DirectoryPaths: context.Args().Slice(),
ExperimentalScannerActions: osvscanner.ExperimentalScannerActions{
CallAnalysis: context.Bool("experimental-call-analysis"),
},
}, r)

if err != nil &&
Expand Down
8 changes: 6 additions & 2 deletions pkg/osvscanner/osvscanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ type ScannerActions struct {
DockerContainerNames []string
ConfigOverridePath string

ExperimentalCallAnalysis bool
ExperimentalScannerActions
}

type ExperimentalScannerActions struct {
CallAnalysis bool
}

// NoPackagesFoundErr for when no packages are found during a scan.
Expand Down Expand Up @@ -571,7 +575,7 @@ func DoScan(actions ScannerActions, r reporter.Reporter) (models.VulnerabilityRe
return models.VulnerabilityResults{}, fmt.Errorf("failed to hydrate OSV response: %w", err)
}

vulnerabilityResults := groupResponseBySource(r, query, hydratedResp, actions.ExperimentalCallAnalysis)
vulnerabilityResults := groupResponseBySource(r, query, hydratedResp, actions.CallAnalysis)

filtered := filterResults(r, &vulnerabilityResults, &configManager)
if filtered > 0 {
Expand Down

0 comments on commit e6eccc2

Please sign in to comment.