mirror of https://github.com/daffainfo/nuclei.git
Moved colorizer stuff to pkg/output
parent
e1bbb9d93d
commit
e6958d7aea
|
@ -1,42 +0,0 @@
|
|||
package colorizer
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/logrusorgru/aurora"
|
||||
)
|
||||
|
||||
const (
|
||||
fgOrange uint8 = 208
|
||||
undefined string = "undefined"
|
||||
)
|
||||
|
||||
// NucleiColorizer contains the severity color mapping
|
||||
type NucleiColorizer struct {
|
||||
Colorizer aurora.Aurora
|
||||
SeverityMap map[string]string
|
||||
}
|
||||
|
||||
// NewNucleiColorizer initializes the new nuclei colorizer
|
||||
func NewNucleiColorizer(colorizer aurora.Aurora) *NucleiColorizer {
|
||||
return &NucleiColorizer{
|
||||
Colorizer: colorizer,
|
||||
SeverityMap: map[string]string{
|
||||
"info": colorizer.Blue("info").String(),
|
||||
"low": colorizer.Green("low").String(),
|
||||
"medium": colorizer.Yellow("medium").String(),
|
||||
"high": colorizer.Index(fgOrange, "high").String(),
|
||||
"critical": colorizer.Red("critical").String(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// GetColorizedSeverity returns the colorized severity string
|
||||
func (r *NucleiColorizer) GetColorizedSeverity(severity string) string {
|
||||
sev := r.SeverityMap[strings.ToLower(severity)]
|
||||
if sev == "" {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return sev
|
||||
}
|
|
@ -13,6 +13,8 @@ import (
|
|||
type Writer interface {
|
||||
// Close closes the output writer interface
|
||||
Close()
|
||||
// Colorizer returns the colorizer instance for writer
|
||||
Colorizer() aurora.Aurora
|
||||
// Write writes the event to file and/or screen.
|
||||
Write(Event) error
|
||||
// Request writes a log the requests trace log
|
||||
|
@ -135,6 +137,11 @@ func (w *StandardWriter) Request(templateID, url, requestType string, err error)
|
|||
w.traceMutex.Unlock()
|
||||
}
|
||||
|
||||
// Colorizer returns the colorizer instance for writer
|
||||
func (w *StandardWriter) Colorizer() aurora.Aurora {
|
||||
return w.aurora
|
||||
}
|
||||
|
||||
// Close closes the output writing interface
|
||||
func (w *StandardWriter) Close() {
|
||||
if w.outputFile != nil {
|
||||
|
|
Loading…
Reference in New Issue