Pull length of assets check out, per David's feedback

Signed-off-by: Ben McDonald <ben.mcdonald@hpe.com>
This commit is contained in:
Ben McDonald 2025-07-08 11:11:54 -07:00
parent 96931cd8a3
commit 117783d264
No known key found for this signature in database

View file

@ -145,13 +145,17 @@ var ScanCmd = &cobra.Command{
Include: include, Include: include,
}) })
if len(foundAssets) > 0 && debug {
log.Info().Any("assets", foundAssets).Msgf("found assets from scan")
}
if len(foundAssets) == 0 {
log.Info().Msg("Scan complete. No responsive assets were found.")
return
}
switch format { switch format {
case "json", "yaml": case "json", "yaml":
if len(foundAssets) == 0 {
log.Info().Msg("Scan complete. No responsive assets were found.")
return
}
var output []byte var output []byte
var err error var err error
@ -166,7 +170,6 @@ var ScanCmd = &cobra.Command{
return return
} }
// if -o flag was used, write to file, if not print to console.
if outputPath != "" { if outputPath != "" {
err := os.WriteFile(outputPath, output, 0644) err := os.WriteFile(outputPath, output, 0644)
if err != nil { if err != nil {
@ -179,24 +182,16 @@ var ScanCmd = &cobra.Command{
} }
case "db": case "db":
if len(foundAssets) > 0 && debug {
log.Info().Any("assets", foundAssets).Msgf("found assets from scan")
}
if !disableCache && cachePath != "" { if !disableCache && cachePath != "" {
err := os.MkdirAll(path.Dir(cachePath), 0755) err := os.MkdirAll(path.Dir(cachePath), 0755)
if err != nil { if err != nil {
log.Printf("failed to make cache directory: %v", err) log.Printf("failed to make cache directory: %v", err)
} }
if len(foundAssets) > 0 { err = sqlite.InsertScannedAssets(cachePath, foundAssets...)
err := sqlite.InsertScannedAssets(cachePath, foundAssets...) if err != nil {
if err != nil { log.Error().Err(err).Msg("failed to write scanned assets to cache")
log.Error().Err(err).Msg("failed to write scanned assets to cache") } else if verbose {
} else if verbose { log.Info().Msgf("Saved assets to cache: %s", cachePath)
log.Info().Msgf("Saved assets to cache: %s", cachePath)
}
} else {
log.Warn().Msg("no assets found to save")
} }
} }
default: default: