Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
Fix infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed May 9, 2024
1 parent 8f17bfa commit 4f59cf8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions security/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// Format formats the vulnerabilities in the given format
func Format(vulns *Vulnerabilities, format string) ([]byte, error) {
if format == "ansi" {
return ToANSI(vulns), nil
return ToANSI(vulns, false), nil
} else if format == "text" || format == "txt" || format == "markdown" || format == "md" {
return ToMarkdown(vulns), nil
} else if format == "json" {
Expand All @@ -29,8 +29,8 @@ func Format(vulns *Vulnerabilities, format string) ([]byte, error) {
}

// ToANSI returns vulnerabilities as text with ANSI code for colors
func ToANSI(vulns *Vulnerabilities) []byte {
if !hasPosixColorSupport() {
func ToANSI(vulns *Vulnerabilities, forceANSICodes bool) []byte {
if !hasPosixColorSupport() && !forceANSICodes {
return ToMarkdown(vulns)
}

Expand Down Expand Up @@ -81,7 +81,7 @@ var ansiRe = regexp.MustCompile("(\u001B\\[\\d+m|\u001B\\]8;;.*?\u0007)")

// ToMarkdown returns vulnerabilities as Markdown
func ToMarkdown(vulns *Vulnerabilities) []byte {
return ansiRe.ReplaceAll(ToANSI(vulns), nil)
return ansiRe.ReplaceAll(ToANSI(vulns, true), nil)
}

// ToJSON outputs vulnerabilities as JSON
Expand Down

0 comments on commit 4f59cf8

Please sign in to comment.