get-woke / woke

Detect non-inclusive language in your source code.
https://docs.getwoke.tech
MIT License
441 stars 61 forks source link

Failure on non-ascii input #278

Open kian99 opened 2 months ago

kian99 commented 2 months ago

Thank you for creating the issue!

Please include the following information:

Version of woke v0.19.0

When running woke on a file with non-ascii characters, one encounters a runtime error about index out of bounds.

panic: runtime error: index out of range [598] with length 598

goroutine 485 [running]:
github.com/get-woke/woke/pkg/rule.maskInlineIgnore({0xc00017fb80, 0x268})
        /home/kian/go/pkg/mod/github.com/get-woke/woke@v0.19.0/pkg/rule/rule.go:215 +0xea
github.com/get-woke/woke/pkg/rule.(*Rule).FindMatchIndexes(0xc0003183f0, {0xc00017fb80?, 0xc0000b8d20?})
        /home/kian/go/pkg/mod/github.com/get-woke/woke@v0.19.0/pkg/rule/rule.go:36 +0x85
github.com/get-woke/woke/pkg/result.FindResults(0xc0003183f0, {0x7ffe53a39e73, 0x1a}, {0xc00017fb80, 0x268}, 0x71)
        /home/kian/go/pkg/mod/github.com/get-woke/woke@v0.19.0/pkg/result/lineresult.go:48 +0x65
github.com/get-woke/woke/pkg/parser.(*Parser).generateFileFindings(0xc0004ee5d0, 0xc000762008)
        /home/kian/go/pkg/mod/github.com/get-woke/woke@v0.19.0/pkg/parser/findings.go:92 +0xae5
github.com/get-woke/woke/pkg/parser.(*Parser).generateFileFindingsFromFilename(0x0?, {0x7ffe53a39e73?, 0x0?})
        /home/kian/go/pkg/mod/github.com/get-woke/woke@v0.19.0/pkg/parser/findings.go:24 +0xb1
github.com/get-woke/woke/pkg/parser.(*Parser).processFiles.func1({0x7ffe53a39e73?, 0x0?})
        /home/kian/go/pkg/mod/github.com/get-woke/woke@v0.19.0/pkg/parser/parser.go:93 +0x6f
created by github.com/get-woke/woke/pkg/parser.(*Parser).processFiles
        /home/kian/go/pkg/mod/github.com/get-woke/woke@v0.19.0/pkg/parser/parser.go:90 +0x34
make: *** [Makefile:103: woke] Error 2

The error comes from maskInlineIgnore and I'll have a PR up shortly with a proposed fix.

github-actions[bot] commented 2 months ago

👋 Thanks for submitting your first issue!

Please be sure to read and follow our Code of Conduct and Contributing guide.

⭐️ Is your org or open source project using woke? If so, we'd love for you to be included in the 'Who uses woke' list at https://github.com/get-woke/woke/blob/main/docs/about.md#who-uses-woke.