Add -enable-audit cli flag

This commit is contained in:
Alex Gartner 2024-07-11 15:17:55 -07:00 committed by Cosmin Cojocar
parent 87fcb9b95b
commit 2f1b81b889

View file

@ -84,6 +84,9 @@ var (
// #nosec alternative tag
flagAlternativeNoSec = flag.String("nosec-tag", "", "Set an alternative string for #nosec. Some examples: #dontanalyze, #falsepositive")
// flagEnableAudit enables audit mode
flagEnableAudit = flag.Bool("enable-audit", false, "Enable audit mode")
// output file
flagOutput = flag.String("out", "", "Set output file for results")
@ -196,6 +199,9 @@ func loadConfig(configFile string) (gosec.Config, error) {
if *flagAlternativeNoSec != "" {
config.SetGlobal(gosec.NoSecAlternative, *flagAlternativeNoSec)
}
if *flagEnableAudit {
config.SetGlobal(gosec.Audit, "true")
}
// set global option IncludeRules ,when flag set or global option IncludeRules is nil
if v, _ := config.GetGlobal(gosec.IncludeRules); *flagRulesInclude != "" || v == "" {
config.SetGlobal(gosec.IncludeRules, *flagRulesInclude)