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,
})
switch format {
case "json", "yaml":
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 {
case "json", "yaml":
var output []byte
var err error
@ -166,7 +170,6 @@ var ScanCmd = &cobra.Command{
return
}
// if -o flag was used, write to file, if not print to console.
if outputPath != "" {
err := os.WriteFile(outputPath, output, 0644)
if err != nil {
@ -179,25 +182,17 @@ var ScanCmd = &cobra.Command{
}
case "db":
if len(foundAssets) > 0 && debug {
log.Info().Any("assets", foundAssets).Msgf("found assets from scan")
}
if !disableCache && cachePath != "" {
err := os.MkdirAll(path.Dir(cachePath), 0755)
if err != nil {
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 {
log.Error().Err(err).Msg("failed to write scanned assets to cache")
} else if verbose {
log.Info().Msgf("Saved assets to cache: %s", cachePath)
}
} else {
log.Warn().Msg("no assets found to save")
}
}
default:
log.Error().Msgf("unknown format specified: %s. Please use 'db', 'json', or 'yaml'.", format)