Conversation
rust language
data-douser
left a comment
There was a problem hiding this comment.
@copilot Good start, lots to do. In addition to addressing my other comments, you should think about useful client integration tests and/or extension integration tests to properly cover rust language support and identify potential gaps in ql-mcp server primitives. For example, once you can actually get valid / non-empty results from the rust tools query for PrintAST, then you should be able to populate, register, and test the servability of a new server/src/resources/languages/rust_ast.md resource.
Created For client/extension integration tests — this would be a good follow-up once the base PR is merged, to test the full round-trip of |
@copilot I asked for client integration tests to cover |
Added two client integration tests for
Both tests follow the existing patterns from |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
Adds first-class Rust language support to the CodeQL Development MCP Server by introducing a Rust tools query pack (PrintAST/PrintCFG/CallGraph*), registering a Rust AST reference resource, and wiring Rust into language lists across server, packaging, CI, and integration tests.
Changes:
- Add Rust tools query pack + query unit tests (
server/ql/rust/tools/{src,test}/**). - Register Rust as a supported language across server prompts/tooling and add Rust AST documentation resource.
- Extend release/CI/scripts and add client integration tests validating Rust PrintAST and CallGraphFrom execution.
Reviewed changes
Copilot reviewed 80 out of 84 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| server/test/src/resources/language-resources.test.ts | Updates resource test expectations to include Rust AST resource. |
| server/test/src/prompts/workflow-prompts.test.ts | Updates language-count and invalid-language tests for new Rust support. |
| server/src/types/language-types.ts | Registers Rust AST resource content in LANGUAGE_RESOURCES. |
| server/src/resources/server-overview.md | Adds rust to supported languages list in server overview resource. |
| server/src/resources/languages/rust_ast.md | Adds Rust AST reference resource content. |
| server/src/prompts/workflow-prompts.ts | Adds rust to SUPPORTED_LANGUAGES. |
| server/src/prompts/tools-query-workflow.prompt.md | Adds rust to supported languages in prompt text. |
| server/src/prompts/explain-codeql-query.prompt.md | Adds rust to the prompt’s supported language list. |
| server/src/prompts/document-codeql-query.prompt.md | Adds rust to the prompt’s supported language list. |
| server/src/lib/query-file-finder.ts | Adds .rs extension mapping for Rust. |
| server/src/lib/cli-tool-registry.ts | Updates supported-language error message to include Rust. |
| server/scripts/upgrade-packs.sh | Adds Rust to supported languages and help text. |
| server/scripts/update-release-version.sh | Adds Rust to pack release version update language list. |
| server/scripts/setup-packs.sh | Adds Rust to supported languages and help text. |
| server/scripts/run-query-unit-tests.sh | Adds Rust to supported languages and help text. |
| server/scripts/install-packs.sh | Installs Rust tool packs and adds Rust to supported languages. |
| server/scripts/extract-test-databases.sh | Adds Rust to supported languages and help text. |
| server/ql/rust/tools/test/ext/print-ast.model.yml | Test data extension for selectedSourceFiles. |
| server/ql/rust/tools/test/ext/call-graph-to.model.yml | Test data extension for targetFunction. |
| server/ql/rust/tools/test/ext/call-graph-from.model.yml | Test data extension for sourceFunction. |
| server/ql/rust/tools/test/ext/call-graph-from-to.model.yml | Test data extensions for sourceFunction + targetFunction. |
| server/ql/rust/tools/test/codeql-pack.yml | Rust tools test pack definition. |
| server/ql/rust/tools/test/codeql-pack.lock.yml | Locked dependencies for Rust tools test pack. |
| server/ql/rust/tools/test/PrintCFG/lib.rs | Rust extractor test module entrypoint for PrintCFG tests. |
| server/ql/rust/tools/test/PrintCFG/PrintCFG.qlref | Test qlref pointing to PrintCFG query. |
| server/ql/rust/tools/test/PrintCFG/PrintCFG.expected | Expected output for PrintCFG unit test. |
| server/ql/rust/tools/test/PrintCFG/Example1.rs | Rust sample code for PrintCFG unit test. |
| server/ql/rust/tools/test/PrintCFG/Cargo.toml | Cargo workspace for PrintCFG test extraction. |
| server/ql/rust/tools/test/PrintAST/lib.rs | Rust extractor test module entrypoint for PrintAST tests. |
| server/ql/rust/tools/test/PrintAST/PrintAST.qlref | Test qlref pointing to PrintAST query. |
| server/ql/rust/tools/test/PrintAST/PrintAST.expected | Expected output for PrintAST unit test. |
| server/ql/rust/tools/test/PrintAST/Example1.rs | Rust sample code for PrintAST unit test. |
| server/ql/rust/tools/test/PrintAST/Cargo.toml | Cargo workspace for PrintAST test extraction. |
| server/ql/rust/tools/test/PrintAST/Cargo.lock | Cargo lockfile for PrintAST test workspace. |
| server/ql/rust/tools/test/CallGraphTo/lib.rs | Rust extractor test module entrypoint for CallGraphTo tests. |
| server/ql/rust/tools/test/CallGraphTo/Example1.rs | Rust sample code for CallGraphTo unit test. |
| server/ql/rust/tools/test/CallGraphTo/Cargo.toml | Cargo workspace for CallGraphTo test extraction. |
| server/ql/rust/tools/test/CallGraphTo/CallGraphTo.qlref | Test qlref pointing to CallGraphTo query. |
| server/ql/rust/tools/test/CallGraphTo/CallGraphTo.expected | Expected output for CallGraphTo unit test. |
| server/ql/rust/tools/test/CallGraphFromTo/lib.rs | Rust extractor test module entrypoint for CallGraphFromTo tests. |
| server/ql/rust/tools/test/CallGraphFromTo/Example1.rs | Rust sample code for CallGraphFromTo unit test. |
| server/ql/rust/tools/test/CallGraphFromTo/Cargo.toml | Cargo workspace for CallGraphFromTo test extraction. |
| server/ql/rust/tools/test/CallGraphFromTo/CallGraphFromTo.qlref | Test qlref pointing to CallGraphFromTo query. |
| server/ql/rust/tools/test/CallGraphFromTo/CallGraphFromTo.expected | Expected output for CallGraphFromTo unit test. |
| server/ql/rust/tools/test/CallGraphFrom/lib.rs | Rust extractor test module entrypoint for CallGraphFrom tests. |
| server/ql/rust/tools/test/CallGraphFrom/Example1.rs | Rust sample code for CallGraphFrom unit test. |
| server/ql/rust/tools/test/CallGraphFrom/Cargo.toml | Cargo workspace for CallGraphFrom test extraction. |
| server/ql/rust/tools/test/CallGraphFrom/Cargo.lock | Cargo lockfile for CallGraphFrom test workspace. |
| server/ql/rust/tools/test/CallGraphFrom/CallGraphFrom.qlref | Test qlref pointing to CallGraphFrom query. |
| server/ql/rust/tools/test/CallGraphFrom/CallGraphFrom.expected | Expected output for CallGraphFrom unit test. |
| server/ql/rust/tools/src/codeql-pack.yml | Rust tools source pack definition with rust-all dependency. |
| server/ql/rust/tools/src/codeql-pack.lock.yml | Locked dependencies for Rust tools source pack. |
| server/ql/rust/tools/src/PrintCFG/PrintCFG.ql | Rust PrintCFG tool query implementation. |
| server/ql/rust/tools/src/PrintCFG/PrintCFG.md | Documentation for Rust PrintCFG tool query. |
| server/ql/rust/tools/src/PrintAST/PrintAST.ql | Rust PrintAST tool query implementation (parameterized PrintAst). |
| server/ql/rust/tools/src/PrintAST/PrintAST.md | Documentation for Rust PrintAST tool query. |
| server/ql/rust/tools/src/ExternalPredicates.qll | Declares extensible predicates used by Rust tool queries. |
| server/ql/rust/tools/src/CallGraphTo/CallGraphTo.ql | Rust CallGraphTo tool query implementation. |
| server/ql/rust/tools/src/CallGraphTo/CallGraphTo.md | Documentation for Rust CallGraphTo tool query. |
| server/ql/rust/tools/src/CallGraphFromTo/CallGraphFromTo.ql | Rust CallGraphFromTo tool query implementation. |
| server/ql/rust/tools/src/CallGraphFromTo/CallGraphFromTo.md | Documentation for Rust CallGraphFromTo tool query. |
| server/ql/rust/tools/src/CallGraphFrom/CallGraphFrom.ql | Rust CallGraphFrom tool query implementation. |
| server/ql/rust/tools/src/CallGraphFrom/CallGraphFrom.md | Documentation for Rust CallGraphFrom tool query. |
| server/ql/README.md | Adds Rust to the supported server/ql language directories list. |
| server/package.json | Ensures Rust tools source pack is included in published server package files. |
| server/dist/codeql-development-mcp-server.js | Updates built server bundle to include Rust changes. |
| extensions/vscode/test/suite/mcp-prompt-e2e.integration.test.ts | Adjusts invalid-language test case to use cobol now that Rust is valid. |
| extensions/vscode/scripts/bundle-server.js | Includes Rust in VSIX bundling languages list. |
| docs/public.md | Adds Rust tools pack entry to public docs table. |
| client/integration-tests/primitives/tools/codeql_query_run/rust_tools_print_ast/before/monitoring-state.json | Adds Rust PrintAST integration test inputs. |
| client/integration-tests/primitives/tools/codeql_query_run/rust_tools_print_ast/after/query-results/rust/tools/print-ast.txt | Adds expected interpreted graphtext output for Rust PrintAST. |
| client/integration-tests/primitives/tools/codeql_query_run/rust_tools_print_ast/after/monitoring-state.json | Adds Rust PrintAST integration test expected outcome. |
| client/integration-tests/primitives/tools/codeql_query_run/rust_tools_print_ast/README.md | Documents the Rust PrintAST integration test scenario. |
| client/integration-tests/primitives/tools/codeql_query_run/rust_call_graph_from_example1/before/monitoring-state.json | Adds Rust CallGraphFrom integration test inputs. |
| client/integration-tests/primitives/tools/codeql_query_run/rust_call_graph_from_example1/after/monitoring-state.json | Adds Rust CallGraphFrom integration test expected outcome. |
| client/integration-tests/primitives/tools/codeql_query_run/rust_call_graph_from_example1/README.md | Documents the Rust CallGraphFrom integration test scenario. |
| .github/workflows/release.yml | Includes Rust tools pack in release summary publishing list. |
| .github/workflows/release-codeql.yml | Includes Rust in CodeQL pack publishing/bundling steps. |
| .github/workflows/query-unit-tests.yml | Adds Rust to the query unit test matrix. |
| .github/skills/validate-ql-mcp-server-tools-queries/SKILL.md | Adds Rust row to tools-queries skill documentation. |
| .github/skills/upgrade-codeql-cli-and-packs/verify-pack-compatibility.sh | Adds Rust to compatibility verification languages list. |
| .github/skills/upgrade-codeql-cli-and-packs/SKILL.md | Updates documentation snippet to include Rust. |
| .github/skills/create-codeql-query-development-workshop/SKILL.md | Adds codeql/rust-all to workshop language library notes. |
client/integration-tests/primitives/tools/codeql_query_run/rust_tools_print_ast/README.md
Outdated
Show resolved
Hide resolved
.../integration-tests/primitives/tools/codeql_query_run/rust_call_graph_from_example1/README.md
Outdated
Show resolved
Hide resolved
|
@copilot apply changes based on the comments in this thread. In addition, be sure to enforce consistent CodeQL formatting by running |
Applied all changes from the review thread in 5f0c5e0:
|
- rust_tools_print_ast: Tests PrintAST query with graphtext format interpretation, including expected graphtext output for AST visualization - rust_call_graph_from_example1: Tests CallGraphFrom query with SARIF format interpretation and external predicates for source function selection Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/ee9dfe2b-a152-4a44-88b9-6e9c2b7bc831 Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
… use extensible predicate wording in integration test READMEs, apply codeql query format to all .ql/.qll files, add *.ql and *.qll to .prettierignore Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/b3ea9842-0497-431d-86d2-800c5fd46faa Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
5f0c5e0 to
9c2fb69
Compare
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/d79c8230-94c3-42ee-8ee7-ec65be88d8e9 Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Fixed both accessor names in
|
|
Resolves #194. |
|
@copilot apply changes based on the comments in this thread. Be sure to enforce consistent CodeQL formatting by running |
…-based matching Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/8ce53ee0-dea8-4a8f-b300-436d11463003 Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Applied all changes from the review thread and ran
|
📝 Primitive Information
Primitive Details
PrintAST,PrintCFG,CallGraphFrom,CallGraphTo,CallGraphFromTo✅ ALLOWED FILES:
server/src/**/*.ts)server/src/tools/*.ts)server/test/**/*.ts)README.md, server docs)server/src/types/*.ts)server/src/lib/*.ts)package.json,tsconfig.json).github/workflows/*.yml)server/scripts/*.sh)extensions/vscode/scripts/bundle-server.js)client/integration-tests/**).github/skills/**).prettierignore)🚫 FORBIDDEN FILES:
🛑 MANDATORY PR VALIDATION CHECKLIST
Primitive Metadata
codeql_query_runtool withqueryLanguage: 'rust'🎯 Functionality Description
What This Primitive Does
Adds first-class Rust support to the MCP server, enabling all standard tool queries (AST printing, CFG visualization, call graph analysis) for Rust codebases, plus a new
rust_ast.mdlanguage resource. This brings the total supported languages to 10.Key Rust-specific implementation details:
PrintAst<shouldPrint/1>module (unlike Swift/Ruby which use class-basedPrintAstConfiguration)getSourceFunction()/getTargetFunction()resolvers that returnFunctionentities, withgetEnclosingCallable()→CallableandgetResolvedTarget()for entity comparison (avoiding name-based matching to correctly handle Rust's function name overloading across modules/impl blocks). UsesgetName().getText()only for display strings (Rust'sgetName()returns aNameobject, not a string)CfgNodefromcodeql.rust.controlflow.ControlFlowGraphserver/src/resources/languages/rust_ast.md) provides a comprehensive reference of CodeQL AST classes for Rust, registered ascodeql://languages/rust/ast. Documents correct accessor predicates verified against actual PrintAST output (e.g.,MatchExpr.getScrutinee(),ForExpr.getLoopBody())sourceFunction,targetFunction,selectedSourceFiles) are declared inExternalPredicates.qlland populated via data extension YAML files at runtimeUse Cases
AI assistants can now:
Example Usage
Example Input/Output
🧪 Implementation Details
Files Added/Modified
New query pack (32+ files):
server/ql/rust/tools/src/codeql-pack.yml— pack config withcodeql/rust-all: 0.2.10(pinned)server/ql/rust/tools/src/codeql-pack.lock.yml— generated lock fileserver/ql/rust/tools/src/ExternalPredicates.qll— shared extensible predicatesserver/ql/rust/tools/src/{PrintAST,PrintCFG,CallGraphFrom,CallGraphTo,CallGraphFromTo}/*.ql— 5 tool queries (formatted withcodeql query format -i), using entity-based resolution viagetSourceFunction()/getTargetFunction()resolvers andgetResolvedTarget()entity comparison for call graph edgesserver/ql/rust/tools/src/{PrintAST,PrintCFG,CallGraphFrom,CallGraphTo,CallGraphFromTo}/*.md— 5 query docs with correct double-backtick escaping for message patternsserver/ql/rust/tools/test/codeql-pack.yml+codeql-pack.lock.yml— test pack config and lock fileserver/ql/rust/tools/test/— test pack with.qlref,Example1.rs,.expected(non-empty, verified),Cargo.toml,lib.rs, andext/*.model.ymlfilesTypeScript (4 files):
server/src/prompts/workflow-prompts.ts— add'rust'toSUPPORTED_LANGUAGESserver/src/lib/query-file-finder.ts— addrust: 'rs'toLANGUAGE_EXTENSIONSserver/src/lib/cli-tool-registry.ts— update error message stringsserver/src/types/language-types.ts— register Rust AST resourceNew Resource:
server/src/resources/languages/rust_ast.md— comprehensive Rust AST class reference for CodeQL query development, with accessor predicates verified against actual PrintAST output (e.g.,MatchExpr.getScrutinee()notgetExpr(),ForExpr.getLoopBody()notgetBody())Scripts (6 files):
install-packs.sh,extract-test-databases.sh,run-query-unit-tests.sh—VALID_LANGUAGES+ help textsetup-packs.sh,upgrade-packs.sh,update-release-version.sh—VALID_LANGUAGES/LANGUAGESConfig/Docs/Skills/CI (13 files):
server/package.json— addql/rust/tools/src/tofilesextensions/vscode/scripts/bundle-server.js— add'rust'to VSIXLANGUAGESarraydocs/public.md,server/ql/README.md,server-overview.md, 3 prompt.mdfilesverify-pack-compatibility.shquery-unit-tests.yml,release.yml,release-codeql.ymlClient Integration Tests (7 files):
client/integration-tests/primitives/tools/codeql_query_run/rust_tools_print_ast/— PrintAST integration test with graphtext format, including expected AST output (502 lines)client/integration-tests/primitives/tools/codeql_query_run/rust_call_graph_from_example1/— CallGraphFrom integration test with SARIF format and extensible predicatesTests (2 files):
server/test/src/prompts/workflow-prompts.test.ts— expect 10 languages, use'cobol'as invalid languageserver/test/src/resources/language-resources.test.ts— expect 9 AST resources (was 8), 17 total resources (was 16), verify'RUST AST Reference'registeredFormatting & Tooling (1 file):
.prettierignore— add*.ql,*.qll, andserver/ql/*/tools/src/*.md/server/ql/*/tools/src/**/*.mdto prevent prettier from overriding CodeQL formatting or mangling double-backtick patterns in query documentationArchitecture Integration
SUPPORTED_LANGUAGES+LANGUAGE_EXTENSIONSpatternSUPPORTED_LANGUAGESconst array provides compile-time safety'rust'fromSUPPORTED_LANGUAGESDesign Patterns
getSourceFunction()/getTargetFunction()resolversExternalPredicates.qllcodeql/rust-all: 0.2.10(pinned version)shouldPrint/shouldPrintNodepredicates.qland.qllfiles formatted withcodeql query format -i;.prettierignoreupdated to prevent prettier from overriding CodeQL formattinggetResolvedTarget()) instead of name-based string matching to correctly handle Rust's function name overloading across modules and impl blocks📋 Testing Coverage
Unit Tests
SUPPORTED_LANGUAGESlength test updated (9 → 10)'cobol'(never supported).mdfiles)Test Scenarios
SUPPORTED_LANGUAGEShas 10 entries'rust'is in the supported list'cobol'(not supported) is rejected.qlfile has a matching.mdfile.expectedresults'RUST AST Reference'is registered atcodeql://languages/rust/astcodeql_query_runwithqueryName: "PrintAST"andqueryLanguage: "rust"produces graphtext outputcodeql_query_runwithqueryName: "CallGraphFrom"andqueryLanguage: "rust"produces SARIF output with call graph entriesTest Files
server/test/src/prompts/workflow-prompts.test.ts(updated)server/test/src/resources/language-resources.test.ts(updated)server/ql/rust/tools/test/— 5 test directories with.qlref,Example1.rs,.expected(non-empty),Cargo.toml,lib.rs, andext/*.model.ymlclient/integration-tests/primitives/tools/codeql_query_run/rust_tools_print_ast/— PrintAST client integration testclient/integration-tests/primitives/tools/codeql_query_run/rust_call_graph_from_example1/— CallGraphFrom client integration testQuery Unit Test Results
All 5 Rust query unit tests pass with verified non-empty expected results:
source_functounrelated1andunrelated2target_funcfromcaller1andcaller2sourcethroughintermediatetotarget🔗 References
Related Implementation
server/ql/swift/tools/) — primary reference implementation for entity-based function resolution patternserver/ql/go/tools/) — custom PrintAST referenceclient/integration-tests/primitives/tools/codeql_query_run/javascript_tools_print_ast/) — pattern for Rust PrintAST client testclient/integration-tests/primitives/tools/codeql_query_run/cpp_call_graph_from_example1/) — pattern for Rust CallGraphFrom client testExternal References
codeql_query_runtoolcodeql.rust.printast.PrintAst(parameterized module pattern)Validation Materials
getSourceFunction()/getTargetFunction()resolvers andgetResolvedTarget().(Function)entity comparison to avoid false matches from function name overloading (Rust'sgetName()returns aNameobject, requiring.getText()for display strings only)🚀 Server Integration
Registration Details
Rust is auto-registered by adding to existing arrays — no new
server.tool()calls needed:Compatibility
codeql/rust-all: 0.2.10(pinned version, resolved at pack install time)Performance Considerations
🔍 Quality Assurance
Code Quality
.ql/.qllfiles formatted withcodeql query format -iand excluded from Prettier via.prettierignore.mdfiles for all 5 queries +rust_ast.mdresource with verified accessor predicate namesValidation Testing
Security Considerations
👥 Review Guidelines
For Reviewers
Please verify:
codeql query formatrust_ast.mduses verified accessor namesTesting Instructions
Manual Validation Steps
📊 Impact Analysis
Server Impact
codeql_query_runwithqueryLanguage: 'rust'; new resource atcodeql://languages/rust/astcodeql/rust-all: 0.2.10)AI Assistant Benefits
Monitoring & Reporting Integration
Maintenance Considerations
.qlref+.expectedstructure with non-empty verified results; client integration tests with monitoring-state.json before/after patternrust_ast.mdresource with verified predicate names + updated skills/promptscodeql/rust-all: 0.2.10pinned to latest compatible version🔄 Deployment Considerations
Rollout Strategy
'rust'from arrays to disableMigration Notes
No special migration steps required. All query unit tests have been verified with non-empty expected results. The
codeql-pack.lock.ymlfiles are already generated and committed. CallGraph queries use entity-based resolution consistent with the Swift implementation pattern.