Skip to content

Commit b488914

Browse files
Copilotdata-douser
andcommitted
Address review feedback: pin codeql/rust-all, fix queries, populate .expected files, add rust_ast.md resource
- Pin codeql/rust-all to 0.2.10 (not '*') matching other language conventions - Fix Rust CallGraph queries: use getName().getText() for string comparison (Rust's getName() returns Name object, not string like Swift's) - Populate all 5 .expected files with actual query test results - Generate codeql-pack.lock.yml for both src and test packs - Create server/src/resources/languages/rust_ast.md AST reference resource - Register Rust AST resource in language-types.ts - Add 'rust' to VSIX bundle-server.js LANGUAGES array - Change 'kotlin' to 'cobol' as invalid language in tests - Update language-resources tests for 9 AST resources (was 8) Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/936d5519-c2a3-418b-9d95-555823d3ea7e Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
1 parent b1b2aae commit b488914

File tree

26 files changed

+1221
-28
lines changed

26 files changed

+1221
-28
lines changed

extensions/vscode/scripts/bundle-server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const targetServerDir = join(extensionRoot, 'server');
2727
// Languages with tool query packs
2828
const LANGUAGES = [
2929
'actions', 'cpp', 'csharp', 'go', 'java',
30-
'javascript', 'python', 'ruby', 'swift',
30+
'javascript', 'python', 'ruby', 'rust', 'swift',
3131
];
3232

3333
// Clean previous bundle

server/dist/codeql-development-mcp-server.js

Lines changed: 7 additions & 0 deletions
Large diffs are not rendered by default.

server/dist/codeql-development-mcp-server.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/ql/rust/tools/src/CallGraphFrom/CallGraphFrom.ql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ string getSourceFunctionName() {
2222
*/
2323
string getCalleeName(CallExpr call) {
2424
if exists(call.getResolvedTarget().(Function).getName())
25-
then result = call.getResolvedTarget().(Function).getName()
25+
then result = call.getResolvedTarget().(Function).getName().getText()
2626
else result = call.toString()
2727
}
2828

2929
from CallExpr call, Function source
3030
where
3131
call.getEnclosingCallable() = source and
32-
source.getName() = getSourceFunctionName()
33-
select call, "Call from `" + source.getName() + "` to `" + getCalleeName(call) + "`"
32+
source.getName().getText() = getSourceFunctionName()
33+
select call,
34+
"Call from `" + source.getName().getText() + "` to `" + getCalleeName(call) + "`"

server/ql/rust/tools/src/CallGraphFromTo/CallGraphFromTo.ql

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ string getTargetFunctionName() {
3030
predicate calls(Function caller_, Function callee_) {
3131
exists(CallExpr c |
3232
c.getEnclosingCallable() = caller_ and
33-
c.getResolvedTarget().(Function).getName() = callee_.getName()
33+
c.getResolvedTarget().(Function).getName().getText() = callee_.getName().getText()
3434
)
3535
}
3636

@@ -39,20 +39,21 @@ predicate calls(Function caller_, Function callee_) {
3939
*/
4040
string getCalleeName(CallExpr call) {
4141
if exists(call.getResolvedTarget().(Function).getName())
42-
then result = call.getResolvedTarget().(Function).getName()
42+
then result = call.getResolvedTarget().(Function).getName().getText()
4343
else result = call.toString()
4444
}
4545

4646
from CallExpr call, Function caller
4747
where
4848
call.getEnclosingCallable() = caller and
4949
exists(Function source, Function target |
50-
source.getName() = getSourceFunctionName() and
51-
target.getName() = getTargetFunctionName() and
50+
source.getName().getText() = getSourceFunctionName() and
51+
target.getName().getText() = getTargetFunctionName() and
5252
calls*(source, caller) and
5353
exists(Function callee |
54-
call.getResolvedTarget().(Function).getName() = callee.getName() and
54+
call.getResolvedTarget().(Function).getName().getText() = callee.getName().getText() and
5555
calls*(callee, target)
5656
)
5757
)
58-
select call, "Reachable call from `" + caller.getName() + "` to `" + getCalleeName(call) + "`"
58+
select call,
59+
"Reachable call from `" + caller.getName().getText() + "` to `" + getCalleeName(call) + "`"

server/ql/rust/tools/src/CallGraphTo/CallGraphTo.ql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ string getTargetFunctionName() {
2222
*/
2323
string getCallerName(CallExpr call) {
2424
if exists(call.getEnclosingCallable().(Function).getName())
25-
then result = call.getEnclosingCallable().(Function).getName()
25+
then result = call.getEnclosingCallable().(Function).getName().getText()
2626
else result = "Top-level"
2727
}
2828

@@ -31,10 +31,11 @@ string getCallerName(CallExpr call) {
3131
*/
3232
string getCalleeName(CallExpr call) {
3333
if exists(call.getResolvedTarget().(Function).getName())
34-
then result = call.getResolvedTarget().(Function).getName()
34+
then result = call.getResolvedTarget().(Function).getName().getText()
3535
else result = call.toString()
3636
}
3737

3838
from CallExpr call
39-
where call.getResolvedTarget().(Function).getName() = getTargetFunctionName()
40-
select call, "Call to `" + getCalleeName(call) + "` from `" + getCallerName(call) + "`"
39+
where call.getResolvedTarget().(Function).getName().getText() = getTargetFunctionName()
40+
select call,
41+
"Call to `" + getCalleeName(call) + "` from `" + getCallerName(call) + "`"

server/ql/rust/tools/src/codeql-pack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ version: 2.25.1
33
description: 'Queries for codeql-development-mcp-server tools for rust language'
44
library: false
55
dependencies:
6-
codeql/rust-all: '*'
6+
codeql/rust-all: 0.2.10
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| Example1.rs:12:5:12:16 | unrelated1(...) | Call from `source_func` to `unrelated1` |
2+
| Example1.rs:13:5:13:16 | unrelated2(...) | Call from `source_func` to `unrelated2` |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
[workspace]
3+
[package]
4+
name = "test"
5+
version = "0.0.1"
6+
edition = "2021"
7+
[lib]
8+
path = "lib.rs"
9+
[dependencies]
10+
11+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod Example1;

0 commit comments

Comments
 (0)