mirror of
https://github.com/safedep/vet.git
synced 2025-12-13 06:36:59 -06:00
Isolate query params
This commit is contained in:
parent
4e5b5412c2
commit
c8248ce9bd
23
query.go
23
query.go
@ -9,10 +9,11 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
// We will re-use the variable declarations in scan.go
|
var (
|
||||||
// since query.go is a subset of scan function where
|
queryFilterExpression string
|
||||||
// data is loaded from JSON instead of lockfiles and enriched
|
queryLoadDirectory string
|
||||||
// with backend
|
queryEnableConsoleReport bool
|
||||||
|
)
|
||||||
|
|
||||||
func newQueryCommand() *cobra.Command {
|
func newQueryCommand() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
@ -24,11 +25,11 @@ func newQueryCommand() *cobra.Command {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().StringVarP(&dumpJsonManifestDir, "from", "F", "",
|
cmd.Flags().StringVarP(&queryLoadDirectory, "from", "F", "",
|
||||||
"The directory to load JSON dump files")
|
"The directory to load JSON dump files")
|
||||||
cmd.Flags().StringVarP(&celFilterExpression, "filter", "", "",
|
cmd.Flags().StringVarP(&queryFilterExpression, "filter", "", "",
|
||||||
"Filter and print packages using CEL")
|
"Filter and print packages using CEL")
|
||||||
cmd.Flags().BoolVarP(&consoleReport, "report-console", "", false,
|
cmd.Flags().BoolVarP(&queryEnableConsoleReport, "report-console", "", false,
|
||||||
"Minimal summary of package manifest")
|
"Minimal summary of package manifest")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
@ -46,8 +47,8 @@ func internalStartQuery() error {
|
|||||||
reporters := []reporter.Reporter{}
|
reporters := []reporter.Reporter{}
|
||||||
enrichers := []scanner.PackageMetaEnricher{}
|
enrichers := []scanner.PackageMetaEnricher{}
|
||||||
|
|
||||||
if !utils.IsEmptyString(celFilterExpression) {
|
if !utils.IsEmptyString(queryFilterExpression) {
|
||||||
task, err := analyzer.NewCelFilterAnalyzer(celFilterExpression)
|
task, err := analyzer.NewCelFilterAnalyzer(queryFilterExpression)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -55,7 +56,7 @@ func internalStartQuery() error {
|
|||||||
analyzers = append(analyzers, task)
|
analyzers = append(analyzers, task)
|
||||||
}
|
}
|
||||||
|
|
||||||
if consoleReport {
|
if queryEnableConsoleReport {
|
||||||
rp, err := reporter.NewConsoleReporter()
|
rp, err := reporter.NewConsoleReporter()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -68,5 +69,5 @@ func internalStartQuery() error {
|
|||||||
TransitiveAnalysis: false,
|
TransitiveAnalysis: false,
|
||||||
}, enrichers, analyzers, reporters)
|
}, enrichers, analyzers, reporters)
|
||||||
|
|
||||||
return pmScanner.ScanDumpDirectory(dumpJsonManifestDir)
|
return pmScanner.ScanDumpDirectory(queryLoadDirectory)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user