Commit Graph

87816 Commits

Author SHA1 Message Date
Owen Mansel-Chan
f84e8b0fbc Make all lines in logging tests reachable 2026-06-03 14:29:10 +01:00
Owen Mansel-Chan
d7ff3ff472 Restore ConditionGuardNode 2026-06-03 14:19:32 +01:00
Owen Mansel-Chan
5c91529b92 Fix treatment of ParenExpr 2026-06-03 14:19:30 +01:00
Owen Mansel-Chan
996a936f85 Add Go CFG consistency query 2026-06-03 14:19:28 +01:00
Owen Mansel-Chan
e56ca68821 Go: update expected node names 2026-06-03 13:04:32 +01:00
Owen Mansel-Chan
6d3d220f71 Use shared CFG getIfInit 2026-06-03 13:04:30 +01:00
Owen Mansel-Chan
7aa651a6c7 Fix lit-init nodes
There was a loop in the definitions which meant nothing ever got made
2026-06-03 13:04:28 +01:00
Owen Mansel-Chan
ee6b8394ab Fix range loop CFG 2026-06-03 13:04:26 +01:00
Owen Mansel-Chan
d8ac19e8c2 update function-entry additional nodes 2026-06-03 13:04:24 +01:00
Owen Mansel-Chan
5578987d0a Restore ExprNode for FuncLit 2026-06-03 13:04:22 +01:00
Owen Mansel-Chan
b6813ac20f Accept change in test output
To determine that test9 can't return normally, you have to use the fact
that test5 can't return normally. This would make CFG construction
recursive, which would be bad for performance. Therefore we accept the
limitation that we cannot detect that test9 can't return normally, and
we change the test output.
2026-06-03 13:04:20 +01:00
Owen Mansel-Chan
b12f7915f9 Fix empty switch statements 2026-06-03 13:04:18 +01:00
Owen Mansel-Chan
e2516fc383 Control flow shouldn't enter another callable 2026-06-03 13:04:16 +01:00
Owen Mansel-Chan
44e7f0fc6d Fix CFG for return instructions 2026-06-03 13:04:15 +01:00
Owen Mansel-Chan
c489f6ffa1 Produce CFG nodes for more reference expressions, like selector bases 2026-06-03 13:04:13 +01:00
Owen Mansel-Chan
c620a423d5 Fix global value numbering calculation 2026-06-03 13:04:10 +01:00
Owen Mansel-Chan
a23b398be9 Include receivers in parameter init 2026-06-03 13:04:09 +01:00
Owen Mansel-Chan
bee9ead570 Fix CFG for range loop 2026-06-03 13:04:07 +01:00
Owen Mansel-Chan
481564668d Fix CFG for select statements 2026-06-03 13:04:05 +01:00
Owen Mansel-Chan
d189d28f63 Use shared CFG implementation of for loops 2026-06-03 13:04:03 +01:00
Owen Mansel-Chan
b411b0ecd0 Do not include comments in the CFG 2026-06-03 13:04:01 +01:00
Owen Mansel-Chan
2c4fe160bf Fix edges to function exit with result variables 2026-06-03 13:03:59 +01:00
Owen Mansel-Chan
0faf3c89df Tweak getEnclosingCallable 2026-06-03 13:03:57 +01:00
Owen Mansel-Chan
b01c0c524b Model non-returning functions in CFG 2026-06-03 13:03:55 +01:00
Owen Mansel-Chan
82913576d6 Create cfg node for child of ParenExpr 2026-06-03 13:03:53 +01:00
Owen Mansel-Chan
c054c3e9b5 Add go/print-cfg 2026-06-03 13:03:51 +01:00
Owen Mansel-Chan
7538201824 Fix overlay annotation in PrintAst.qll 2026-06-03 13:03:49 +01:00
copilot-swe-agent[bot]
e8310f4805 Add GotoStmt, Parameter, Throw, Assignment and PatternMatchExpr to Go Ast module for updated shared CFG AstSig
Agent-Logs-Url: https://github.com/github/codeql/sessions/005953d9-1d54-4071-8cd2-5a7d26f65f61

Co-authored-by: owen-mc <62447351+owen-mc@users.noreply.github.com>
2026-06-03 13:03:48 +01:00
copilot-swe-agent[bot]
f239a8cbce Fix shared Go CFG expression and return-edge regressions
Agent-Logs-Url: https://github.com/github/codeql/sessions/3f96ead2-cda4-479c-9e37-f38ace035870

Co-authored-by: owen-mc <62447351+owen-mc@users.noreply.github.com>
2026-06-03 13:03:46 +01:00
copilot-swe-agent[bot]
13cbc84ded Add missing QLdoc comments to IR.qll classes, predicates, and newtype branches
Agent-Logs-Url: https://github.com/github/codeql/sessions/12c0f9c8-1b85-4db4-b26f-8dbce818aa5a

Co-authored-by: owen-mc <62447351+owen-mc@users.noreply.github.com>
2026-06-03 13:03:44 +01:00
copilot-swe-agent[bot]
0c2d12b6b0 Add File as a CFG root to support file-level declarations
Agent-Logs-Url: https://github.com/github/codeql/sessions/2867f173-c3f1-4564-9885-3ff4517bbf30

Co-authored-by: owen-mc <62447351+owen-mc@users.noreply.github.com>
2026-06-03 13:03:42 +01:00
copilot-swe-agent[bot]
2731bce761 Fix compiler errors and warnings: remove redundant type checks and isIn guards, mark implicitFieldSelection as additional
Agent-Logs-Url: https://github.com/github/codeql/sessions/8d96128c-44db-4ba1-9eca-1a5b37f54442

Co-authored-by: owen-mc <62447351+owen-mc@users.noreply.github.com>
2026-06-03 13:03:40 +01:00
copilot-swe-agent[bot]
171ec3cd90 Fix overlay annotation in ControlFlowGraphShared.qll
Agent-Logs-Url: https://github.com/github/codeql/sessions/011f8465-5ad3-44e2-9d84-f5314ea1afb2

Co-authored-by: owen-mc <62447351+owen-mc@users.noreply.github.com>
2026-06-03 13:03:38 +01:00
copilot-swe-agent[bot]
5eb47af3c2 Continue shared CFG library migration: fix prologue/epilogue, implicit fields, cleanup
Agent-Logs-Url: https://github.com/github/codeql/sessions/011f8465-5ad3-44e2-9d84-f5314ea1afb2

Co-authored-by: owen-mc <62447351+owen-mc@users.noreply.github.com>
2026-06-03 13:03:36 +01:00
Owen Mansel-Chan
367de60ca8 Checkpoint from VS Code for cloud agent session 2026-06-03 13:03:34 +01:00
Owen Mansel-Chan
0e97c26da6 All 90 queries compile cleanly. Here's the status:
Phase 2 progress — shared CFG library fully instantiated with IR support:

ControlFlowGraphShared.qll (1290 lines) now contains:

additionalNode entries for all 30+ synthetic IR operations:

Assignment writes (assign:i), compound RHS (compound-rhs), tuple extraction (extract:i)
Zero initialization (zero-init:i), increment/decrement (implicit-one, incdec-rhs)
Return (return), result write/read (result-write:i, result-read:i)
Function prologue (param-init:i, arg:i, result-init:i, result-zero-init:i)
Range next (next), send (send), implicit deref (implicit-deref)
Slice bounds (implicit-low/high/max), case checks (case-check:i)
Type switch variables (type-switch-var), literal init (lit-init, lit-index)
Implicit field selection (implicit-field:i)
step routing for all constructs needing custom flow:

Assignments (with epilogue node sequencing for extract/assign chains)
Increment/decrement (operand → implicit-one → incdec-rhs → In)
Return statements (expressions → extract → result-write → return)
Index/slice/selector expressions (with implicit deref insertion)
Composite literals (pre-order: allocation first, then element init)
Send statements (channel → value → send)
Plus the existing: if-with-init, for/range loops, switch/select, defer, go
What remains for full migration (making shared types primary):

Rewrite ControlFlowGraph.qll: change ControlFlow::Node from TControlFlowNode to GoCfg::ControlFlowNode
Rewrite IR.qll (1598 lines): map all 30+ IR instruction classes to shared CFG nodes via getAstNode()/getIdTag() instead of Mk* types
Update BasicBlocks.qll to use shared library's built-in BasicBlock
Update ~30 downstream files (SSA, DataFlow, security queries) that reference IR::Instruction/ControlFlow::Node
Add function prologue/epilogue step routing (param init, result init, defer LIFO at exit)
Remove ControlFlowGraphImpl.qll
This remaining work is a substantial rewrite (3000+ lines across 35+ files) that would benefit from being done incrementally with test validation at each step. Shall I continue with the IR.qll rewrite next?
2026-06-03 13:03:32 +01:00
Owen Mansel-Chan
23675b0fae Phase 1 — Complete. The shared CFG library is now instantiated and wired into Go:
Created ControlFlowGraphShared.qll — contains the full GoCfg module with:

Ast module implementing AstSig<Location> — maps Go's AST types to the shared interface, with empty types for constructs Go doesn't have (while/do/try/catch/throw/ternary/null-coalescing)
Input module implementing InputSig1 + InputSig2 — labels, conditional contexts, custom step() predicates for if-with-init, for/range loops, expression/type switches, case clauses, select, defer, and go statements; abrupt completions for panics, fallthrough, and goto
Make0/Make1/Make2 wiring and import Public
Modified ControlFlowGraph.qll — added import of the shared library and re-exports it as module SharedCfg = GoCfg, making shared types accessible as SharedCfg::ControlFlowNode, SharedCfg::ControlFlow::EntryNode, SharedCfg::BasicBlock, etc.

No breakage — all 90 src queries and library files compile cleanly.
2026-06-03 13:03:30 +01:00
Owen Mansel-Chan
2b26022e4b The shared CFG library instantiation for Go compiles cleanly. Let me show you the current state of the file:
Read ControlFlowGraphShared.qll, lines 1 to 50

The file compiles successfully. Here's a summary of what was implemented:

ControlFlowGraphShared.qll — Shared CFG library instantiation for Go, wrapped in the GoCfg module to coexist with the existing CFG during transition. Key design decisions:

Ast module (implements AstSig):

Callable = FuncDef with a body
IfStmt — only For if-statements without init (those with init use custom steps)
LoopStmt — uses characteristic predicate pattern (not direct extension) to avoid return type conflicts with BlockStmt
Empty classes for: WhileStmt, DoStmt, ForStmt, ForeachStmt, ThrowStmt, TryStmt, CatchClause, Switch, Case, ConditionalExpr, NullCoalescingExpr (Go doesn't have these constructs)
LogicalAndExpr = LandExpr, LogicalOrExpr = LorExpr, LogicalNotExpr = NotExpr
BooleanLiteral maps to true/false identifiers
skipCfg filters out type expressions, non-rvalue references, parenthesized expressions, etc.
Input module (implements InputSig1 + InputSig2):

Labels: Go statement labels + fallthrough
Custom steps for: if-with-init, for loops, range loops, expression/type switch, case clauses, select statements, defer, go statements
Abrupt completions: panic via calls/div/deref/type-assert/index/conversion, fallthrough, goto
End abrupt completions: labeled statements catch breaks, goto targets
Remaining work (todos 4-6): The GoCfg module is self-contained and doesn't yet replace the existing CFG. Integration with BasicBlocks.qll, IR.qll, and the public ControlFlowGraph.qll API is the next phase — which is a larger effort requiring updates to DataFlow and all downstream consumers.
2026-06-03 13:03:29 +01:00
Owen Mansel-Chan
52f2a5825a Merge pull request #21804 from github/copilot/add-tests-for-models
Java: Update CWE-918 model coverage for Apache HttpClient `execute` sinks
2026-06-03 12:55:56 +01:00
Owen Mansel-Chan
d55ff83568 Merge pull request #21269 from owen-mc/go/improve-tests-for-varargs-flow
Go: improve tests for varargs flow
2026-06-03 12:39:46 +01:00
Asger F
7edf0100cc Merge pull request #21924 from asgerf/asgerf/yeast-changes
Yeast: some fixes
2026-06-03 10:32:38 +02:00
Owen Mansel-Chan
167c837088 Merge pull request #21914 from owen-mc/shared/cfg/if-init
Shared CFG: allow init stmts for IfStmt
2026-06-02 22:01:02 +01:00
Jeroen Ketema
d11fc3a00e Merge pull request #21932 from jketema/jketema/vue
JS: Add Vue to `file_coverage_languages` and `github_api_languages`
2026-06-02 17:53:25 +02:00
Jeroen Ketema
9d5dfea5c5 JS: Add Vue to file_coverage_languages and github_api_languages 2026-06-02 16:57:51 +02:00
Owen Mansel-Chan
aaa3b363e1 Merge pull request #21929 from owen-mc/go/no-ret-functions
Go: Recognize more non-returning logging functions
2026-06-02 10:39:28 +01:00
Owen Mansel-Chan
9dbe9adb00 Update tests 2026-06-02 09:34:03 +01:00
Owen Mansel-Chan
be9c785cb2 Fix incorrect QLDoc
Co-authored-by: Tom Hvitved <hvitved@github.com>
2026-06-02 09:26:13 +01:00
Owen Mansel-Chan
703cea2b65 Model panicking log functions better 2026-06-02 01:32:00 +01:00
Owen Mansel-Chan
e6e8e3d005 Taint doesn't flow through panicking functions 2026-06-02 01:31:44 +01:00
Owen Mansel-Chan
adc9b7714b Accept changed test output 2026-06-02 00:57:06 +01:00