Possible error in lexer.go
评估
调研方向
从 lexer.go 中大约第 389 行的 consumeUnquotedIdentifier 开始,使用 r = 128 重现所提供的 Go 示例。确认 lexer 对该输入不再发生 panic,同时保留预期的标识符扫描行为。
由索引模型根据 Issue 内容生成。
描述
Hi!
I checked my project, which has the go-jmespath library in its dependencies, with the SAST tool and found some problems in the go-jmespath code.
On line 389, SAST was triggered by a possible index out of range problem.
func (lexer *Lexer) consumeUnquotedIdentifier() token {
// Consume runes until we reach the end of an unquoted
// identifier.
start := lexer.currentPos - lexer.lastWidth
for {
r := lexer.next()
if r < 0 || r > 128 || identifierTrailingBits[uint64(r)/64]&(1<<(uint64(r)%64)) == 0 {
lexer.back()
break
}
}
value := lexer.expression[start:lexer.currentPos]
return token{
tokenType: tUnquotedIdentifier,
value: value,
position: start,
length: lexer.currentPos - start,
}
}
I found that when r = 128 a panic occurs
package main
import "fmt"
func main() {
var identifierTrailingBits = [2]uint64{287948901175001088, 576460745995190270}
var r rune = 128
if r < 0 || r > 128 || identifierTrailingBits[uint64(r)/64]&(1<<(uint64(r)%64)) == 0 {
fmt.Println("yes")
} else {
fmt.Println("no")
}
}
result
panic: runtime error: index out of range [2] with length 2
- 主要语言
- Go
- 星标
- 623
- 派生
- 105
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
jmespath/go-jmespath 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 25/100
jmespath/go-jmespath#96 · 1 条评论 ·
-
Can nested JSON string parsing be supported?可能已有人在做 @joerodriguez 于 1047 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 45/100
jmespath/go-jmespath#91 ·
-
难度 3/5 1-2 天 新手友好度 45/100
jmespath/go-jmespath#90 · 5 条评论 ·
-
难度 3/5 1-2 天 新手友好度 30/100
jmespath/go-jmespath#85 · 1 条评论 ·
-
Probable bug: mysterious nulls from wildcard expression可能已有人在做 @SAY-5 于 202 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 38/100
jmespath/go-jmespath#84 ·
查看 jmespath/go-jmespath 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 3 天内回复
-
agent-execution/02 row 4: consumers Verify row lacks delivery/base binding, cannot pass post-merge未关闭bug effort:s impact:low raised-by:verifier risk:low
难度 2/5 1-3 小时 新手友好度 74/100
medici-finance/assay#7946 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 1/5 1 小时以内 新手友好度 88/100
nwverse/persona#19269 · 1 条评论 ·
维护者通常 1 天内回复
-
console stage:spec
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
tsukumogami/tsuku#2830 · 1 条评论 ·