Skip to content

Commit

Permalink
fix color output issues
Browse files Browse the repository at this point in the history
* fix color output on windows
* add --disable-color flag to disable color output
  • Loading branch information
nl5887 committed Dec 16, 2021
1 parent 9d791de commit 59407da
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/app.go
Expand Up @@ -20,6 +20,7 @@ import (

"os"

"github.com/fatih/color"
"github.com/gosuri/uilive"
_ "github.com/op/go-logging"
)
Expand Down Expand Up @@ -72,6 +73,7 @@ func New(options ...OptionFn) (*fuzzer, error) {
}

b.writer = uilive.New()
b.writer.Out = color.Output

for k, v := range signatures {
h, _ := hex.DecodeString(v)
Expand Down
6 changes: 6 additions & 0 deletions cmd/cmd.go
Expand Up @@ -34,6 +34,10 @@ var globalFlags = []cli.Flag{
"085e0b34e40533015ba6a73e85933472702654e471c32f276e76cffcf7b13869",
),
},
&cli.BoolFlag{
Name: "disable-color",
Usage: "disable color output",
},
&cli.IntFlag{
Name: "num-threads",
Usage: "the number of threads to use",
Expand Down Expand Up @@ -290,6 +294,8 @@ func New() *Cmd {
fmt.Println("divd-2021-00038--log4j-scanner by DTACT")
fmt.Println("http://github.com/dtact/divd-2021-00038--log4j-scanner")
fmt.Println("--------------------------------------")

color.NoColor = c.Bool("no-color")
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Expand Up @@ -41,7 +41,7 @@ require (
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/masterzen/simplexml v0.0.0-20160608183007-4572e39b1ab9 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
Expand All @@ -53,7 +53,7 @@ require (
github.com/sirupsen/logrus v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9 // indirect
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Expand Up @@ -113,6 +113,8 @@ github.com/masterzen/winrm v0.0.0-20210623064412-3b76017826b0 h1:KqYuDbSr8I2X8H6
github.com/masterzen/winrm v0.0.0-20210623064412-3b76017826b0/go.mod h1:l31LCh9VvG43RJ83A5JLkFPjuz48cZAxBSLQLaIn1p8=
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
Expand Down Expand Up @@ -197,6 +199,9 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down
8 changes: 7 additions & 1 deletion main.go
@@ -1,8 +1,14 @@
package main

import "github.com/dutchcoders/divd-2021-00038--log4j-scanner/cmd"
import (
"github.com/dutchcoders/divd-2021-00038--log4j-scanner/cmd"
"github.com/fatih/color"
"github.com/urfave/cli/v2"
)

func main() {
cli.ErrWriter = color.Output

app := cmd.New()
app.RunAndExitOnError()
}

0 comments on commit 59407da

Please sign in to comment.