Add AlertSuppression.ql for Rust (inline // codeql[...] suppression)
まだ誰も着手していません。
評価
調査の方向性
python/ql/src/AlertSuppression.ql にある提案されたパターンから始め、次に shared/util/codeql/util/suppression/AlertSuppression.qll と Rust の Comment.qll および AstNode.qll ファイルを読んでください。rust/ql/src/AlertSuppression.ql を追加し、// codeql[...] と // lgtm[...] のコメントが Rust のアラート抑制を生成することを、rust/ql/src/qlpack.yml を変更せずに確認してください。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- CodeQL
- スター
- 10.1k
- フォーク
- 2.1k
- 平均マージ
- 2日 11時間
- マージ済み PR(30日)
- 129
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/codeql のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
C#: cs/simplifiable-boolean-expression false positive on Nullable<bool> compared with a literal オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
false-positive
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
false-positive
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
AXERA-TECH/ax-llm#75 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
gitbutlerapp/gitbutler#15998 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
sympozium-ai/sympozium#627 ·
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
TheManticoreProject/Manticore#1383 ·
-
auth bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100