Skip to content

Commit a9669d7

Browse files
authored
Merge branch 'main' into dd/bug-fixes/1
2 parents 5e06cd6 + fdc42c5 commit a9669d7

File tree

85 files changed

+2729
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+2729
-45
lines changed

.github/skills/create-codeql-query-development-workshop/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ Include appropriate CodeQL libraries in `codeql-pack.yml`:
398398
- **JavaScript/TypeScript**: `codeql/javascript-all`
399399
- **Python**: `codeql/python-all`
400400
- **Ruby**: `codeql/ruby-all`
401+
- **Rust**: `codeql/rust-all`
401402

402403
### Java-Specific API Notes
403404

.github/skills/upgrade-codeql-cli-and-packs/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Use the `codeql_pack_ls` MCP tool to see what pack versions are installed:
113113
For each `codeql/*-all` pack, verify it was built for a compatible CLI version by checking the `cliVersion` field in its `qlpack.yml`:
114114

115115
```bash
116-
for lang in actions cpp csharp go java javascript python ruby swift; do
116+
for lang in actions cpp csharp go java javascript python ruby rust swift; do
117117
version=$(ls ~/.codeql/packages/codeql/${lang}-all/ | head -1)
118118
echo "$lang-all@$version: $(cat ~/.codeql/packages/codeql/${lang}-all/$version/qlpack.yml | grep cliVersion)"
119119
done

.github/skills/upgrade-codeql-cli-and-packs/verify-pack-compatibility.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ find_extractor_dir() {
5151
}
5252

5353
## Languages to check
54-
LANGUAGES=("actions" "cpp" "csharp" "go" "java" "javascript" "python" "ruby" "swift")
54+
LANGUAGES=("actions" "cpp" "csharp" "go" "java" "javascript" "python" "ruby" "rust" "swift")
5555

5656
## Track overall status
5757
ALL_COMPATIBLE=true

.github/skills/validate-ql-mcp-server-tools-queries/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ The tools queries are available for all CodeQL-supported languages:
3333
| javascript | `server/ql/javascript/tools/` | `.js` |
3434
| python | `server/ql/python/tools/` | `.py` |
3535
| ruby | `server/ql/ruby/tools/` | `.rb` |
36+
| rust | `server/ql/rust/tools/` | `.rs` |
3637
| swift | `server/ql/swift/tools/` | `.swift` |
3738

3839
## Tools Queries Overview

.github/workflows/query-unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
strategy:
4343
fail-fast: false
4444
matrix:
45-
language: ['actions', 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby']
45+
language: ['actions', 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'rust']
4646

4747
steps:
4848
- name: Query Unit Tests - ${{ matrix.language }} - Checkout repository

.github/workflows/release-codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8383
run: |
8484
RELEASE_NAME="${{ steps.version.outputs.release_name }}"
85-
LANGUAGES="actions cpp csharp go java javascript python ruby swift"
85+
LANGUAGES="actions cpp csharp go java javascript python ruby rust swift"
8686
8787
# Prerelease versions (containing a hyphen) require --allow-prerelease
8888
PRERELEASE_FLAG=""
@@ -110,7 +110,7 @@ jobs:
110110
- name: CodeQL - Bundle CodeQL tool query packs
111111
run: |
112112
mkdir -p dist-packs
113-
LANGUAGES="actions cpp csharp go java javascript python ruby swift"
113+
LANGUAGES="actions cpp csharp go java javascript python ruby rust swift"
114114
echo "Bundling CodeQL tool query packs..."
115115
for lang in ${LANGUAGES}; do
116116
PACK_DIR="server/ql/${lang}/tools/src"
@@ -148,6 +148,6 @@ jobs:
148148
echo "### Published CodeQL Packs" >> $GITHUB_STEP_SUMMARY
149149
echo "| Pack | Version |" >> $GITHUB_STEP_SUMMARY
150150
echo "| ---- | ------- |" >> $GITHUB_STEP_SUMMARY
151-
for lang in actions cpp csharp go java javascript python ruby swift; do
151+
for lang in actions cpp csharp go java javascript python ruby rust swift; do
152152
echo "| \`advanced-security/ql-mcp-${lang}-tools-src\` | ${RELEASE_NAME} |" >> $GITHUB_STEP_SUMMARY
153153
done

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,6 @@ jobs:
279279
echo "### Published CodeQL Packs" >> $GITHUB_STEP_SUMMARY
280280
echo "| Pack | Version |" >> $GITHUB_STEP_SUMMARY
281281
echo "| ---- | ------- |" >> $GITHUB_STEP_SUMMARY
282-
for lang in actions cpp csharp go java javascript python ruby swift; do
282+
for lang in actions cpp csharp go java javascript python ruby rust swift; do
283283
echo "| \`advanced-security/ql-mcp-${lang}-tools-src\` | ${RELEASE_NAME} |" >> $GITHUB_STEP_SUMMARY
284284
done

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
*.actual
44
*.expected
55
*.log
6+
*.ql
7+
*.qll
68
*.qlref
79
*.testproj/
810
options
@@ -17,6 +19,8 @@ extensions/vscode/test/fixtures/
1719
node_modules
1820
query-results*
1921
server/dist/
22+
server/ql/*/tools/src/*.md
23+
server/ql/*/tools/src/**/*.md
2024
server/ql/*/tools/test/*
2125
workshops/
2226

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Integration Test: codeql_query_run/rust_call_graph_from_example1
2+
3+
## Purpose
4+
5+
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.
6+
7+
## Test Scenario
8+
9+
This test validates that the `codeql_query_run` tool can:
10+
11+
1. Accept `queryName` ("CallGraphFrom") and `queryLanguage` ("rust") parameters
12+
2. Accept `sourceFunction` parameter to specify which function's outbound calls to analyze
13+
3. Resolve the query path using `codeql resolve queries` to find the CallGraphFrom.ql query
14+
4. Automatically provide external predicates for the sourceFunction
15+
5. Execute the resolved query against a Rust test database with external predicate data
16+
6. Interpret the .bqrs results using native `codeql bqrs interpret --format=sarif-latest`
17+
7. Generate SARIF format output containing call graph results
18+
8. Return enhanced results confirming the interpretation succeeded
19+
20+
## Required Inputs
21+
22+
The test requires the following inputs in `before/monitoring-state.json`:
23+
24+
- `queryName`: "CallGraphFrom" - Name of the query to resolve and execute
25+
- `queryLanguage`: "rust" - Programming language for query resolution
26+
- `database`: "server/ql/rust/tools/test/CallGraphFrom/CallGraphFrom.testproj" - Path to CodeQL test database
27+
- `sourceFunction`: "source_func" - Source function name to analyze (used as external predicate)
28+
- `output`: "query-results.bqrs" - Output file for binary query results
29+
- `format`: "sarif-latest" - SARIF format for interpreting @kind problem query results
30+
- `interpretedOutput`: "query-results.sarif" - Output file for SARIF format results
31+
- `timeout`: 300000 - Timeout in milliseconds (5 minutes)
32+
33+
The test database is created by running `codeql test extract server/ql/rust/tools/test/CallGraphFrom`.
34+
35+
## Expected Outputs
36+
37+
The test expects the following behavior:
38+
39+
- `monitoring-state.json`: Test execution state showing success
40+
- The tool generates `query-results.bqrs` (binary query results, not committed to repo)
41+
- The tool interprets results using `codeql bqrs interpret --format=sarif-latest`
42+
- The SARIF output contains call graph entries showing calls from `source_func` to `unrelated1` and `unrelated2`
43+
- The monitoring state confirms successful execution and interpretation
44+
45+
## Expected Behavior
46+
47+
The tool should:
48+
49+
1. Resolve "CallGraphFrom" to the absolute path of `server/ql/rust/tools/src/CallGraphFrom/CallGraphFrom.ql`
50+
2. Automatically add external predicate: `sourceFunction=source_func`
51+
3. Execute the query against the provided database with the external predicate data
52+
4. Generate query results in BQRS format
53+
5. Call `codeql bqrs interpret` with format=sarif-latest
54+
6. Generate SARIF output showing calls from the source function
55+
7. Return enhanced output confirming the interpretation succeeded
56+
57+
## External Predicates Integration
58+
59+
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.
60+
61+
## Format Parameter
62+
63+
This test uses the `format` parameter which leverages native CodeQL tooling (`codeql bqrs interpret`) to produce SARIF output based on query metadata.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"toolName": "codeql_query_run",
3+
"parameters": {
4+
"queryName": "CallGraphFrom",
5+
"queryLanguage": "rust",
6+
"database": "server/ql/rust/tools/test/CallGraphFrom/CallGraphFrom.testproj",
7+
"sourceFunction": "source_func",
8+
"output": "query-results.bqrs",
9+
"format": "sarif-latest",
10+
"interpretedOutput": "query-results.sarif",
11+
"timeout": 300000
12+
},
13+
"success": true,
14+
"description": "Successfully executed CallGraphFrom (@kind problem) query using query name resolution with external predicates and SARIF format interpretation for Rust language"
15+
}

0 commit comments

Comments
 (0)