Skip to content

[K9VULN-14294] Update to tree-sitter 0.25.8#909

Merged
jasonforal merged 3 commits into
mainfrom
jf/K9VULN-14294
May 12, 2026
Merged

[K9VULN-14294] Update to tree-sitter 0.25.8#909
jasonforal merged 3 commits into
mainfrom
jf/K9VULN-14294

Conversation

@jasonforal

@jasonforal jasonforal commented May 8, 2026

Copy link
Copy Markdown
Collaborator

What problem are you trying to solve?

We're using tree-sitter 0.24.7 (from January 2025). The latest version is 0.26.8 (March 2026), and it contains numerous bug fixes.

What is your solution?

Update to tree-sitter 0.25.8

  • 0.25.0 introduced a breaking change removing timeout_micros from the QueryCursor API. This PR thus re-implements the same functionality using the new callback-based cancellation API.

Why not 0.26.8?

There was a non-trivial behavior change from 0.25.8 to 0.25.9 due to a bug in the query engine that was fixed with tree-sitter/tree-sitter#4532. A good amount of our default rules are currently affected by this, and so going from 0.25.8 -> 0.25.9 introduces a regression in true positives/true negatives. It'll require its own migration.

CI Failure

The "check_regressions (golang, go)" CI failure is expected. 0.25.0 fixes a false negative present in 0.24.7 with the go-best-practices/superfluous-else rule. This is due to a bug in how 0.24.7 dealt with alternations and anchors, which was fixed by tree-sitter/tree-sitter#4067. This didn't cause any real regressions (i.e. no false positives or false negatives) within our default rulesets, though it is important to note it might affect a custom rule. I'll add a disclaimer in the release notes.

Notes

  • 3f3de56 adapts a unit test that relied on the previous, buggy behavior for alternations/anchors referenced in "CI Failure" above.

@datadog-datadog-prod-us1

This comment has been minimized.

@jasonforal
jasonforal marked this pull request as ready for review May 11, 2026 13:52
@jasonforal
jasonforal requested a review from a team as a code owner May 11, 2026 13:52
Copilot AI review requested due to automatic review settings May 11, 2026 13:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR upgrades the Rust tree-sitter dependency to 0.25.8 and adapts the static analysis kernel to the updated query cursor API (notably replacing the removed timeout_micros with the new callback-based cancellation mechanism).

Changes:

  • Bump tree-sitter to =0.25.8 and update lockfile accordingly.
  • Rework TSQueryCursor::matches to use QueryCursorOptions progress callbacks for timeouts and return collected matches.
  • Remove direct streaming-iterator usage/dependency in favor of tree_sitter::StreamingIterator, and adjust affected queries/tests.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
LICENSE-3rdparty.csv Removes the direct streaming-iterator entry after dependency cleanup.
crates/static-analysis-kernel/src/analysis/tree_sitter.rs Re-implements query timeouts via progress callbacks; changes matches to return Vec; adds a timeout unit test.
crates/static-analysis-kernel/src/analysis/languages/python/imports.rs Switches StreamingIterator import to tree_sitter re-export.
crates/static-analysis-kernel/src/analysis/languages/javascript/imports.rs Adjusts JS imports query patterns for updated tree-sitter behavior and switches StreamingIterator import.
crates/static-analysis-kernel/src/analysis/languages/java/imports.rs Switches StreamingIterator import to tree_sitter re-export.
crates/static-analysis-kernel/src/analysis/languages/go/imports.rs Switches StreamingIterator import to tree_sitter re-export.
crates/static-analysis-kernel/src/analysis/languages/csharp/using_directives.rs Switches StreamingIterator import to tree_sitter re-export.
crates/static-analysis-kernel/src/analysis/ddsa_lib/runtime.rs Updates call sites for TSQueryCursor::matches returning Vec (retain vs iterator filter).
crates/static-analysis-kernel/src/analysis/ddsa_lib/js/ts_node.rs Switches StreamingIterator import to tree_sitter re-export (tests).
crates/static-analysis-kernel/src/analysis/ddsa_lib/context/file_tf.rs Switches StreamingIterator import to tree_sitter re-export.
crates/static-analysis-kernel/src/analysis/ddsa_lib/bridge/query_match.rs Updates call sites for matches returning Vec (tests).
crates/static-analysis-kernel/Cargo.toml Removes direct streaming-iterator dependency.
Cargo.toml Pins tree-sitter to =0.25.8.
Cargo.lock Updates dependency graph for tree-sitter 0.25.8 and related transitive changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/static-analysis-kernel/src/analysis/tree_sitter.rs Outdated
jasonforal and others added 3 commits May 11, 2026 10:04
- Migrate `QueryCursor::set_timeout_micros` (removed in 0.25) to the new
  progress-callback-based cancellation via `matches_with_options` +
  `QueryCursorOptions::progress_callback`. `TSQueryCursor::matches` now
  returns `Vec<QueryMatch<...>>` so the closure's lifetime is bounded by
  the function body.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The alternation arm `name: ((_) "as")` asserted that `"as"` is a child
of the `name:` field's content; in the tree-sitter-javascript grammar
it's a sibling of the field, so the arm never matched cleanly. The
upgrade to tree-sitter 0.25.0 stopped tolerating it and dropped the
match entirely.

Split the alternation into two top-level patterns: one for bare
`import { x }` (anchored, name is the only child) and one for
`import { x as y }` (anchored, name field followed by an `"as"` sibling).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@jasonforal
jasonforal merged commit f6ab8f4 into main May 12, 2026
142 of 170 checks passed
@jasonforal
jasonforal deleted the jf/K9VULN-14294 branch May 12, 2026 16:08
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.

3 participants