Add AlertSuppression.ql for Rust (inline // codeql[...] suppression)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu với mẫu được đề xuất trong python/ql/src/AlertSuppression.ql, sau đó đọc shared/util/codeql/util/suppression/AlertSuppression.qll cùng các tệp Rust Comment.qll và AstNode.qll. Thêm rust/ql/src/AlertSuppression.ql và xác nhận rằng các chú thích // codeql[...] và // lgtm[...] tạo ra các suppression cảnh báo Rust mà không thay đổi rust/ql/src/qlpack.yml.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description of the issue
Rust is missing an AlertSuppression.ql query, which means // codeql[...] and // lgtm[...] inline suppression comments have no effect on Rust code scanning alerts. Every other supported language (C++, C#, Go, Java, JavaScript, Python, Ruby, Swift) has this query.
All the building blocks already exist in the Rust CodeQL library:
- Shared suppression module:
shared/util/codeql/util/suppression/AlertSuppression.qll— requiresAstNode(withhasLocationInfo) andSingleLineComment(withhasLocationInfo,getText,toString) - Rust
Commentclass:rust/ql/lib/codeql/rust/elements/Comment.qll— already hasgetText()(raw text including//),getCommentText()(stripped),hasLocationInfo(inherited fromAstNode/Token), andtoString - Rust
AstNode:rust/ql/lib/codeql/rust/elements/AstNode.qll
Proposed implementation
A new file at rust/ql/src/AlertSuppression.ql, following the same pattern as python/ql/src/AlertSuppression.ql:
/**
* @name Alert suppression
* @description Generates information about alert suppressions.
* @kind alert-suppression
* @id rust/alert-suppression
*/
private import codeql.util.suppression.AlertSuppression as AS
private import codeql.rust.elements.Comment as C
private import codeql.rust.elements.AstNode as A
class AstNode instanceof A::AstNode {
predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
super.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
string toString() { result = super.toString() }
}
class SingleLineComment instanceof C::Comment {
SingleLineComment() {
// Only match single-line comments (// ...), not block comments (/* ... */)
super.getText().matches("//%")
}
predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
super.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
string getText() { result = super.getText() }
string toString() { result = super.toString() }
}
import AS::Make<AstNode, SingleLineComment>
The qlpack.yml at rust/ql/src/qlpack.yml already depends on codeql/util, so no dependency changes are needed.
Motivation
Without this, there is no way to suppress false positives inline for Rust. The only workaround is dismissing alerts via the GitHub API or UI, which doesn't persist reliably across code changes.
- Ngôn ngữ chính
- CodeQL
- Star
- 10.1k
- Fork
- 2.1k
- Merge trung bình
- 2 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 129
Hướng dẫn đóng góp
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 github/codeql
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
C#: cs/simplifiable-boolean-expression false positive on Nullable<bool> compared with a literal Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
false-positive
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
false-positive
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
Tất cả issue của github/codeql
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
TheManticoreProject/Manticore#1383 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
dotnet/arcade-skills#51 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
ethereum-optimism/factory#64 ·
-
Cookie sessions never expire Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
zitadel/zitadel-go#628 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
phoenixframework/phoenix#6847 ·