mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 12:05:52 +00:00
Merge branch 'master' of https://github.com/GoASTScanner/gas into nosec-specify-rule
This commit is contained in:
commit
7bb6f004ae
5 changed files with 28 additions and 3 deletions
13
.github/issue_template.md
vendored
Normal file
13
.github/issue_template.md
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
### Steps to reproduce the behavior
|
||||||
|
|
||||||
|
### Gas version
|
||||||
|
|
||||||
|
### Go version (output of 'go version')
|
||||||
|
|
||||||
|
### Operating system / Environment
|
||||||
|
|
||||||
|
### Expected behavior
|
||||||
|
|
||||||
|
### Actual behavior
|
2
Godeps/Godeps.json
generated
2
Godeps/Godeps.json
generated
|
@ -296,7 +296,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "gopkg.in/yaml.v2",
|
"ImportPath": "gopkg.in/yaml.v2",
|
||||||
"Rev": "eb3733d160e74a9c7e442f435eb3bea458e1d19f"
|
"Rev": "d670f9405373e636a5a2765eea47fac0c9bc91a4"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ $ gas -nosec=true ./...
|
||||||
|
|
||||||
### Output formats
|
### Output formats
|
||||||
|
|
||||||
Gas currently supports text, json, csv and JUnit XML output formats. By default
|
Gas currently supports text, json, yaml, csv and JUnit XML output formats. By default
|
||||||
results will be reported to stdout, but can also be written to an output
|
results will be reported to stdout, but can also be written to an output
|
||||||
file. The output format is controlled by the '-fmt' flag, and the output file is controlled by the '-out' flag as follows:
|
file. The output format is controlled by the '-fmt' flag, and the output file is controlled by the '-out' flag as follows:
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ var (
|
||||||
flagIgnoreNoSec = flag.Bool("nosec", false, "Ignores #nosec comments when set")
|
flagIgnoreNoSec = flag.Bool("nosec", false, "Ignores #nosec comments when set")
|
||||||
|
|
||||||
// format output
|
// format output
|
||||||
flagFormat = flag.String("fmt", "text", "Set output format. Valid options are: json, csv, junit-xml, html, or text")
|
flagFormat = flag.String("fmt", "text", "Set output format. Valid options are: json, yaml, csv, junit-xml, html, or text")
|
||||||
|
|
||||||
// output file
|
// output file
|
||||||
flagOutput = flag.String("out", "", "Set output file for results")
|
flagOutput = flag.String("out", "", "Set output file for results")
|
||||||
|
|
|
@ -23,6 +23,7 @@ import (
|
||||||
plainTemplate "text/template"
|
plainTemplate "text/template"
|
||||||
|
|
||||||
"github.com/GoASTScanner/gas"
|
"github.com/GoASTScanner/gas"
|
||||||
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ReportFormat enumrates the output format for reported issues
|
// ReportFormat enumrates the output format for reported issues
|
||||||
|
@ -72,6 +73,8 @@ func CreateReport(w io.Writer, format string, issues []*gas.Issue, metrics *gas.
|
||||||
switch format {
|
switch format {
|
||||||
case "json":
|
case "json":
|
||||||
err = reportJSON(w, data)
|
err = reportJSON(w, data)
|
||||||
|
case "yaml":
|
||||||
|
err = reportYAML(w, data)
|
||||||
case "csv":
|
case "csv":
|
||||||
err = reportCSV(w, data)
|
err = reportCSV(w, data)
|
||||||
case "junit-xml":
|
case "junit-xml":
|
||||||
|
@ -99,6 +102,15 @@ func reportJSON(w io.Writer, data *reportInfo) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func reportYAML(w io.Writer, data *reportInfo) error {
|
||||||
|
raw, err := yaml.Marshal(data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = w.Write(raw)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func reportCSV(w io.Writer, data *reportInfo) error {
|
func reportCSV(w io.Writer, data *reportInfo) error {
|
||||||
out := csv.NewWriter(w)
|
out := csv.NewWriter(w)
|
||||||
defer out.Flush()
|
defer out.Flush()
|
||||||
|
|
Loading…
Reference in a new issue