Skip to content

Commit

Permalink
Merge pull request #196 from cerberauth/display-scans-performed
Browse files Browse the repository at this point in the history
Add summary report output with scans number per status
  • Loading branch information
emmanuelgautier authored Oct 6, 2024
2 parents 34cc0fb + b51eef9 commit 2b0ec34
Show file tree
Hide file tree
Showing 12 changed files with 407 additions and 257 deletions.
2 changes: 1 addition & 1 deletion cmd/discover/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewAPICmd() (apiCmd *cobra.Command) {

internalCmd.TrackScanReport(ctx, tracer, reporter)
printtable.WellKnownPathsScanReport(reporter)
printtable.ContextualScanReport(reporter)
printtable.FingerprintScanReport(reporter)
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/discover/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewDomainCmd() (domainCmd *cobra.Command) {

internalCmd.TrackScanReport(ctx, tracer, reporter)
printtable.WellKnownPathsScanReport(reporter)
printtable.ContextualScanReport(reporter)
printtable.FingerprintScanReport(reporter)
}
},
}
Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ func PrintOrExportReport(format string, transport string, report *report.Reporte

func PrintTable(report *report.Reporter) {
printtable.WellKnownPathsScanReport(report)
printtable.ContextualScanReport(report)
printtable.FingerprintScanReport(report)
printtable.DisplayReportSummaryTable(report)
printtable.DisplayReportTable(report)
}

Expand Down
89 changes: 89 additions & 0 deletions internal/cmd/printtable/fingerprint_table.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package printtable

import (
"fmt"

"github.com/cerberauth/vulnapi/report"
"github.com/cerberauth/vulnapi/scan/discover/fingerprint"
"github.com/olekukonko/tablewriter"
)

func FingerprintScanReport(reporter *report.Reporter) {
report := reporter.GetReportByID(fingerprint.DiscoverFingerPrintScanID)
if report == nil || !report.HasData() {
return
}

data, ok := report.Data.(fingerprint.FingerPrintData)
if !ok {
return
}

rows := [][]string{}
for _, fp := range data.AuthServices {
rows = append(rows, []string{"Authentication Service", fp.Name})
}

for _, fp := range data.CDNs {
rows = append(rows, []string{"CDN", fp.Name})
}

for _, fp := range data.Caching {
rows = append(rows, []string{"Caching", fp.Name})
}

for _, fp := range data.CertificateAuthority {
rows = append(rows, []string{"Certificate Authority", fp.Name})
}

for _, fp := range data.Databases {
rows = append(rows, []string{"Database", fp.Name})
}

for _, fp := range data.Frameworks {
rows = append(rows, []string{"Framework", fp.Name})
}

for _, fp := range data.Hosting {
rows = append(rows, []string{"Hosting", fp.Name})
}

for _, fp := range data.Languages {
rows = append(rows, []string{"Language", fp.Name})
}

for _, fp := range data.OS {
rows = append(rows, []string{"Operating System", fp.Name})
}

for _, fp := range data.SecurityServices {
rows = append(rows, []string{"Security Service", fp.Name})
}

for _, fp := range data.ServerExtensions {
rows = append(rows, []string{"Server Extension", fp.Name})
}

for _, fp := range data.Servers {
rows = append(rows, []string{"Server", fp.Name})
}

if len(rows) == 0 {
return
}

fmt.Println()
headers := []string{"Technologie/Service", "Value"}
table := CreateTable(headers)

tableColors := make([]tablewriter.Colors, len(headers))
tableColors[0] = tablewriter.Colors{tablewriter.Bold}
tableColors[1] = tablewriter.Colors{tablewriter.Bold}

for _, row := range rows {
table.Rich(row, tableColors)
}

table.Render()
fmt.Println()
}
254 changes: 0 additions & 254 deletions internal/cmd/printtable/output_table.go

This file was deleted.

23 changes: 23 additions & 0 deletions internal/cmd/printtable/printttable.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package printtable

import (
"fmt"
"os"

"github.com/olekukonko/tablewriter"
)

func CreateTable(headers []string) *tablewriter.Table {
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader(headers)
table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false})
table.SetCenterSeparator("|")
table.SetAutoMergeCellsByColumnIndex([]int{0})

return table
}

func DisplayUnexpectedErrorMessage() {
fmt.Println()
fmt.Println("If you think that report is not accurate or if you have any suggestions for improvements, please open an issue at: https://github.com/cerberauth/vulnapi/issues/new.")
}
Loading

0 comments on commit 2b0ec34

Please sign in to comment.