Changed failure text from json to plaintext.

This commit is contained in:
Wong Her Laang 2018-01-27 12:43:08 +08:00
parent 4059facfb9
commit fdc78c0c47

View file

@ -1,8 +1,8 @@
package output package output
import ( import (
"encoding/json"
"encoding/xml" "encoding/xml"
"strconv"
"github.com/GoASTScanner/gas" "github.com/GoASTScanner/gas"
) )
@ -51,15 +51,17 @@ func createJUnitXMLStruct(groupedData map[string][]*gas.Issue) JUnitXMLReport {
Tests: len(issues), Tests: len(issues),
} }
for _, issue := range issues { for _, issue := range issues {
stacktrace, err := json.MarshalIndent(issue, "", "\t") text := "Results:\n"
if err != nil { text += "[" + issue.File + ":" + issue.Line + "] - " +
panic(err) issue.What + " (Confidence: " + strconv.Itoa(int(issue.Confidence)) +
} ", Severity: " + strconv.Itoa(int(issue.Severity)) + ")\n"
text += "> " + issue.Code
testcase := Testcase{ testcase := Testcase{
Name: issue.File, Name: issue.File,
Failure: Failure{ Failure: Failure{
Message: "Found 1 vulnerability. See stacktrace for details.", Message: "Found 1 vulnerability. See stacktrace for details.",
Text: string(stacktrace), Text: text,
}, },
} }
testsuite.Testcases = append(testsuite.Testcases, testcase) testsuite.Testcases = append(testsuite.Testcases, testcase)