Skip to content

Extend FindRelatedPrimitives tool queries for all languages #4

@data-douser

Description

@data-douser

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

  1. Query Structure (server/ql/{lang}/tools/src/FindRelatedPrimitives/)

    • FindRelatedPrimitives.ql: Main entry point query
    • Parameterized by: file, startLine, endLine, startColumn, endColumn
  2. 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
  3. Relevance Scoring

    • Direct AST match: score 100
    • Parent/child AST types: score 75
    • Related dataflow concepts: score 50
    • Tangentially related types: score 25
  4. Per-Language Implementation
    Required for: actions, cpp, csharp, go, java, javascript, python, ruby, swift

Acceptance Criteria

  • Query implemented for all 9 languages in server/ql/{lang}/tools/
  • Unit tests with .expected files for each language
  • Results ranked by relevance score
  • Integration with codeql_query_run tool for execution

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions