Repository navigation
fix(analyzer): recognize JavaScript template literals - #801
Open
efegokdemir wants to merge 1 commit into
Open
efegokdemir wants to merge 1 commit into
efegokdemir wants to merge 1 commit into
Conversation
Signed-off-by: Efe <efe@rexcode.co.uk>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Recognize parser-proven JavaScript template literal spans when checking whether the bounded shell parser exhausted its input. Benign templates no longer make an otherwise complete JavaScript file appear partially inspected. Malformed or unsupported JavaScript remains on the conservative path. When an interpolated template coexists with a recognized shell-execution call, the file also remains partial because this analyzer does not prove the template's data flow.
Why
JavaScript uses backticks to delimit template literals. The shell parser treated those delimiters and quotes inside interpolations as shell syntax, so ordinary source files could receive
static_parse_limitand never reach a complete inspection result.How
Use Esprima to parse complete JavaScript within the existing source-size bound and obtain exact template-literal ranges. The static finding scan still receives the original source, so command findings remain visible. Template ownership is used only for parser-completeness accounting, and dynamic templates in files with recognized execution calls retain the conservative result.
This addresses the JavaScript template-literal case in #694; the broader issue remains open for its other reported language cases.
Testing
upstream/main, the four benign template regression cases failed as expected; after this change they pass. Dynamic execution and malformed-source controls remain partial.pytest -m 'not integration and not provider' tests/ -q: 10,544 passed, 17 skipped, 4 xfailed, 133 deselected.make lint,make format-check, anduv build --out-dir /tmp/skillspector-694-distpassed.mypy src/skillspector/javascript_tokens.pypassed.Compatibility
No public API changes. Static findings continue to scan the original source. The new parser fails closed for unsupported syntax and incomplete contexts.
Checklist
Prepared with AI assistance.
Related to #694.