Thank you for creating the issue!
- [x] Yes, I've searched similar issues on GitHub and didn't find any.
- [x] Yes, I've included all information below (version, config, etc).
Toy example of the issue:
[~/Documents/code/woke] nkrichevsky@nkrichevsky-mbp$ cat blah.txt
/* wokeignore:rule=master-slave */ master-slave
[~/Documents/code/woke] nkrichevsky@nkrichevsky-mbp$ ./woke blah.txt
panic: runtime error: slice bounds out of range [:103] with length 47
goroutine 34 [running]:
github.com/get-woke/woke/pkg/result.FindResults(0xc00017b5e0, 0x7ffeefbff3af, 0x8, 0xc0000aa000, 0x2f, 0x1, 0x0, 0x0, 0x0)
/Users/nkrichevsky/Documents/code/woke/pkg/result/lineresult.go:53 +0x445
github.com/get-woke/woke/pkg/parser.(*Parser).generateFileFindings(0xc000198e10, 0xc000092000, 0x0, 0x0, 0x0)
/Users/nkrichevsky/Documents/code/woke/pkg/parser/findings.go:73 +0x5a5
github.com/get-woke/woke/pkg/parser.(*Parser).generateFileFindingsFromFilename(0xc000198e10, 0x7ffeefbff3af, 0x8, 0x0, 0x0, 0x0)
/Users/nkrichevsky/Documents/code/woke/pkg/parser/findings.go:23 +0xcf
github.com/get-woke/woke/pkg/parser.(*Parser).processFiles.func1(0xc0001bc820, 0xc000198e10, 0x7ffeefbff3af, 0x8)
/Users/nkrichevsky/Documents/code/woke/pkg/parser/parser.go:91 +0x6b
created by github.com/get-woke/woke/pkg/parser.(*Parser).processFiles
/Users/nkrichevsky/Documents/code/woke/pkg/parser/parser.go:88 +0x9e
I think this is due to the fact that unicode.ReplacementChar
is actually a three byte symbol (see: https://play.golang.org/p/Jl1WrtoRDM0), so the index within the re function is at the wrong offset. (indeed, changing it from unicode.ReplacementChar
to an underscore removes the panic, but I don't know if this is a suitable solution).
Please include the following information:
Version of woke
$ go run main.go --version
woke version main (it's v0.10.1)
Config file
Default
Go environment
$ go version && go env
go version go1.16.5 darwin/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/nkrichevsky/Library/Caches/go-build"
GOENV="/Users/nkrichevsky/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/nkrichevsky/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/nkrichevsky/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.16.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.16.5/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/gj/6g23qq697ddc5mx6ry8ypdy80000gp/T/go-build2259988605=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
$ ./woke --debug blah.txt
2021-07-21T13:22:59-04:00 DBG woke version main built from 000000 on today
2021-07-21T13:22:59-04:00 DBG rules enabled rules=["whitelist","blacklist","master-slave","slave","grandfathered","man-hours","sanity","dummy","guys","whitebox","blackbox"]
2021-07-21T13:22:59-04:00 DBG adding ignorefile file=.gitignore
2021-07-21T13:22:59-04:00 DBG adding ignorefile file=.wokeignore
2021-07-21T13:22:59-04:00 DBG adding ignorefile file=.git/info/exclude
2021-07-21T13:22:59-04:00 DBG finished compiling ignores durationMS=0.760226
2021-07-21T13:22:59-04:00 DBG created new printer printer=text
2021-07-21T13:22:59-04:00 DBG process files path=blah.txt type=parallel
2021-07-21T13:22:59-04:00 DBG ignoring via in-line file=blah.txt line=1 rule=master-slave
2021-07-21T13:22:59-04:00 DBG finished processing findings durationMS=0.325451 file=blah.txt
panic: runtime error: slice bounds out of range [:103] with length 47
goroutine 34 [running]:
github.com/get-woke/woke/pkg/result.FindResults(0xc0001295e0, 0x7ffeefbff3af, 0x8, 0xc000226000, 0x2f, 0x1, 0x0, 0x0, 0x0)
/Users/nkrichevsky/Documents/code/woke/pkg/result/lineresult.go:53 +0x445
github.com/get-woke/woke/pkg/parser.(*Parser).generateFileFindings(0xc0001451d0, 0xc00020e000, 0x0, 0x0, 0x0)
/Users/nkrichevsky/Documents/code/woke/pkg/parser/findings.go:73 +0x5a5
github.com/get-woke/woke/pkg/parser.(*Parser).generateFileFindingsFromFilename(0xc0001451d0, 0x7ffeefbff3af, 0x8, 0x0, 0x0, 0x0)
/Users/nkrichevsky/Documents/code/woke/pkg/parser/findings.go:23 +0xcf
github.com/get-woke/woke/pkg/parser.(*Parser).processFiles.func1(0xc000168c40, 0xc0001451d0, 0x7ffeefbff3af, 0x8)
/Users/nkrichevsky/Documents/code/woke/pkg/parser/parser.go:91 +0x6b
created by github.com/get-woke/woke/pkg/parser.(*Parser).processFiles
/Users/nkrichevsky/Documents/code/woke/pkg/parser/parser.go:88 +0x9e