mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Changed db.path flag to cache
This commit is contained in:
parent
24cbae6570
commit
f4540ea4ce
5 changed files with 13 additions and 13 deletions
|
|
@ -26,7 +26,7 @@ var collectCmd = &cobra.Command{
|
|||
l := log.NewLogger(logrus.New(), logrus.DebugLevel)
|
||||
|
||||
// get probe states stored in db from scan
|
||||
probeStates, err := sqlite.GetProbeResults(dbpath)
|
||||
probeStates, err := sqlite.GetProbeResults(cachePath)
|
||||
if err != nil {
|
||||
l.Log.Errorf("failed toget states: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ var listCmd = &cobra.Command{
|
|||
Use: "list",
|
||||
Short: "List information from scan",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
probeResults, err := sqlite.GetProbeResults(dbpath)
|
||||
probeResults, err := sqlite.GetProbeResults(cachePath)
|
||||
if err != nil {
|
||||
logrus.Errorf("failed toget probe results: %v\n", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ var (
|
|||
cacertPath string
|
||||
username string
|
||||
password string
|
||||
dbpath string
|
||||
cachePath string
|
||||
outputPath string
|
||||
configPath string
|
||||
verbose bool
|
||||
|
|
@ -83,13 +83,13 @@ func init() {
|
|||
rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "set the config file path")
|
||||
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "set output verbosity")
|
||||
rootCmd.PersistentFlags().StringVar(&accessToken, "access-token", "", "set the access token")
|
||||
rootCmd.PersistentFlags().StringVar(&dbpath, "db.path", fmt.Sprintf("/tmp/%smagellan/magellan.db", currentUser.Username+"/"), "set the probe storage path")
|
||||
rootCmd.PersistentFlags().StringVar(&cachePath, "cache", fmt.Sprintf("/tmp/%smagellan/magellan.db", currentUser.Username+"/"), "set the scanning result cache path")
|
||||
|
||||
// bind viper config flags with cobra
|
||||
viper.BindPFlag("concurrency", rootCmd.Flags().Lookup("concurrency"))
|
||||
viper.BindPFlag("timeout", rootCmd.Flags().Lookup("timeout"))
|
||||
viper.BindPFlag("verbose", rootCmd.Flags().Lookup("verbose"))
|
||||
viper.BindPFlag("db.path", rootCmd.Flags().Lookup("db.path"))
|
||||
viper.BindPFlag("cache", rootCmd.Flags().Lookup("cache"))
|
||||
viper.BindPFlags(rootCmd.Flags())
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ func SetDefaults() {
|
|||
viper.SetDefault("timeout", 30)
|
||||
viper.SetDefault("config", "")
|
||||
viper.SetDefault("verbose", false)
|
||||
viper.SetDefault("db.path", "/tmp/magellan/magellan.db")
|
||||
viper.SetDefault("cache", "/tmp/magellan/magellan.db")
|
||||
viper.SetDefault("scan.hosts", []string{})
|
||||
viper.SetDefault("scan.ports", []int{})
|
||||
viper.SetDefault("scan.subnets", []string{})
|
||||
|
|
|
|||
|
|
@ -82,12 +82,12 @@ var scanCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
// make the dbpath dir if needed
|
||||
err := os.MkdirAll(path.Dir(dbpath), 0766)
|
||||
err := os.MkdirAll(path.Dir(cachePath), 0766)
|
||||
if err != nil {
|
||||
fmt.Printf("failed tomake database directory: %v", err)
|
||||
}
|
||||
|
||||
sqlite.InsertProbeResults(dbpath, &probeStates)
|
||||
sqlite.InsertProbeResults(cachePath, &probeStates)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue