Skip to content

Commit

Permalink
Refactor report generation: extract rendering logic into separate fun…
Browse files Browse the repository at this point in the history
…ctions for improved clarity and maintainability

Signed-off-by: HAHWUL <[email protected]>
  • Loading branch information
hahwul committed Dec 6, 2024
1 parent dd40974 commit 10fe782
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 {
Expand All @@ -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{
"#",
Expand All @@ -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,
Expand All @@ -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)
}
}

0 comments on commit 10fe782

Please sign in to comment.