-
Notifications
You must be signed in to change notification settings - Fork 2
Add support for rust language
#195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
866c9e7
Initial plan
Copilot 61de78b
Add Rust language support: query packs, TypeScript, scripts, docs, CI
Copilot 75e8810
Fix tests and add query documentation files for Rust
Copilot f57c7b9
Update remaining scripts, workflows, and skills for Rust support
Copilot b1b2aae
Plan for addressing review feedback
Copilot b488914
Address review feedback: pin codeql/rust-all, fix queries, populate .β¦
Copilot 7327a9a
Add client integration tests for codeql_query_run with Rust language
Copilot 51331e7
Fix mcp-prompt-e2e extension integration test
data-douser f70e16a
Fix reviewer comments: correct message pattern spacing in query docs,β¦
Copilot 9c2fb69
Sync server/dist/** after rebase
data-douser c3e1064
Fix MatchExpr and ForExpr accessor names in rust_ast.md resource
Copilot e2c4de6
Fix CallGraph queries to use resolved target entities instead of nameβ¦
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...tests/primitives/tools/codeql_query_run/rust_call_graph_from_example1/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # Integration Test: codeql_query_run/rust_call_graph_from_example1 | ||
|
|
||
| ## Purpose | ||
|
|
||
| Tests the `codeql_query_run` tool with the CallGraphFrom query for Rust language, demonstrating external predicates for source function selection and SARIF format interpretation for call graph visualization. | ||
|
|
||
| ## Test Scenario | ||
|
|
||
| This test validates that the `codeql_query_run` tool can: | ||
|
|
||
| 1. Accept `queryName` ("CallGraphFrom") and `queryLanguage` ("rust") parameters | ||
| 2. Accept `sourceFunction` parameter to specify which function's outbound calls to analyze | ||
| 3. Resolve the query path using `codeql resolve queries` to find the CallGraphFrom.ql query | ||
| 4. Automatically provide external predicates for the sourceFunction | ||
| 5. Execute the resolved query against a Rust test database with external predicate data | ||
| 6. Interpret the .bqrs results using native `codeql bqrs interpret --format=sarif-latest` | ||
| 7. Generate SARIF format output containing call graph results | ||
| 8. Return enhanced results confirming the interpretation succeeded | ||
|
|
||
| ## Required Inputs | ||
|
|
||
| The test requires the following inputs in `before/monitoring-state.json`: | ||
|
|
||
| - `queryName`: "CallGraphFrom" - Name of the query to resolve and execute | ||
| - `queryLanguage`: "rust" - Programming language for query resolution | ||
| - `database`: "server/ql/rust/tools/test/CallGraphFrom/CallGraphFrom.testproj" - Path to CodeQL test database | ||
| - `sourceFunction`: "source_func" - Source function name to analyze (used as external predicate) | ||
| - `output`: "query-results.bqrs" - Output file for binary query results | ||
| - `format`: "sarif-latest" - SARIF format for interpreting @kind problem query results | ||
| - `interpretedOutput`: "query-results.sarif" - Output file for SARIF format results | ||
| - `timeout`: 300000 - Timeout in milliseconds (5 minutes) | ||
|
|
||
| The test database is created by running `codeql test extract server/ql/rust/tools/test/CallGraphFrom`. | ||
|
|
||
| ## Expected Outputs | ||
|
|
||
| The test expects the following behavior: | ||
|
|
||
| - `monitoring-state.json`: Test execution state showing success | ||
| - The tool generates `query-results.bqrs` (binary query results, not committed to repo) | ||
| - The tool interprets results using `codeql bqrs interpret --format=sarif-latest` | ||
| - The SARIF output contains call graph entries showing calls from `source_func` to `unrelated1` and `unrelated2` | ||
| - The monitoring state confirms successful execution and interpretation | ||
|
|
||
| ## Expected Behavior | ||
|
|
||
| The tool should: | ||
|
|
||
| 1. Resolve "CallGraphFrom" to the absolute path of `server/ql/rust/tools/src/CallGraphFrom/CallGraphFrom.ql` | ||
| 2. Automatically add external predicate: `sourceFunction=source_func` | ||
| 3. Execute the query against the provided database with the external predicate data | ||
| 4. Generate query results in BQRS format | ||
| 5. Call `codeql bqrs interpret` with format=sarif-latest | ||
| 6. Generate SARIF output showing calls from the source function | ||
| 7. Return enhanced output confirming the interpretation succeeded | ||
|
|
||
| ## External Predicates Integration | ||
|
|
||
| This test demonstrates the integration between the MCP server's sourceFunction parameter and CodeQL's extensible predicates system. The CallGraphFrom query uses `extensible predicate sourceFunction(string name)` to receive the function name via data extensions, making it work with any Rust code database. | ||
|
|
||
| ## Format Parameter | ||
|
|
||
| This test uses the `format` parameter which leverages native CodeQL tooling (`codeql bqrs interpret`) to produce SARIF output based on query metadata. |
15 changes: 15 additions & 0 deletions
15
...imitives/tools/codeql_query_run/rust_call_graph_from_example1/after/monitoring-state.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "toolName": "codeql_query_run", | ||
| "parameters": { | ||
| "queryName": "CallGraphFrom", | ||
| "queryLanguage": "rust", | ||
| "database": "server/ql/rust/tools/test/CallGraphFrom/CallGraphFrom.testproj", | ||
| "sourceFunction": "source_func", | ||
| "output": "query-results.bqrs", | ||
| "format": "sarif-latest", | ||
| "interpretedOutput": "query-results.sarif", | ||
| "timeout": 300000 | ||
| }, | ||
| "success": true, | ||
| "description": "Successfully executed CallGraphFrom (@kind problem) query using query name resolution with external predicates and SARIF format interpretation for Rust language" | ||
| } |
15 changes: 15 additions & 0 deletions
15
...mitives/tools/codeql_query_run/rust_call_graph_from_example1/before/monitoring-state.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "toolName": "codeql_query_run", | ||
| "parameters": { | ||
| "queryName": "CallGraphFrom", | ||
| "queryLanguage": "rust", | ||
| "database": "server/ql/rust/tools/test/CallGraphFrom/CallGraphFrom.testproj", | ||
| "sourceFunction": "source_func", | ||
| "output": "query-results.bqrs", | ||
| "format": "sarif-latest", | ||
| "interpretedOutput": "query-results.sarif", | ||
| "timeout": 300000 | ||
| }, | ||
| "expectedSuccess": true, | ||
| "description": "Test codeql_query_run with queryName resolution for CallGraphFrom (@kind problem) query using external predicates and SARIF format interpretation for Rust language" | ||
| } |
62 changes: 62 additions & 0 deletions
62
...egration-tests/primitives/tools/codeql_query_run/rust_tools_print_ast/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Integration Test: codeql_query_run/rust_tools_print_ast | ||
|
|
||
| ## Purpose | ||
|
|
||
| Tests the `codeql_query_run` tool with the PrintAST query for Rust language, demonstrating external predicates for source file selection and graphtext format interpretation for AST visualization. | ||
|
|
||
| ## Test Scenario | ||
|
|
||
| This test validates that the `codeql_query_run` tool can: | ||
|
|
||
| 1. Accept `queryName` ("PrintAST") and `queryLanguage` ("rust") parameters | ||
| 2. Accept `sourceFiles` parameter to specify which source files to analyze | ||
| 3. Resolve the query path using `codeql resolve queries` to find the PrintAST.ql query | ||
| 4. Automatically provide external predicates for the selectedSourceFiles | ||
| 5. Execute the resolved query against a Rust test database with external predicate data | ||
| 6. Interpret the .bqrs results using native `codeql bqrs interpret -t kind=graph -t id=rust/tools/print-ast --format=graphtext` | ||
| 7. Generate graphtext format output representing the AST graph structure | ||
| 8. Return enhanced results confirming the interpretation succeeded | ||
|
|
||
| ## Required Inputs | ||
|
|
||
| The test requires the following inputs in `before/monitoring-state.json`: | ||
|
|
||
| - `queryName`: "PrintAST" - Name of the query to resolve and execute | ||
| - `queryLanguage`: "rust" - Programming language for query resolution | ||
| - `database`: "server/ql/rust/tools/test/PrintAST/PrintAST.testproj" - Path to CodeQL test database | ||
| - `sourceFiles`: "server/ql/rust/tools/test/PrintAST/Example1.rs" - Source file(s) to analyze (used as external predicate) | ||
| - `output`: "query-results.bqrs" - Output file for binary query results | ||
| - `format`: "graphtext" - Native CodeQL format for interpreting @kind graph query results | ||
| - `interpretedOutput`: "query-results" - Output directory for graphtext format results | ||
|
|
||
| The test database should be pre-created at `server/ql/rust/tools/test/PrintAST/PrintAST.testproj` by running `codeql test extract server/ql/rust/tools/test/PrintAST`. | ||
|
|
||
| ## Expected Outputs | ||
|
|
||
| The test expects the following behavior: | ||
|
|
||
| - `monitoring-state.json`: Test execution state showing success | ||
| - The tool generates `query-results.bqrs` (binary query results, not committed to repo) | ||
| - The tool interprets results using `codeql bqrs interpret -t kind=graph -t id=rust/tools/print-ast --format=graphtext` | ||
| - The interpreted output is written to a directory structure at `query-results/` | ||
| - The monitoring state confirms successful execution and interpretation | ||
|
|
||
| ## Expected Behavior | ||
|
|
||
| The tool should: | ||
|
|
||
| 1. Resolve "PrintAST" to the absolute path of `server/ql/rust/tools/src/PrintAST/PrintAST.ql` | ||
| 2. Automatically add external predicate: `selectedSourceFiles=Example1.rs` | ||
| 3. Execute the query against the provided database with the external predicate data | ||
| 4. Generate query results in BQRS format | ||
| 5. Call `codeql bqrs interpret` with format=graphtext and appropriate metadata (-t kind=graph -t id=rust/tools/print-ast) | ||
| 6. Generate graphtext format output showing the AST structure for the selected Rust source file | ||
| 7. Return enhanced output confirming the interpretation succeeded | ||
|
|
||
| ## External Predicates Integration | ||
|
|
||
| This test demonstrates the integration between the MCP server's sourceFiles parameter and CodeQL's extensible predicates system. The PrintAST query uses `extensible predicate selectedSourceFiles(string path)` to receive file paths via data extensions, making it work with any Rust code database rather than being limited to test directories. | ||
|
|
||
| ## Format Parameter | ||
|
|
||
| This test uses the `format` parameter which leverages native CodeQL tooling (`codeql bqrs interpret`) to produce properly formatted output based on query metadata, rather than custom post-processing. |
14 changes: 14 additions & 0 deletions
14
...-tests/primitives/tools/codeql_query_run/rust_tools_print_ast/after/monitoring-state.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "toolName": "codeql_query_run", | ||
| "parameters": { | ||
| "queryName": "PrintAST", | ||
| "queryLanguage": "rust", | ||
| "database": "server/ql/rust/tools/test/PrintAST/PrintAST.testproj", | ||
| "sourceFiles": "server/ql/rust/tools/test/PrintAST/Example1.rs", | ||
| "output": "query-results.bqrs", | ||
| "format": "graphtext", | ||
| "interpretedOutput": "query-results" | ||
| }, | ||
| "success": true, | ||
| "description": "Successfully executed PrintAST query using query name resolution with external predicates and graphtext format interpretation for Rust language" | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.