Skip to content

Commit

Permalink
Making autodetect the new default.
Browse files Browse the repository at this point in the history
Basically if you dont pass in --os then we will attempt to figure it
out.
  • Loading branch information
zendern committed Aug 12, 2020
1 parent 8fda365 commit ad601f1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
13 changes: 12 additions & 1 deletion cmd/chase.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var (

func init() {
rootCmd.AddCommand(chaseCmd)
chaseCmd.PersistentFlags().StringVar(&operating, "os", "debian", "Specify a value for the operating system type you want to scan (alpine, debian, fedora)")
chaseCmd.PersistentFlags().StringVar(&operating, "os", "", "Specify a value for the operating system type you want to scan (alpine, debian, fedora)")
chaseCmd.PersistentFlags().BoolVar(&cleanCache, "clean-cache", false, "Flag to clean the database cache for OSS Index")
chaseCmd.PersistentFlags().StringVar(&ossIndexUser, "user", "", "Specify your OSS Index Username")
chaseCmd.PersistentFlags().StringVar(&ossIndexToken, "token", "", "Specify your OSS Index API Token")
Expand Down Expand Up @@ -140,6 +140,17 @@ var chaseCmd = &cobra.Command{

err = getCVEExcludesFromFile(excludeVulnerabilityFilePath)

if operating == "" {
logLady.Trace("Attempting to detect os for you")
manager, err := packages.DetectPackageManager(logLady)
if err != nil {
logLady.Error(err)
panic(err)
}
operating = manager
}


logLady.Trace("Attempting to audit list of strings from standard in")
pkgs, err := parseStdIn(&operating)
if err != nil {
Expand Down
14 changes: 13 additions & 1 deletion cmd/iq.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/sonatype-nexus-community/ahab/buildversion"
"github.com/sonatype-nexus-community/ahab/logger"
"github.com/sonatype-nexus-community/ahab/packages"
"github.com/sonatype-nexus-community/go-sona-types/iq"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
Expand All @@ -41,7 +42,7 @@ func init() {
rootCmd.AddCommand(iqCmd)

pf := iqCmd.PersistentFlags()
pf.StringVar(&operating, "os", "debian", "Specify a value for the operating system type you want to scan (alpine, debian, fedora)")
pf.StringVar(&operating, "os", "", "Specify a value for the operating system type you want to scan (alpine, debian, fedora)")
pf.StringVar(&iqUsername, "user", "admin", "Specify Nexus IQ Username for request")
pf.StringVar(&iqToken, "token", "admin123", "Specify Nexus IQ Token/Password for request")
pf.StringVar(&ossIndexUser, "oss-index-user", "", "Specify your OSS Index Username")
Expand Down Expand Up @@ -109,6 +110,17 @@ var iqCmd = &cobra.Command{
MaxRetries: maxRetries,
})


if operating == "" {
logLady.Trace("Attempting to detect os for you")
manager, err := packages.DetectPackageManager(logLady)
if err != nil {
logLady.Error(err)
panic(err)
}
operating = manager
}

pkgs, err := parseStdIn(&operating)
if err != nil {
logLady.Error(err)
Expand Down

0 comments on commit ad601f1

Please sign in to comment.