github / github/codeql

[Rust] Get type of expression

未關閉
#20,501 7 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
question Rust
主要語言
CodeQL
星號
10.1k
分支
2.1k
平均合併
2 天 15 小時
30 天內合併 PR
141

描述

**Description of the issue**

How do I get the type of an expression in Rust?

For example, I want to constrain this to only accesses on string-like expressions.
```ql
private class IndexExprOnNonConstantString extends IndexExpr {
IndexExprOnNonConstantString() { not this.getBase() instanceof StringLiteralExpr }
}
```

**Actual**: No `getType` predicate on expr.
**Expected**: Predicate to get type of expr.

When will support be added for an - in my understanding - very basic feature?
Or is there a workaround/internal API?

貢獻指南

開啟貢獻指南

研究方向

首先檢視 Rust CodeQL expression model 和現有的 Expr predicates,以範例中的 getBase() 和 StringLiteralExpr 作為最初的切入點。確認是否存在內部 type API 或 workaround;當 expression type 可以被查詢到足以約束所示的 index-expression class 時,即視為完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
rust
領域
devtools, security
Issue 類型
功能
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。