fix: enable TypeScript tree-sitter parsing - #14
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe TypeScript tree-sitter path now recognizes the TypeScript language accessor, wraps compatible language objects, warns on initialization fallback, handles ChangesTypeScript tree-sitter support
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant TypeScriptScanner
participant TreeSitterParser
participant TreeSitter
TypeScriptScanner->>TreeSitterParser: initialize TypeScript parsing
TreeSitterParser->>TreeSitter: resolve language and parse source
TreeSitter-->>TreeSitterParser: return AST or initialization error
TreeSitterParser-->>TypeScriptScanner: traverse calls or use regex fallback
TypeScriptScanner-->>TypeScriptScanner: map exec/spawn calls to AGENT-034
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/audit/agent_audit/parsers/treesitter_parser.py`:
- Around line 190-219: Update the tree-sitter initialization logic to remove the
wrap_language flag and unconditionally convert lang to a tree_sitter.Language
when it is not already that type, before constructing tree_sitter.Parser in the
parser setup flow. Preserve all language accessor branches and fallback behavior
unchanged.
In `@packages/audit/agent_audit/scanners/typescript_scanner.py`:
- Around line 66-69: Update the AGENT-034 handling associated with the
ts_child_process_exec mappings in the TypeScript scanner to support all required
pattern types: tool_no_input_validation, eval_exec_expanded, and
subprocess_expanded. Ensure the relevant handling logic recognizes and processes
each pattern type, not just the existing mapping definitions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 92be8679-87c1-49c2-a6dd-9ecc9999627f
📒 Files selected for processing (5)
CHANGELOG.mdpackages/audit/agent_audit/parsers/treesitter_parser.pypackages/audit/agent_audit/scanners/typescript_scanner.pypackages/audit/pyproject.tomltests/test_parsers/test_treesitter_parser.py
Signed-off-by: Floze <88098863+floze-the-genius@users.noreply.github.com>
Summary
tree_sitter_typescript.language_typescript()and convert its capsule to atree_sitter.Languagetree-sitter 0.24.xlinenew Function()and importedexec/spawndetections when the TypeScript AST path is activeRoot cause
tree_sitter_typescript 0.23.xexposeslanguage_typescript()rather thanLANGUAGEorlanguage(). It returns aPyCapsule, which also requirestree-sitter 0.24.xforLanguage(capsule)conversion; the previoustree-sitter ^0.22.0constraint could not initialize that grammar.Testing
1516 passed, 1 skippedwith all tree-sitter grammar packages installedruff check packages/auditruff check tests/test_parsers/test_treesitter_parser.py tests/test_typescript_scanner.pymypy packages/audit/agent_audit --ignore-missing-imports(81 source files)agent-audit[tree-sitter], resolvedtree-sitter 0.24.0/tree-sitter-typescript 0.23.2, and assertedTreeSitterParser(..., file_path="x.ts").is_tree_sitter_availableScope
.tsxremains mapped to the TypeScript grammar, matching the current language mapping and the issue's requested minimal scope. Selecting the separate TSX grammar remains a follow-up design decision.Closes #12.
AI assistance
This contribution was implemented and tested with OpenAI Codex assistance. The final diff and verification results were reviewed before submission.
Summary by CodeRabbit
exec*/spawn*are used withoutchild_process.qualification, plus better handling ofnew Function().