codeql-development-mcp-server 2.24.2-rc1 → 2.24.2-rc3
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.
- package/package.json +1 -1
- package/ql/actions/tools/src/PrintAST/PrintAST.md +53 -0
- package/ql/actions/tools/src/PrintCFG/PrintCFG.md +3 -3
- package/ql/actions/tools/src/codeql-pack.yml +1 -1
- package/ql/cpp/tools/src/CallGraphFrom/CallGraphFrom.md +45 -0
- package/ql/cpp/tools/src/CallGraphTo/CallGraphTo.md +42 -0
- package/ql/cpp/tools/src/PrintAST/PrintAST.md +58 -0
- package/ql/cpp/tools/src/PrintCFG/PrintCFG.md +2 -2
- package/ql/cpp/tools/src/codeql-pack.yml +1 -1
- package/ql/csharp/tools/src/CallGraphFrom/CallGraphFrom.md +45 -0
- package/ql/csharp/tools/src/CallGraphTo/CallGraphTo.md +42 -0
- package/ql/csharp/tools/src/PrintAST/PrintAST.md +56 -0
- package/ql/csharp/tools/src/PrintCFG/PrintCFG.md +2 -2
- package/ql/csharp/tools/src/codeql-pack.yml +1 -1
- package/ql/go/tools/src/CallGraphFrom/CallGraphFrom.md +45 -0
- package/ql/go/tools/src/CallGraphTo/CallGraphTo.md +42 -0
- package/ql/go/tools/src/PrintAST/PrintAST.md +55 -0
- package/ql/go/tools/src/PrintCFG/PrintCFG.md +2 -2
- package/ql/go/tools/src/codeql-pack.yml +1 -1
- package/ql/java/tools/src/CallGraphFrom/CallGraphFrom.md +45 -0
- package/ql/java/tools/src/CallGraphTo/CallGraphTo.md +42 -0
- package/ql/java/tools/src/PrintAST/PrintAST.md +54 -0
- package/ql/java/tools/src/PrintCFG/PrintCFG.md +2 -2
- package/ql/java/tools/src/codeql-pack.yml +1 -1
- package/ql/javascript/tools/src/CallGraphFrom/CallGraphFrom.md +48 -0
- package/ql/javascript/tools/src/CallGraphTo/CallGraphTo.md +46 -0
- package/ql/javascript/tools/src/PrintAST/PrintAST.md +58 -0
- package/ql/javascript/tools/src/PrintCFG/PrintCFG.md +2 -2
- package/ql/javascript/tools/src/codeql-pack.yml +1 -1
- package/ql/python/tools/src/CallGraphFrom/CallGraphFrom.md +47 -0
- package/ql/python/tools/src/CallGraphTo/CallGraphTo.md +46 -0
- package/ql/python/tools/src/PrintAST/PrintAST.md +53 -0
- package/ql/python/tools/src/PrintCFG/PrintCFG.md +2 -2
- package/ql/python/tools/src/codeql-pack.yml +1 -1
- package/ql/ruby/tools/src/CallGraphFrom/CallGraphFrom.md +49 -0
- package/ql/ruby/tools/src/CallGraphTo/CallGraphTo.md +48 -0
- package/ql/ruby/tools/src/PrintAST/PrintAST.md +56 -0
- package/ql/ruby/tools/src/PrintCFG/PrintCFG.md +2 -2
- package/ql/ruby/tools/src/codeql-pack.yml +1 -1
- package/ql/swift/tools/src/CallGraphFrom/CallGraphFrom.md +45 -0
- package/ql/swift/tools/src/CallGraphTo/CallGraphTo.md +42 -0
- package/ql/swift/tools/src/PrintAST/PrintAST.md +54 -0
- package/ql/swift/tools/src/PrintCFG/PrintCFG.md +55 -0
- package/ql/swift/tools/src/codeql-pack.yml +1 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# CallGraphFrom for Swift
|
|
2
|
+
|
|
3
|
+
Displays calls made from a specified function, showing the call graph outbound from the source function.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This query identifies all function calls made within the body of a named function, producing an outbound call graph. Given a source function name, it reports each call site and the callee, which is useful for understanding function dependencies and call chains.
|
|
8
|
+
|
|
9
|
+
The query accepts function names via an external predicate (`sourceFunction`).
|
|
10
|
+
|
|
11
|
+
## Use Cases
|
|
12
|
+
|
|
13
|
+
This query is primarily used for:
|
|
14
|
+
|
|
15
|
+
- Mapping outbound dependencies of a specific function
|
|
16
|
+
- Understanding what a function calls and in what order
|
|
17
|
+
- Analyzing call chains for refactoring or security review
|
|
18
|
+
- IDE integration for call hierarchy navigation
|
|
19
|
+
|
|
20
|
+
## Example
|
|
21
|
+
|
|
22
|
+
The following Swift code demonstrates outbound calls from `sourceFunc`:
|
|
23
|
+
|
|
24
|
+
```swift
|
|
25
|
+
func helper1() {}
|
|
26
|
+
func helper2() { helper1() }
|
|
27
|
+
|
|
28
|
+
func sourceFunc() { // Source function for analysis
|
|
29
|
+
helper1()
|
|
30
|
+
helper2()
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Running with `sourceFunction = "sourceFunc"` produces results showing each call site with the message pattern `Call from 'sourceFunc' to 'helper1'`.
|
|
35
|
+
|
|
36
|
+
## Output Format
|
|
37
|
+
|
|
38
|
+
The query is a `@kind problem` query producing rows of:
|
|
39
|
+
|
|
40
|
+
- `select call, "Call from 'source' to 'callee'"`
|
|
41
|
+
|
|
42
|
+
## References
|
|
43
|
+
|
|
44
|
+
- [Swift Functions](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/functions/)
|
|
45
|
+
- [CodeQL Call Graph Analysis](https://codeql.github.com/docs/writing-codeql-queries/about-data-flow-analysis/)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# CallGraphTo for Swift
|
|
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 caller and call location, which is useful for understanding how a function is used across 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
|
+
- Impact analysis before modifying a function signature
|
|
17
|
+
- Understanding usage patterns and entry points
|
|
18
|
+
- IDE integration for call hierarchy navigation
|
|
19
|
+
|
|
20
|
+
## Example
|
|
21
|
+
|
|
22
|
+
The following Swift code demonstrates inbound calls to `targetFunc`:
|
|
23
|
+
|
|
24
|
+
```swift
|
|
25
|
+
func targetFunc() {} // Target function for analysis
|
|
26
|
+
|
|
27
|
+
func caller1() { targetFunc() }
|
|
28
|
+
func caller2() { targetFunc() }
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Running with `targetFunction = "targetFunc"` produces results showing each call site with the message pattern `Call to 'targetFunc' from 'caller1'`.
|
|
32
|
+
|
|
33
|
+
## Output Format
|
|
34
|
+
|
|
35
|
+
The query is a `@kind problem` query producing rows of:
|
|
36
|
+
|
|
37
|
+
- `select call, "Call to 'target' from 'caller'"`
|
|
38
|
+
|
|
39
|
+
## References
|
|
40
|
+
|
|
41
|
+
- [Swift Functions](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/functions/)
|
|
42
|
+
- [CodeQL Call Graph Analysis](https://codeql.github.com/docs/writing-codeql-queries/about-data-flow-analysis/)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Print AST for Swift
|
|
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 Swift source files, which is useful for understanding code structure, inspecting how the CodeQL extractor parses types 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 Swift structs, classes, and functions
|
|
16
|
+
- Debugging queries that match on AST node types
|
|
17
|
+
- Understanding parent-child relationships between declarations and expressions
|
|
18
|
+
- Verifying extractor behavior for closures, optionals, and protocol conformances
|
|
19
|
+
- IDE integration for syntax tree visualization
|
|
20
|
+
|
|
21
|
+
## Example
|
|
22
|
+
|
|
23
|
+
The following Swift code demonstrates AST structure through struct and function declarations:
|
|
24
|
+
|
|
25
|
+
```swift
|
|
26
|
+
struct Example {
|
|
27
|
+
let name: String
|
|
28
|
+
|
|
29
|
+
func greet() { // Function declaration in AST
|
|
30
|
+
print("Hello, \(name)!")
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let e = Example(name: "World") // Initializer call in AST
|
|
35
|
+
e.greet()
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
In the resulting AST:
|
|
39
|
+
|
|
40
|
+
- The struct declaration contains property and function declarations as children
|
|
41
|
+
- Each function body contains a brace statement with expression nodes
|
|
42
|
+
- Call expressions and string interpolations reference their components as child nodes
|
|
43
|
+
|
|
44
|
+
## Output Format
|
|
45
|
+
|
|
46
|
+
The query produces a graph via the `PrintAstConfiguration` library:
|
|
47
|
+
|
|
48
|
+
- `nodes`: Each AST node with its type, label, and properties
|
|
49
|
+
- `edges`: Parent-child relationships forming the syntax tree
|
|
50
|
+
|
|
51
|
+
## References
|
|
52
|
+
|
|
53
|
+
- [Swift Language Guide](https://docs.swift.org/swift-book/)
|
|
54
|
+
- [CodeQL Abstract Syntax Trees](https://codeql.github.com/docs/writing-codeql-queries/abstract-syntax-tree/)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Print CFG for Swift
|
|
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 represents the order in which statements and expressions are executed in a program. Each node in the graph represents a control-flow element (statement or expression), and edges represent possible execution paths between them.
|
|
8
|
+
|
|
9
|
+
This query outputs all CFG nodes and their successor relationships for Swift code, which is useful for understanding program execution flow, debugging control flow issues, and analyzing code paths.
|
|
10
|
+
|
|
11
|
+
## Use Cases
|
|
12
|
+
|
|
13
|
+
This query is primarily used for:
|
|
14
|
+
|
|
15
|
+
- Visualizing program execution flow
|
|
16
|
+
- Understanding complex branching logic
|
|
17
|
+
- Debugging control flow issues
|
|
18
|
+
- Analysis of code paths and reachability
|
|
19
|
+
- IDE integration for control flow visualization
|
|
20
|
+
|
|
21
|
+
## Example
|
|
22
|
+
|
|
23
|
+
The following Swift code demonstrates control flow through conditional statements and loops:
|
|
24
|
+
|
|
25
|
+
```swift
|
|
26
|
+
func example(x: Int) {
|
|
27
|
+
if x > 0 { // Branching creates CFG edges
|
|
28
|
+
print("Positive")
|
|
29
|
+
} else {
|
|
30
|
+
print("Non-positive")
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
for i in 0..<3 { // Loop creates cyclic CFG
|
|
34
|
+
print(i)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
In the resulting CFG:
|
|
40
|
+
|
|
41
|
+
- The `if` condition creates two outgoing edges (true/false branches)
|
|
42
|
+
- The `for-in` loop creates a cycle back to the iterator
|
|
43
|
+
- Each statement connects to its successor in execution order
|
|
44
|
+
|
|
45
|
+
## Output Format
|
|
46
|
+
|
|
47
|
+
The query produces two relations:
|
|
48
|
+
|
|
49
|
+
- `nodes(ControlFlowNode, string, string)`: Each CFG node with its label
|
|
50
|
+
- `edges(ControlFlowNode, ControlFlowNode)`: Successor relationships between nodes
|
|
51
|
+
|
|
52
|
+
## References
|
|
53
|
+
|
|
54
|
+
- [Swift Control Flow](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/controlflow/)
|
|
55
|
+
- [CodeQL Control Flow Graph](https://codeql.github.com/docs/writing-codeql-queries/about-control-flow-in-codeql/)
|