From 10fe7821a09e7a6ab0f71d9ff0687af198152db9 Mon Sep 17 00:00:00 2001 From: HAHWUL Date: Fri, 6 Dec 2024 22:52:46 +0900 Subject: [PATCH] Refactor report generation: extract rendering logic into separate functions for improved clarity and maintainability Signed-off-by: HAHWUL --- pkg/report/report.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/report/report.go b/pkg/report/report.go index 51d22aae..77cced9e 100644 --- a/pkg/report/report.go +++ b/pkg/report/report.go @@ -16,6 +16,11 @@ func GenerateReport(scanResult model.Result, options model.Options) { fmt.Println("+ End: " + scanResult.EndTime.String()) fmt.Println("+ Duration: " + scanResult.Duration.String()) + renderTable(scanResult.Params, options) + renderPoCTable(scanResult.PoCs, options) +} + +func renderTable(params []model.ParamResult, options model.Options) { table := tablewriter.NewWriter(os.Stdout) table.SetHeader([]string{ "Param", @@ -26,7 +31,7 @@ func GenerateReport(scanResult model.Result, options model.Options) { "Chars", }) - for _, v := range scanResult.Params { + for _, v := range params { chars := strings.Join(v.Chars, " ") reflected := "false" if v.Reflected { @@ -45,7 +50,9 @@ func GenerateReport(scanResult model.Result, options model.Options) { } fmt.Println(options.AuroraObject.BrightGreen("\n[ Parameter Analysis ]")) table.Render() +} +func renderPoCTable(pocs []model.PoC, options model.Options) { pocTable := tablewriter.NewWriter(os.Stdout) pocTable.SetHeader([]string{ "#", @@ -57,7 +64,7 @@ func GenerateReport(scanResult model.Result, options model.Options) { "CWE", }) - for i, v := range scanResult.PoCs { + for i, v := range pocs { line := []string{ "#" + strconv.Itoa(i), v.Type, @@ -71,7 +78,7 @@ func GenerateReport(scanResult model.Result, options model.Options) { } fmt.Println(options.AuroraObject.BrightGreen("\n[ XSS PoCs ]")) pocTable.Render() - for i, v := range scanResult.PoCs { + for i, v := range pocs { fmt.Printf("[#%s] %s\n", strconv.Itoa(i), v.Data) } }