codeql-development-mcp-server 2.25.0 → 2.25.1-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/codeql-development-mcp-server.js +138160 -7960
  2. package/dist/codeql-development-mcp-server.js.map +4 -4
  3. package/package.json +4 -3
  4. package/ql/README.md +1 -0
  5. package/ql/actions/tools/src/codeql-pack.lock.yml +14 -14
  6. package/ql/actions/tools/src/codeql-pack.yml +2 -2
  7. package/ql/cpp/tools/src/codeql-pack.lock.yml +12 -12
  8. package/ql/cpp/tools/src/codeql-pack.yml +2 -2
  9. package/ql/csharp/tools/src/codeql-pack.lock.yml +10 -10
  10. package/ql/csharp/tools/src/codeql-pack.yml +2 -2
  11. package/ql/go/tools/src/codeql-pack.lock.yml +10 -10
  12. package/ql/go/tools/src/codeql-pack.yml +2 -2
  13. package/ql/java/tools/src/codeql-pack.lock.yml +14 -14
  14. package/ql/java/tools/src/codeql-pack.yml +2 -2
  15. package/ql/javascript/tools/src/codeql-pack.lock.yml +13 -13
  16. package/ql/javascript/tools/src/codeql-pack.yml +2 -2
  17. package/ql/python/tools/src/codeql-pack.lock.yml +13 -13
  18. package/ql/python/tools/src/codeql-pack.yml +2 -2
  19. package/ql/ruby/tools/src/codeql-pack.lock.yml +10 -10
  20. package/ql/ruby/tools/src/codeql-pack.yml +2 -2
  21. package/ql/rust/tools/src/CallGraphFrom/CallGraphFrom.md +48 -0
  22. package/ql/rust/tools/src/CallGraphFrom/CallGraphFrom.ql +38 -0
  23. package/ql/rust/tools/src/CallGraphFromTo/CallGraphFromTo.md +48 -0
  24. package/ql/rust/tools/src/CallGraphFromTo/CallGraphFromTo.ql +69 -0
  25. package/ql/rust/tools/src/CallGraphTo/CallGraphTo.md +47 -0
  26. package/ql/rust/tools/src/CallGraphTo/CallGraphTo.ql +47 -0
  27. package/ql/rust/tools/src/ExternalPredicates.qll +14 -0
  28. package/ql/rust/tools/src/PrintAST/PrintAST.md +59 -0
  29. package/ql/rust/tools/src/PrintAST/PrintAST.ql +46 -0
  30. package/ql/rust/tools/src/PrintCFG/PrintCFG.md +56 -0
  31. package/ql/rust/tools/src/PrintCFG/PrintCFG.ql +58 -0
  32. package/ql/rust/tools/src/codeql-pack.lock.yml +28 -0
  33. package/ql/rust/tools/src/codeql-pack.yml +6 -0
  34. package/ql/swift/tools/src/codeql-pack.lock.yml +10 -10
  35. package/ql/swift/tools/src/codeql-pack.yml +2 -2
  36. package/scripts/setup-packs.sh +2 -2
@@ -0,0 +1,47 @@
1
+ # CallGraphTo for Rust
2
+
3
+ Displays calls made to a specified function, showing the call graph inbound to the target function.
4
+
5
+ ## Overview
6
+
7
+ This query identifies all call sites that invoke a named function, producing an inbound call graph. Given a target function name, it reports each call site and the enclosing caller, which is useful for understanding how a function is used throughout the codebase.
8
+
9
+ The query accepts function names via an external predicate (`targetFunction`).
10
+
11
+ ## Use Cases
12
+
13
+ This query is primarily used for:
14
+
15
+ - Finding all callers of a specific function
16
+ - Understanding how a function is used across modules
17
+ - Impact analysis when modifying or deprecating a function
18
+
19
+ ## Example
20
+
21
+ The following Rust code demonstrates inbound calls to `target_func`:
22
+
23
+ ```rust
24
+ fn target_func() {} // Target function for analysis
25
+
26
+ fn caller1() {
27
+ target_func();
28
+ }
29
+
30
+ fn caller2() {
31
+ target_func();
32
+ }
33
+ ```
34
+
35
+ Running with `targetFunction = "target_func"` produces results showing each call site with the message pattern ``Call to `target_func` from `caller1` ``.
36
+
37
+ ## Output Format
38
+
39
+ The query is a `@kind problem` query producing rows of:
40
+
41
+ - ``select call, "Call to `callee` from `caller`"``
42
+
43
+ ## References
44
+
45
+ - [Rust Functions](https://doc.rust-lang.org/book/ch03-03-how-functions-work.html)
46
+ - [CodeQL Call Graph Analysis](https://codeql.github.com/docs/writing-codeql-queries/about-data-flow-analysis/)
47
+ - [CodeQL Library for Rust](https://codeql.github.com/docs/codeql-language-guides/codeql-library-for-rust/)
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @name Call Graph To for rust
3
+ * @description Displays calls made to a specified function, showing the call graph inbound to the target function.
4
+ * @id rust/tools/call-graph-to
5
+ * @kind problem
6
+ * @problem.severity recommendation
7
+ * @tags call-graph
8
+ */
9
+
10
+ import rust
11
+ import ExternalPredicates
12
+
13
+ /**
14
+ * Gets a single target function name from the comma-separated list.
15
+ */
16
+ string getTargetFunctionName() {
17
+ exists(string s | targetFunction(s) | result = s.splitAt(",").trim())
18
+ }
19
+
20
+ /**
21
+ * Gets a function by matching against the selected target function names.
22
+ */
23
+ Function getTargetFunction() { result.getName().getText() = getTargetFunctionName() }
24
+
25
+ /**
26
+ * Gets the caller name for a call expression.
27
+ */
28
+ string getCallerName(CallExpr call) {
29
+ if exists(call.getEnclosingCallable().(Function).getName())
30
+ then result = call.getEnclosingCallable().(Function).getName().getText()
31
+ else result = "Top-level"
32
+ }
33
+
34
+ /**
35
+ * Gets the name of the called function.
36
+ */
37
+ string getCalleeName(CallExpr call) {
38
+ if exists(call.getResolvedTarget().(Function).getName())
39
+ then result = call.getResolvedTarget().(Function).getName().getText()
40
+ else result = call.toString()
41
+ }
42
+
43
+ from CallExpr call, Function target
44
+ where
45
+ target = getTargetFunction() and
46
+ call.getResolvedTarget() = target
47
+ select call, "Call to `" + getCalleeName(call) + "` from `" + getCallerName(call) + "`"
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Shared extensible predicate declarations for MCP server tools queries.
3
+ * Values are provided via dataExtensions YAML files during testing,
4
+ * or via a temporary data extension pack at runtime from the MCP server.
5
+ */
6
+
7
+ /** Holds for each source function name for call graph analysis. */
8
+ extensible predicate sourceFunction(string name);
9
+
10
+ /** Holds for each target function name for call graph analysis. */
11
+ extensible predicate targetFunction(string name);
12
+
13
+ /** Holds for each selected source file path for AST/CFG printing. */
14
+ extensible predicate selectedSourceFiles(string path);
@@ -0,0 +1,59 @@
1
+ # Print AST for Rust
2
+
3
+ Outputs a representation of the Abstract Syntax Tree (AST) for specified source files.
4
+
5
+ ## Overview
6
+
7
+ The Abstract Syntax Tree is a hierarchical representation of source code structure. Each node represents a syntactic construct (declaration, statement, expression, etc.) and edges represent parent-child containment relationships.
8
+
9
+ This query produces the full AST for specified Rust source files, which is useful for understanding code structure, inspecting how the CodeQL extractor parses modules and functions, and debugging query logic that operates on AST nodes.
10
+
11
+ ## Use Cases
12
+
13
+ This query is primarily used for:
14
+
15
+ - Inspecting how CodeQL represents Rust functions, structs, and expressions
16
+ - Debugging queries that match on AST node types
17
+ - Understanding parent-child relationships between items and statements
18
+ - Verifying extractor behavior for ownership, borrowing, and pattern matching
19
+ - IDE integration for syntax tree visualization
20
+
21
+ ## Example
22
+
23
+ The following Rust code demonstrates AST structure through function declarations and control flow:
24
+
25
+ ```rust
26
+ struct Greeter {
27
+ name: String,
28
+ }
29
+
30
+ impl Greeter {
31
+ fn greet(&self) {
32
+ println!("Hello, {}!", self.name);
33
+ }
34
+ }
35
+
36
+ fn main() {
37
+ let g = Greeter { name: "World".to_string() };
38
+ g.greet();
39
+ }
40
+ ```
41
+
42
+ In the resulting AST:
43
+
44
+ - The module contains struct and function declarations as children
45
+ - Each function body contains a block expression with statement nodes
46
+ - Call expressions reference their target and arguments as child nodes
47
+
48
+ ## Output Format
49
+
50
+ The query produces a graph via the parameterized `PrintAst` library module:
51
+
52
+ - `nodes`: Each AST node with its type, label, and properties
53
+ - `edges`: Parent-child relationships forming the syntax tree
54
+
55
+ ## References
56
+
57
+ - [The Rust Reference](https://doc.rust-lang.org/reference/)
58
+ - [CodeQL Abstract Syntax Trees](https://codeql.github.com/docs/writing-codeql-queries/abstract-syntax-tree/)
59
+ - [CodeQL Library for Rust](https://codeql.github.com/docs/codeql-language-guides/codeql-library-for-rust/)
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @name Print AST for rust
3
+ * @description Outputs a representation of the Abstract Syntax Tree for specified source files.
4
+ * @id rust/tools/print-ast
5
+ * @kind graph
6
+ * @tags ast
7
+ */
8
+
9
+ import rust
10
+ private import codeql.rust.printast.PrintAst
11
+ import ExternalPredicates
12
+
13
+ /**
14
+ * Gets a single source file from the comma-separated list.
15
+ */
16
+ string getSelectedSourceFile() {
17
+ exists(string s | selectedSourceFiles(s) | result = s.splitAt(",").trim())
18
+ }
19
+
20
+ /**
21
+ * Gets a file by matching against the selected source file paths.
22
+ */
23
+ File getSelectedFile() {
24
+ exists(string selectedFile |
25
+ selectedFile = getSelectedSourceFile() and
26
+ (
27
+ // Match by exact relative path from source root
28
+ result.getRelativePath() = selectedFile
29
+ or
30
+ // Match by file name if no path separators
31
+ not selectedFile.matches("%/%") and result.getBaseName() = selectedFile
32
+ or
33
+ // Match by ending path component
34
+ result.getAbsolutePath().suffix(result.getAbsolutePath().length() - selectedFile.length()) =
35
+ selectedFile
36
+ )
37
+ )
38
+ }
39
+
40
+ /**
41
+ * Holds if a locatable element should be printed in the AST output.
42
+ * Restricts output to elements from the selected file.
43
+ */
44
+ predicate shouldPrint(Locatable e) { e.getLocation().getFile() = getSelectedFile() }
45
+
46
+ import PrintAst<shouldPrint/1>
@@ -0,0 +1,56 @@
1
+ # Print CFG for Rust
2
+
3
+ Produces a representation of a file's Control Flow Graph (CFG) for specified source files.
4
+
5
+ ## Overview
6
+
7
+ The Control Flow Graph models the runtime execution order of statements and expressions within functions. Nodes represent individual executable elements and edges represent possible transitions between them, including branches, loops, and exceptional control flow.
8
+
9
+ This query produces the CFG for specified Rust source files, which is useful for understanding execution paths, identifying dead code, and debugging data flow queries that depend on control flow ordering.
10
+
11
+ ## Use Cases
12
+
13
+ This query is primarily used for:
14
+
15
+ - Visualizing execution paths through Rust functions
16
+ - Understanding how `if`, `match`, `loop`, `while`, and `for` affect control flow
17
+ - Debugging data flow queries that depend on CFG structure
18
+ - Identifying unreachable code or unexpected control flow edges
19
+ - Verifying CFG behavior for Rust-specific constructs like pattern matching
20
+
21
+ ## Example
22
+
23
+ The following Rust code demonstrates control flow through branching and loops:
24
+
25
+ ```rust
26
+ fn example(x: i32) -> i32 {
27
+ if x > 0 {
28
+ return x;
29
+ }
30
+
31
+ let mut val = x;
32
+ while val < 10 {
33
+ val += 1;
34
+ }
35
+ val
36
+ }
37
+ ```
38
+
39
+ In the resulting CFG:
40
+
41
+ - The `if` condition creates a branch with two successors
42
+ - The early `return` creates an edge to the function exit
43
+ - The `while` loop creates a back-edge from the loop body to the condition
44
+
45
+ ## Output Format
46
+
47
+ The query produces a graph with:
48
+
49
+ - `nodes`: Each CFG node with a `semmle.label` property
50
+ - `edges`: Control flow transitions between nodes
51
+
52
+ ## References
53
+
54
+ - [The Rust Reference - Expressions](https://doc.rust-lang.org/reference/expressions.html)
55
+ - [CodeQL Control Flow Analysis](https://codeql.github.com/docs/writing-codeql-queries/about-data-flow-analysis/)
56
+ - [CodeQL Library for Rust](https://codeql.github.com/docs/codeql-language-guides/codeql-library-for-rust/)
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @name Print CFG for rust
3
+ * @description Produces a representation of a file's Control Flow Graph for specified source files.
4
+ * @id rust/tools/print-cfg
5
+ * @kind graph
6
+ * @tags cfg
7
+ */
8
+
9
+ import rust
10
+ import codeql.rust.controlflow.ControlFlowGraph
11
+ import ExternalPredicates
12
+
13
+ /**
14
+ * Gets a single source file from the comma-separated list.
15
+ */
16
+ string getSelectedSourceFile() {
17
+ exists(string s | selectedSourceFiles(s) | result = s.splitAt(",").trim())
18
+ }
19
+
20
+ /**
21
+ * Gets a file by matching against the selected source file paths.
22
+ */
23
+ File getSelectedFile() {
24
+ exists(string selectedFile |
25
+ selectedFile = getSelectedSourceFile() and
26
+ (
27
+ // Match by exact relative path from source root
28
+ result.getRelativePath() = selectedFile
29
+ or
30
+ // Match by file name if no path separators
31
+ not selectedFile.matches("%/%") and result.getBaseName() = selectedFile
32
+ or
33
+ // Match by ending path component
34
+ result.getAbsolutePath().suffix(result.getAbsolutePath().length() - selectedFile.length()) =
35
+ selectedFile
36
+ )
37
+ )
38
+ }
39
+
40
+ /**
41
+ * Holds if this CFG node should be included in output.
42
+ */
43
+ predicate shouldPrintNode(CfgNode node) { node.getLocation().getFile() = getSelectedFile() }
44
+
45
+ /**
46
+ * Configuration for PrintCFG that outputs filtered CFG nodes and edges.
47
+ */
48
+ query predicate nodes(CfgNode node, string property, string value) {
49
+ shouldPrintNode(node) and
50
+ property = "semmle.label" and
51
+ value = node.toString()
52
+ }
53
+
54
+ query predicate edges(CfgNode pred, CfgNode succ) {
55
+ shouldPrintNode(pred) and
56
+ shouldPrintNode(succ) and
57
+ pred.getASuccessor() = succ
58
+ }
@@ -0,0 +1,28 @@
1
+ ---
2
+ lockVersion: 1.0.0
3
+ dependencies:
4
+ codeql/concepts:
5
+ version: 0.0.20
6
+ codeql/controlflow:
7
+ version: 2.0.30
8
+ codeql/dataflow:
9
+ version: 2.1.2
10
+ codeql/mad:
11
+ version: 1.0.46
12
+ codeql/regex:
13
+ version: 1.0.46
14
+ codeql/rust-all:
15
+ version: 0.2.10
16
+ codeql/ssa:
17
+ version: 2.0.22
18
+ codeql/threat-models:
19
+ version: 1.0.46
20
+ codeql/tutorial:
21
+ version: 1.0.46
22
+ codeql/typeinference:
23
+ version: 0.0.27
24
+ codeql/typetracking:
25
+ version: 2.0.30
26
+ codeql/util:
27
+ version: 2.0.33
28
+ compiled: false
@@ -0,0 +1,6 @@
1
+ name: advanced-security/ql-mcp-rust-tools-src
2
+ version: 2.25.1-next.2
3
+ description: 'Queries for codeql-development-mcp-server tools for rust language'
4
+ library: false
5
+ dependencies:
6
+ codeql/rust-all: 0.2.10
@@ -2,23 +2,23 @@
2
2
  lockVersion: 1.0.0
3
3
  dependencies:
4
4
  codeql/concepts:
5
- version: 0.0.18
5
+ version: 0.0.20
6
6
  codeql/controlflow:
7
- version: 2.0.28
7
+ version: 2.0.30
8
8
  codeql/dataflow:
9
- version: 2.1.0
9
+ version: 2.1.2
10
10
  codeql/mad:
11
- version: 1.0.44
11
+ version: 1.0.46
12
12
  codeql/regex:
13
- version: 1.0.44
13
+ version: 1.0.46
14
14
  codeql/ssa:
15
- version: 2.0.20
15
+ version: 2.0.22
16
16
  codeql/swift-all:
17
- version: 6.3.0
17
+ version: 6.3.2
18
18
  codeql/tutorial:
19
- version: 1.0.44
19
+ version: 1.0.46
20
20
  codeql/typetracking:
21
- version: 2.0.28
21
+ version: 2.0.30
22
22
  codeql/util:
23
- version: 2.0.31
23
+ version: 2.0.33
24
24
  compiled: false
@@ -1,6 +1,6 @@
1
1
  name: advanced-security/ql-mcp-swift-tools-src
2
- version: 2.25.0
2
+ version: 2.25.1-next.2
3
3
  description: 'Queries for codeql-development-mcp-server tools for swift language'
4
4
  library: false
5
5
  dependencies:
6
- codeql/swift-all: 6.3.0
6
+ codeql/swift-all: 6.3.2
@@ -31,7 +31,7 @@ Install CodeQL pack dependencies for bundled tool query packs.
31
31
 
32
32
  OPTIONS:
33
33
  --language <lang> Install packs only for the specified language
34
- Valid values: actions, cpp, csharp, go, java, javascript, python, ruby, swift
34
+ Valid values: actions, cpp, csharp, go, java, javascript, python, ruby, rust, swift
35
35
  -h, --help Show this help message
36
36
 
37
37
  By default, installs pack dependencies for all supported languages.
@@ -62,7 +62,7 @@ while [[ $# -gt 0 ]]; do
62
62
  done
63
63
 
64
64
  ## Validate language if provided
65
- VALID_LANGUAGES=("actions" "cpp" "csharp" "go" "java" "javascript" "python" "ruby" "swift")
65
+ VALID_LANGUAGES=("actions" "cpp" "csharp" "go" "java" "javascript" "python" "ruby" "rust" "swift")
66
66
  if [ -n "${LANGUAGE}" ]; then
67
67
  LANGUAGE_VALID=false
68
68
  for valid_lang in "${VALID_LANGUAGES[@]}"; do