mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 12:05:52 +00:00
Merge pull request #68 from GoASTScanner/command_line_fixes
Command line fixes
This commit is contained in:
commit
ce2c3283d9
1 changed files with 12 additions and 2 deletions
14
main.go
14
main.go
|
@ -33,13 +33,17 @@ import (
|
|||
var flagIgnoreNoSec = flag.Bool("nosec", false, "Ignores #nosec comments when set")
|
||||
|
||||
// format output
|
||||
var flagFormat = flag.String("fmt", "text", "Set output format. Valid options are: json, csv, or text")
|
||||
var flagFormat = flag.String("fmt", "text", "Set output format. Valid options are: json, csv, html, or text")
|
||||
|
||||
// output file
|
||||
var flagOutput = flag.String("out", "", "Set output file for results")
|
||||
|
||||
// config file
|
||||
var flagConfig = flag.String("conf", "", "Path to optional config file")
|
||||
|
||||
// quiet
|
||||
var flagQuiet = flag.Bool("quiet", false, "Only show output when errors are found")
|
||||
|
||||
var usageText = `
|
||||
GAS - Go AST Scanner
|
||||
|
||||
|
@ -216,6 +220,12 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
issuesFound := len(analyzer.Issues) > 0
|
||||
// Exit quietly if nothing was found
|
||||
if !issuesFound && *flagQuiet {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Create output report
|
||||
if *flagOutput != "" {
|
||||
outfile, err := os.Create(*flagOutput)
|
||||
|
@ -229,7 +239,7 @@ func main() {
|
|||
}
|
||||
|
||||
// Do we have an issue? If so exit 1
|
||||
if len(analyzer.Issues) > 0 {
|
||||
if issuesFound {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue