Feature request: Public API for MySQL executable comment (/*!...*/) recognition
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #398 của @fujiabao89 — đã đóng, không merge
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- go, mysql
- Lĩnh vực
- api, backend-api-design, databases
Hướng nghiên cứu
Bắt đầu bằng cách kiểm tra các API lexer của mysql/parser, đặc biệt là Lexer.NextToken(), Tokenize(), hàm chưa được export spliceGaps và các định nghĩa token được mô tả trong issue. Tái hiện bốn ví dụ SQL và xem xét các cách tiếp cận được đề xuất cùng các maintainer. Công việc được xem là hoàn tất khi có một tín hiệu công khai, ổn định và được tài liệu hóa để phân biệt các comment thực sự có thể thực thi với comment thông thường, string và các phiên bản không hợp lệ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Background
WebDB P0-04 SQL safety policy requires dialect-AST-based classification for all SQL before execution (see ADR-007). MySQL executable comments (/*!NNNNN ... */) are a documented MySQL extension that can hide DDL/DML statements inside what appears to be a comment. String prefix or regex scanning is not an acceptable security boundary.
Current limitation (verified against v0.0.0-20260728103305-d2f82de1b468)
- No exported ECM token type constant — all token type constants in
mysql/parserare unexported (tok*/kw*) spliceGapsfield in lexer is unexported — ECM boundary information is inaccessible to API consumersLexer.NextToken()/Tokenize()produce normal keyword/literal tokens for ECM content — no way to distinguish ECM-originated tokens from regular SQL tokens- 0/12 true ECM positive cases recognized via public API in our Spike harness
Required API capability
A stable, public, documented mechanism to answer: "Does this SQL contain executable comments?"
The API must distinguish:
- Genuine MySQL executable comments (
/*!NNNNN ... */) - Ordinary block comments (
/* ... */) /*!...*/inside string literals (SELECT '/*!50000 harmless*/' AS str)- Invalid or unknown version formats
Suggested implementations (non-exhaustive):
- Export ECM token type constant and ensure
Lexer.NextToken()emits it - Export
spliceGapsas a public API - Add parser AST node/flag marking ECM-originated nodes
Regex, string prefix, or raw text scanning are NOT acceptable as SQL security boundaries.
Minimal reproduction
Using mysql/parser from v0.0.0-20260728103305-d2f82de1b468:
package main
import (
"fmt"
myparser "github.com/bytebase/omni/mysql/parser"
)
func main() {
sqls := []string{
"/*!50000 DROP TABLE t*/ SELECT 1", // ECM with DDL
"/*!99999 SELECT 1*/", // ECM with SELECT
"SELECT /*!80100 42*/ FROM dual", // ECM with expression
"SELECT '/*!50000 harmless*/' AS str", // string literal
}
for _, sql := range sqls {
lex := myparser.NewLexer(sql)
fmt.Printf("SQL: %s\n", sql)
for {
tok := lex.NextToken()
if tok.Type == 0 { break }
// Is this token from an executable comment?
// Currently no public API to determine this.
fmt.Printf(" Token{Type=%d, Str=%q, Loc=%d, End=%d}\n",
tok.Type, tok.Str, tok.Loc, tok.End)
}
fmt.Println()
}
}
All ECM content tokens appear identical to normal SQL tokens.
Request
- Confirm whether the maintainers consider this in scope
- If accepted: commit to API stability and version compatibility guarantees for the exported ECM signal
- We are prepared to submit a minimal PR if the approach is approved
- The Spike evidence (0/12 ECM recognition via public API) is fully reproducible with the fixed version above
- Ngôn ngữ chính
- Go
- Star
- 20
- Fork
- 8
- Merge trung bình
- 6 giờ 39 phút
- Pull request đã merge (30 ngày)
- 390
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bytebase/omni
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của bytebase/omni
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Area/DeveloperPortal Aspect/UI Severity/Minor Type/Bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
wso2/api-platform#4369 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
keyxmakerx/Chronicle#2285 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
vLLM metrics adapter tests start the adapter twice and race on its request countersCó thể đã có người làm @bhargavchintam đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
llm-d/llm-d-inference-sim#933 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
spellshift/realm#2509 ·
Maintainer thường phản hồi trong vòng 1 ngày