Add a new flag terse to show only the results and summary (#986)

The new flag '-terse' will only show the results and summary ignoring any logs occured during a scan.

Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
This commit is contained in:
Cosmin Cojocar 2023-07-18 16:21:22 +02:00 committed by GitHub
parent 36f69332a4
commit fc570b6f1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -143,6 +143,9 @@ var (
// output suppression information for auditing purposes // output suppression information for auditing purposes
flagTrackSuppressions = flag.Bool("track-suppressions", false, "Output suppression information, including its kind and justification") flagTrackSuppressions = flag.Bool("track-suppressions", false, "Output suppression information, including its kind and justification")
// flagTerse shows only the summary of scan discarding all the logs
flagTerse = flag.Bool("terse", false, "Shows only the results and summary")
// exclude the folders from scan // exclude the folders from scan
flagDirsExclude arrayFlags flagDirsExclude arrayFlags
@ -354,7 +357,7 @@ func main() {
} }
} }
if *flagQuiet { if *flagQuiet || *flagTerse {
logger = log.New(io.Discard, "", 0) logger = log.New(io.Discard, "", 0)
} else { } else {
logger = log.New(logWriter, "[gosec] ", log.LstdFlags) logger = log.New(logWriter, "[gosec] ", log.LstdFlags)