Commit Graph

87416 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
190a76125e 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-05-14 00:22:13 +01:00
copilot-swe-agent[bot]
b6b01245c2 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-05-14 00:22:11 +01:00
copilot-swe-agent[bot]
ef6e973831 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-05-14 00:22:09 +01:00
copilot-swe-agent[bot]
8bd2effeff 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-05-14 00:22:07 +01:00
copilot-swe-agent[bot]
515e5c13ca 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-05-14 00:22:05 +01:00
Owen Mansel-Chan
7bf289ed1e Checkpoint from VS Code for cloud agent session 2026-05-14 00:22:03 +01:00
Owen Mansel-Chan
2a22399150 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-05-14 00:22:01 +01:00
Owen Mansel-Chan
0e2125b385 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-05-14 00:21:59 +01:00
Owen Mansel-Chan
d4ce252e7b 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-05-14 00:21:57 +01:00
Asger F
cfa175357b Merge pull request #21815 from asgerf/asgerf/missing-node-kind-error
Shared: Nicer panic message if node kind is missing
2026-05-13 10:11:14 +02:00
Owen Mansel-Chan
0b808e1170 Merge pull request #21807 from owen-mc/java/improve-qhelp-unsafe-deserialization
Shared: improve qhelp for unsafe deserialization queries
2026-05-12 22:22:49 +01:00
Taus
5508b1576f Merge pull request #21821 from github/tausbn/unified-swift-grammar-cleanup-phase-1
unified: Swift grammar cleanup part 1
2026-05-12 16:12:09 +02:00
Taus
911e59caef unified: regenerate files 2026-05-12 12:57:26 +00:00
Taus
ff5c0b40f1 unified: add supertypes for various kinds of declarations
Hides a bunch of huge unions under (hopefully) sensible supertypes.
2026-05-12 12:57:26 +00:00
Taus
a5a1312e51 unified: regenerate files 2026-05-12 12:57:25 +00:00
Taus
2608db9fd9 unified: Prevent field bleed-through from _if_let_binding
Same procedure as before -- we change the anonymous node to a named
node, and the problem magically goes away.
2026-05-12 12:57:25 +00:00
Taus
f9e7f90896 unified: regenerate files 2026-05-12 12:57:25 +00:00
Taus
31386f566c unified: drop element field on _parenthesized_type
Same pattern we've seen many times before: a field on an anonymous node
gets attached to the parent node instead.

I'm not 100% sure this is the right solution, but it seemed wrong to
just make `_parenthesized_type` named instead (we don't usually name
parentheticals). At the very least, this cleans up the spurious
navigation_expression.element and tuple_type_item.element fields.
2026-05-12 12:57:25 +00:00
Taus
e9822f67ee unified: regenerate files 2026-05-12 12:57:25 +00:00
Taus
994b27bdbd unified: convert _type into a named rule
Because `_type` was anonymous, its body was inlined in all of the places
it appeared. Because this body contained a `name` field, this field was
_also_ inlined. This caused a bunch of nodes to have spurious `name`
fields, and for some of them (that already had such a field) it caused
that field have multiplicity greater than one.

To fix this, we make the `_type` node named, which prevents the errant
field from escaping.
2026-05-12 12:57:25 +00:00
Taus
a720e258ac unified: regenerate files 2026-05-12 12:57:25 +00:00
Taus
8b977ef8e1 unified: Get rid of some "." bleed
Adds a new type `nested_type_identifier`, which contains the
choice-branch that previously allowed those tokens to bleed through into
the closest parent field.
2026-05-12 12:57:25 +00:00
Taus
caa9b04ad8 unified: regenerate files 2026-05-12 12:57:25 +00:00
Taus
91a46f0340 unified: stop "!" bleeding through
You know the drill. We just make an anonymous node named instead. In
this case, however, we have to be a bit more clever about how to rewrite
it. We turn the sequence of a type followed by an optional ! into a
_choice_ between mere type or type followed by bang (the latter being
our new named node).
2026-05-12 12:57:24 +00:00
Taus
37e1e3c879 unified: regenerate files 2026-05-12 12:57:24 +00:00
Taus
70f3fd1158 unified: make unannotated_type named and supertype
Gets rid of a bunch of ad-hoc node type unions.
2026-05-12 12:57:24 +00:00
Taus
9abfaca98c unified: regenerate files 2026-05-12 12:57:24 +00:00
Taus
38473f9e0b unified: make expression named and a supertype
Supertypes are a honking great idea. We should use more of them.

This massively cleans up the node types, without polluting the AST with
`expression` nodes.
2026-05-12 12:57:24 +00:00
Taus
c7c6e45254 unified: regenerate files 2026-05-12 12:57:24 +00:00
Taus
c0efc52cc7 unified: make if-condition nodes named, to stop bleed
Before, the `condition` field of an if statement supposedly could
contain things like parentheses and commas, due to bleeding from
referenced anonymous nodes. Making the node named makes this issue go
away.
2026-05-12 12:57:24 +00:00
Taus
5c16b0faf9 unified: regenerate files 2026-05-12 12:57:24 +00:00
Taus
7854a534fd unified: stop operators bleeding through everywhere
We make _referenceable_operator a named node. This prevents it from
bleeding through to the _expression definition. It likely also makes the
output easier to deal with, as bare operators used as arguments now have
a named node wrapping them in the AST.

Also removes a duplicated inclusion of _comparison_operator that served
no purpose.
2026-05-12 12:57:24 +00:00
Taus
76a1a87c41 unified: regenerate files 2026-05-12 12:57:23 +00:00
Taus
9062bba168 unified: get rid of undesirable self-recursion in _expression
This caused any field containing an _expression to appear as if it could
countain any number of such nodes. It also threw away the information
that there was a `?` marker there.

To fix it, we simply move the definition into its own named node.
2026-05-12 12:57:23 +00:00
Taus
e709650449 unified: Rebuild generated files
The astute reader will note that we seem to _lose_ some node types in
the process. Apparently, these were unreachable in the grammar, and the
newer version of tree-sitter removes such "dead code".
2026-05-12 12:57:23 +00:00
Taus
513c7bb30b unified: Add scripts for automatically rebuilding Swift grammar 2026-05-12 12:57:23 +00:00
Taus
9c958a420a Merge pull request #21819 from github/tausbn/unified-vendor-in-tree-sitter-swift
unified: use a vendored-in copy of tree-sitter-swift
2026-05-12 14:55:35 +02:00
Taus
2e9de7878b unified: update build dependencies 2026-05-12 11:25:15 +00:00
Taus
c5ae315dbe unified: auto-generate parser files
Uses the `tree-sitter-generate` crate to generate these files on the
fly.
2026-05-12 11:24:35 +00:00
Owen Mansel-Chan
592c7c0437 Merge pull request #21826 from AriehSchneier/fix/go-extractor-root-test-files
Go: Fix extractor to extract root internal test files
2026-05-12 10:34:42 +01:00
Owen Mansel-Chan
c0798f7b1d Merge pull request #21829 from owen-mc/static/update-framework-report-sink-kinds
C#, Go, Java: Use all path injection sinks when generating docs
2026-05-12 10:16:31 +01:00
Jeroen Ketema
cac7262a45 Merge pull request #21831 from jketema/jketema/swift-declared-interface-type
Swift: Expose the declared interface type of a type decl
2026-05-12 09:47:39 +02:00
Owen Mansel-Chan
6b65866ff4 Merge branch 'main' into fix/go-extractor-root-test-files 2026-05-11 17:18:43 +01:00
Jeroen Ketema
73a210a442 Swift: Add change note 2026-05-11 17:24:09 +02:00
Owen Mansel-Chan
0aaa7d0631 Update expected test output 2026-05-11 16:15:50 +01:00
Jeroen Ketema
f212efbe5b Swift: Expose the declared interface type of a type decl 2026-05-11 17:05:45 +02:00
Arieh Schneier
aa1d322fe7 Address PR feedback
Changes based on code review:

1. Remove redundant strings.Contains check in isExactTestPackage
   The equality check on the next line handles both cases, making
   the early return unnecessary.

2. Extract package selection logic into selectBestPackages function
   This reduces code duplication and allows the test to call the
   actual implementation rather than copying the logic.

3. Add TestSelectBestPackages to test the new function
   Comprehensive test covering single packages, test vs production,
   exact vs nested tests, and multiple packages.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-05-11 21:07:39 +10:00
Arieh Schneier
151a332f0a Add Bazel build target for extractor_test.go
Generated by manually applying the output from CI's Gazelle check.
This adds the go_test target for the new extractor_test.go file.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-05-11 20:55:11 +10:00
Owen Mansel-Chan
974e7cc319 Merge pull request #21825 from github/dependabot/go_modules/go/extractor/extractor-dependencies-0e0a523006
Bump the extractor-dependencies group in /go/extractor with 2 updates
2026-05-11 11:35:14 +01:00
Asger F
f91482810d Merge pull request #21816 from github/tausbn/yeast-mutate-in-place
yeast: Two minor performance optimisations
2026-05-11 11:08:24 +02:00