/
listIssues.go
38 lines (34 loc) · 1.2 KB
/
listIssues.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package nessusTools
import (
"fmt"
"github.com/beevik/etree"
)
//ListIssues lists all issues in a collection of Nessus reports by name and ID
func ListIssues(filePath string) ([]string, error) {
//current report hosts are being added from
report := etree.NewDocument()
if err := report.ReadFromFile(filePath); err != nil {
return nil, err
}
issues := []string{}
root := report.SelectElement("NessusClientData_v2")
for _, report := range root.SelectElements("Report") { //Select report branch to iterate over
for _, host := range report.SelectElements("ReportHost") { //Select Reporthost branch to iterate over
for _, item := range host.SelectElements("ReportItem") { //Select ReportItem branch to iterate over
var nameID string
nameID = item.SelectAttrValue("pluginName", "Not Found")
spaces := 70 - len(nameID)
for i := 0; i < spaces; i++ {
nameID += " "
}
nameID += "| ID: " + item.SelectAttrValue("pluginID", "Not Found")
issues = append(issues, nameID) //Select the value of the plugin name attribute(NOT FOUND is the default value)
}
}
}
issues = RemoveDuplicates(issues)
for a, b := range issues {
fmt.Printf("%d | Issue: %s\n", a, b)
}
return issues, nil
}