Develop comprehensive FindRelatedPrimitives.ql tool queries for each supported language to discover CodeQL classes, predicates, and types relevant to a source code location.
Query Output Schema
| primitiveType | primitiveName | definitionFile | definitionLine | relevanceScore |
Implementation Design
-
Query Structure (server/ql/{lang}/tools/src/FindRelatedPrimitives/)
FindRelatedPrimitives.ql: Main entry point query
- Parameterized by:
file, startLine, endLine, startColumn, endColumn
-
Primitive Discovery Logic
- AST Types: Find CodeQL classes that match AST nodes at location
- Type Predicates: Discover
getType(), getAQualifiedName() accessors
- Dataflow Nodes: Map to
DataFlow::Node subtypes when applicable
- Taint Sources/Sinks: Identify if location matches known sources/sinks
- Control Flow: Find relevant
ControlFlowNode and BasicBlock types
-
Relevance Scoring
- Direct AST match: score 100
- Parent/child AST types: score 75
- Related dataflow concepts: score 50
- Tangentially related types: score 25
-
Per-Language Implementation
Required for: actions, cpp, csharp, go, java, javascript, python, ruby, swift
Acceptance Criteria
Develop comprehensive
FindRelatedPrimitives.qltool queries for each supported language to discover CodeQL classes, predicates, and types relevant to a source code location.Query Output Schema
Implementation Design
Query Structure (
server/ql/{lang}/tools/src/FindRelatedPrimitives/)FindRelatedPrimitives.ql: Main entry point queryfile,startLine,endLine,startColumn,endColumnPrimitive Discovery Logic
getType(),getAQualifiedName()accessorsDataFlow::Nodesubtypes when applicableControlFlowNodeandBasicBlocktypesRelevance Scoring
Per-Language Implementation
Required for:
actions,cpp,csharp,go,java,javascript,python,ruby,swiftAcceptance Criteria
server/ql/{lang}/tools/.expectedfiles for each languagecodeql_query_runtool for execution