github.com/projectdiscovery/nuclei/v2@v2.9.15/internal/colorizer/colorizer.go (about) 1 package colorizer 2 3 import ( 4 "fmt" 5 6 "github.com/logrusorgru/aurora" 7 8 "github.com/projectdiscovery/nuclei/v2/pkg/model/types/severity" 9 ) 10 11 const ( 12 fgOrange uint8 = 208 13 ) 14 15 func GetColor(colorizer aurora.Aurora, templateSeverity fmt.Stringer) string { 16 var method func(arg interface{}) aurora.Value 17 switch templateSeverity { 18 case severity.Info: 19 method = colorizer.Blue 20 case severity.Low: 21 method = colorizer.Green 22 case severity.Medium: 23 method = colorizer.Yellow 24 case severity.High: 25 method = func(stringValue interface{}) aurora.Value { return colorizer.Index(fgOrange, stringValue) } 26 case severity.Critical: 27 method = colorizer.Red 28 default: 29 method = colorizer.White 30 } 31 32 return method(templateSeverity.String()).String() 33 } 34 35 func New(colorizer aurora.Aurora) func(severity.Severity) string { 36 return func(severity severity.Severity) string { 37 return GetColor(colorizer, severity) 38 } 39 }