Possible error in lexer.go

オープン
#97 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@AdamMagued がすでに取り組んでいます。

2026年10月10日 から。

  • #104 @AdamMagued による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
go
領域
compilers

調査の方向性

lexer.go の 389 行目付近にある consumeUnquotedIdentifier から始め、r = 128 で提供された Go の例を再現します。その入力で lexer がパニックしなくなったことを確認し、意図された識別子スキャンの動作を維持します。

索引モデルが 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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

jmespath/go-jmespath のほかの issue

jmespath/go-jmespath の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。