Skip to content

Unified: Add control flow graph. - #7

Open
anurag6569201 wants to merge 1 commit into
qa/agent-github-codeql/pr-07-22479/basefrom
qa/agent-github-codeql/pr-07-22479/head
Open

anurag6569201 wants to merge 1 commit into
qa/agent-github-codeql/pr-07-22479/basefrom
qa/agent-github-codeql/pr-07-22479/head

Conversation

@anurag6569201

Copy link
Copy Markdown

This is a very rough initial version, but it provides the basic functionality including "View CFG" support and consistency queries.

Source merge-base: 164d97da7456f78a78e8a1b8a27bacd18ab24604
Source head: f452bd48ebf0cf989ead1f81d769fba38b2f9a9d

@shipwright-agent

Copy link
Copy Markdown

⛔ Shipwright · Blocked

Recommendation: do not merge PR #7 · Tier T2
Checks: 0 total · 0 needing attention

Next step: resolve the blocking findings before merge.

Findings (7)

  • CRITICAL The 'Ast' module implementing 'AstSig<Location>' contains numerous stub classes with 'none()' bodies (e.g., 'ExprStmt', 'IfStmt', 'ForStmt', 'GotoStmt', 'Assignment', 'UntilStmt'). · unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll:60
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • CRITICAL 'BooleanLiteral.getValue()' is implemented as 'result.toString() = super.getValue()'. · unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll:190
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The 'Ast' module is a large hand-written adapter with many 'none()' stubs and TODO comments (e.g., '// TODO support foreach guard', '// TODO: sort out the relationship between Bina · unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll:110
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH 'Block.getLastStmt()' uses 'not exists(this.getStmt(i + 1))' to find the last statement. · unified/ql/lib/codeql/unified/internal/FacadeAst.qll:42
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH 'getEnclosingCallable' recurses through parents but stops only when the parent is a 'Callable'. · unified/ql/lib/codeql/unified/internal/ControlFlowGraph.qll:31
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The new 'printCfg.ql' query is tagged 'ide-contextual-queries/print-cfg' and exposes a graph representation of a file's CFG via external predicates ('selectedSourceFile', 'selected · unified/ql/lib/ide-contextual-queries/printCfg.ql:1
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The new 'qlpack.yml' adds a dependency on 'codeql/controlflow' and changes the dependency order. · unified/ql/lib/qlpack.yml:8
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

Fireworks usage: 11,803 input · 941 output · 12,744 total tokens · $0.0032 · 14s · 0 fix iteration(s)

Open the Shipwright check for full evidence and the audit bundle. Use /shipwright rerun to verify again.

}

class Parameter extends U::Parameter {
Expr getDefaultValue() { result = super.getDefault() }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shipwright · CRITICAL

The 'Ast' module implementing 'AstSig<Location>' contains numerous stub classes with 'none()' bodies (e.g., 'ExprStmt', 'IfStmt', 'ForStmt', 'GotoStmt', 'Assignment', 'UntilStmt').

Impact: The 'Ast' module implementing 'AstSig<Location>' contains numerous stub classes with 'none()' bodies (e.g., 'ExprStmt', 'IfStmt', 'ForStmt', 'GotoStmt', 'Assignment', 'UntilStmt'). Any CFG construction that encounters these node types will silently produce no control-flow edges, yielding an incomplete or incorrect CFG. This can cause downstream analyses (e.g., taint, dataflow, dead-code) to miss paths and prod…

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

class DefaultCase extends Case {
DefaultCase() { not exists(super.getPattern()) }
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shipwright · CRITICAL

'BooleanLiteral.getValue()' is implemented as 'result.toString() = super.getValue()'.

Impact: 'BooleanLiteral.getValue()' is implemented as 'result.toString() = super.getValue()'. This compares a string representation of a boolean result to the raw value, which is type-incompatible or always false depending on QL type resolution. If this compiles, it will never produce a true value, breaking CFG handling of boolean literals and any conditional logic depending on them.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

Expr getCondition() { result = super.getCondition() }
}

class UntilStmt extends LoopStmt {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shipwright · HIGH

The 'Ast' module is a large hand-written adapter with many 'none()' stubs and TODO comments (e.g., '// TODO support foreach guard', '// TODO: sort out the relationship between Bina

Impact: The 'Ast' module is a large hand-written adapter with many 'none()' stubs and TODO comments (e.g., '// TODO support foreach guard', '// TODO: sort out the relationship between BinaryExpr and Assignment'). A new maintainer cannot determine which language constructs are actually supported by the CFG without exhaustively reading every stub. This is a maintainability hazard and likely to cause incorrect assumptions abou…

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

}
}

/** A block statement. */

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shipwright · HIGH

'Block.getLastStmt()' uses 'not exists(this.getStmt(i + 1))' to find the last statement.

Impact: 'Block.getLastStmt()' uses 'not exists(this.getStmt(i + 1))' to find the last statement. This relies on 'getStmt' indices being contiguous and starting at 0. If the underlying AST representation has gaps or non-zero-based indexing, this predicate will return no result or the wrong statement, and the intent is not documented.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

private predicate skipControlFlow(AstNode e) { e instanceof Modifier or e instanceof Identifier }

AstNode getChild(AstNode n, int index) {
result.getParent() = n and

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shipwright · HIGH

'getEnclosingCallable' recurses through parents but stops only when the parent is a 'Callable'.

Impact: 'getEnclosingCallable' recurses through parents but stops only when the parent is a 'Callable'. If an AST node is not enclosed by any callable (e.g., top-level declarations outside a 'TopLevel' body), the recursion can fail to produce a result or traverse unexpectedly, leaving CFG nodes without an enclosing callable and breaking scope-based queries.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

@@ -0,0 +1,40 @@
/**

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shipwright · HIGH

The new 'printCfg.ql' query is tagged 'ide-contextual-queries/print-cfg' and exposes a graph representation of a file's CFG via external predicates ('selectedSourceFile', 'selected

Impact: The new 'printCfg.ql' query is tagged 'ide-contextual-queries/print-cfg' and exposes a graph representation of a file's CFG via external predicates ('selectedSourceFile', 'selectedSourceLine', 'selectedSourceColumn'). If this query is runnable in an environment where source file paths or line/column inputs are attacker-influenced, it could be used to exfiltrate code structure or probe internal source layout. The que…

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant