Skip to content

Commit e4dc797

Browse files
Dboy0ZDevDennis Tuan Anh Quach
authored andcommitted
Fixed long links not breaking in Scan Results (Issue-1532)
1 parent eeeeab7 commit e4dc797

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

cmd/devguard-scanner/scanner/print.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ func PrintFirstPartyScanResults(scanResponse dtos.FirstPartyScanResponse, assetN
5656

5757
func PrintSecretScanResults(firstPartyVulns []dtos.FirstPartyVulnDTO, webUI string, assetName string, assetVersionName string) {
5858
tw := table.NewWriter()
59-
tw.SetAllowedRowLength(130)
59+
rowLengthLimit := 130
60+
tw.SetAllowedRowLength(rowLengthLimit)
6061

6162
blue := text.FgBlue
6263
green := text.FgGreen
@@ -69,7 +70,7 @@ func PrintSecretScanResults(firstPartyVulns []dtos.FirstPartyVulnDTO, webUI stri
6970
for _, snippet := range vuln.SnippetContents {
7071
tw.AppendRow(table.Row{"Snippet", snippet.Snippet})
7172
}
72-
raw = []table.Row{{"Message:", text.WrapText(*vuln.Message, 80)},
73+
raw = []table.Row{{"Message:", text.WrapText(*vuln.Message, rowLengthLimit)},
7374

7475
{"Commit:", vuln.Commit},
7576
{"Author:", vuln.Author},
@@ -80,14 +81,17 @@ func PrintSecretScanResults(firstPartyVulns []dtos.FirstPartyVulnDTO, webUI stri
8081
tw.AppendSeparator()
8182
}
8283

83-
tw.AppendRow(table.Row{"Link", blue.Sprint(fmt.Sprintf("%s/%s/refs/%s/code-risks/", webUI, assetName, slug.Make(assetVersionName)))})
84+
link := blue.Sprint(fmt.Sprintf("%s/%s/refs/%s/code-risks/", webUI, assetName, slug.Make(assetVersionName)))
85+
wrappedLink := text.WrapText(link, rowLengthLimit)
86+
tw.AppendRow(table.Row{"Link", wrappedLink})
8487

8588
fmt.Println(tw.Render())
8689
}
8790

8891
func PrintSastScanResults(firstPartyVulns []dtos.FirstPartyVulnDTO, webUI, assetName string, assetVersionName string) {
8992
tw := table.NewWriter()
90-
tw.SetAllowedRowLength(130)
93+
rowLengthLimit := 130
94+
tw.SetAllowedRowLength(rowLengthLimit)
9195

9296
blue := text.FgBlue
9397
green := text.FgGreen
@@ -96,14 +100,18 @@ func PrintSastScanResults(firstPartyVulns []dtos.FirstPartyVulnDTO, webUI, asset
96100
for _, snippet := range vuln.SnippetContents {
97101
tw.AppendRow(table.Row{"Snippet", snippet.Snippet})
98102
}
99-
tw.AppendRow(table.Row{"Message", text.WrapText(*vuln.Message, 80)})
103+
tw.AppendRow(table.Row{"Message", text.WrapText(*vuln.Message, rowLengthLimit)})
100104
if vuln.URI != "" {
101105
tw.AppendRow(table.Row{"File", green.Sprint(vuln.URI)})
102106

103107
}
104108
tw.AppendSeparator()
105109
}
106-
tw.AppendRow(table.Row{"Link", blue.Sprint(fmt.Sprintf("%s/%s/refs/%s/code-risks/", webUI, assetName, slug.Make(assetVersionName)))})
110+
111+
link := blue.Sprint(fmt.Sprintf("%s/%s/refs/%s/code-risks/", webUI, assetName, slug.Make(assetVersionName)))
112+
wrappedLink := text.WrapText(link, rowLengthLimit)
113+
tw.AppendRow(table.Row{"Link", wrappedLink})
114+
107115
fmt.Println(tw.Render())
108116
}
109117

0 commit comments

Comments
 (0)