@@ -319,6 +319,7 @@ func (h *TextHandler) traces(traces []*findingSummary) {
319319}
320320
321321func (h * TextHandler ) summary (c summaryCounters ) {
322+ // print short summary of findings identified at the desired level of scan precision
322323 var vulnCount int
323324 h .print ("Your code " , choose (h .scanLevel .WantSymbols (), "is" , "may be" ), " affected by " )
324325 switch h .scanLevel {
@@ -346,6 +347,20 @@ func (h *TextHandler) summary(c summaryCounters) {
346347 }
347348 h .print (".\n " )
348349
350+ // print summary for vulnerabilities found at other levels of scan precision
351+ if other := h .summaryOtherVulns (c ); other != "" {
352+ h .wrap ("" , other , 80 )
353+ h .print ("\n " )
354+ }
355+
356+ // print suggested flags for more/better info depending on scan level and if in verbose mode
357+ if sugg := h .summarySuggestion (); sugg != "" {
358+ h .wrap ("" , sugg , 80 )
359+ h .print ("\n " )
360+ }
361+ }
362+
363+ func (h * TextHandler ) summaryOtherVulns (c summaryCounters ) string {
349364 var summary strings.Builder
350365 if c .VulnerabilitiesRequired + c .VulnerabilitiesImported == 0 {
351366 summary .WriteString ("This scan found no other vulnerabilities in " )
@@ -367,26 +382,26 @@ func (h *TextHandler) summary(c summaryCounters) {
367382 summary .WriteString (choose (h .scanLevel .WantSymbols (), ", but your code doesn't appear to call these vulnerabilities." , "." ))
368383 }
369384 }
370- h .wrap ("" , summary .String (), 80 )
371- h .print ("\n " )
372- // print suggested flags for more/better info depending on scan level and if in verbose mode
385+ return summary .String ()
386+ }
387+
388+ func (h * TextHandler ) summarySuggestion () string {
389+ var sugg strings.Builder
373390 switch h .scanLevel {
374391 case govulncheck .ScanLevelSymbol :
375392 if ! h .showAllVulns {
376- h . print ("Use " , verboseMessage , "." )
393+ sugg . WriteString ("Use " + verboseMessage + "." )
377394 }
378395 case govulncheck .ScanLevelPackage :
379- var message strings.Builder
380- message .WriteString ("Use " + symbolMessage )
396+ sugg .WriteString ("Use " + symbolMessage )
381397 if ! h .showAllVulns {
382- message .WriteString (" and " + verboseMessage )
398+ sugg .WriteString (" and " + verboseMessage )
383399 }
384- message .WriteString ("." )
385- h .wrap ("" , message .String (), 80 )
400+ sugg .WriteString ("." )
386401 case govulncheck .ScanLevelModule :
387- h . print ("Use " , symbolMessage , "." )
402+ sugg . WriteString ("Use " + symbolMessage + "." )
388403 }
389- h . print ( " \n " )
404+ return sugg . String ( )
390405}
391406
392407func (h * TextHandler ) style (style style , values ... any ) {
0 commit comments