Skip to content

fix(analyzer): stop TypeScript templates from hitting parse limits - #990

Open
bniladridas wants to merge 6 commits into
NVIDIA:mainfrom
bniladridas:investigate/884-typescript-template-ownership
Open

bniladridas wants to merge 6 commits into
NVIDIA:mainfrom
bniladridas:investigate/884-typescript-template-ownership

Conversation

@bniladridas

@bniladridas bniladridas commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a bounded TypeScript template scanner and applies it only when the whole file is available. Benign .ts templates no longer reach the shell backtick parser, including the ${format(n)} reproducer. Tagged templates, shell execution surfaces, non-host shebangs, malformed delimiters, and ambiguous regex syntax stay conservative.

Maps .tsx to TypeScript so the same ownership path applies to TSX sources. JSX-specific syntax still fails closed, including JSX attribute templates. .jsx remains outside this change.

The scanner reads delimiters as matched opener and closer pairs, so a closer only ends the scope it actually pairs with. The earlier revision compared cross-bracket counts that were always equal and also carried a paren boundary stack to compensate, which let a bracket inside a call or an array end the scan early. That bookkeeping is gone here.

A slash after } divides rather than opening a regex. A brace ends an expression far more often than a statement, so const n = {} / eval(p) / 2 now reaches the eval guard instead of being read as a regex. Statement-position blocks that are followed by a regex still parse, and a nested block inside a template keeps later templates owned.

Identifiers are matched with escape sequences and decoded before they are classified, so \u0065val(payload), \x65val(payload) and \u{65}val(payload) are all the eval call they spell, while a benign escaped name stays owned. An escape inside a template is literal text, so that case is out of scope for an ownership bypass and covered only in code context.

An undecodable module specifier fails closed. _decode_string_source rejects an unknown escape such as the identity escape in ex\eca, so the raw spelling may still name execa; the reader now treats that as an execution module instead of falling back to a raw-string comparison.

After . or #, an identifier is a property name even when it spells a keyword. ${obj.return / eval(payload) / 2} used to read the middle slash as a regex opener, skip the eval call and claim the template; this.#return had the same hole. The scanner now records member context from the preceding token and vetoes the keyword set before the slash decision.

Review follow-up

Expand the five review follow-ups

Review follow-up from rng1995 (changes requested on de9e5a1d): the shared call list also carries the JavaScript keyword function, which is a declaration keyword in TypeScript. It is excluded from the TypeScript comparison, so a generic function body no longer suppresses ownership of a benign template; test_declaration_keywords_do_not_read_as_execution_calls fails without that exclusion. String spellings are decoded before the guard compares them. _decode_string_source resolves \xNN, \uNNNN, \u{...}, the single-character and line-continuation escapes without evaluation and returns None on malformed, unsupported, or partially decoded input, so an undecodable specifier keeps the conservative read instead of establishing or clearing ownership. Decoded module specifiers after from, import, and require are checked against the allowlist, and decoded computed and dotted members such as cp["exec"], cp[`exec`], and cp.exec are checked against _SHELL_EXECUTION_CALLS.

Review follow-up from yashrajp22 (four findings raised on b15673fd): four cases could still claim ownership of byte ranges the reader had not proven. Only the exact lowercase function is a declaration keyword, so Function, including new Function(${code})(), stays an execution surface. The callee name survives the ( token, so the module specifier in require('execa') and dynamic import(...) is compared with the execution-module list. Postfix ++/-- are consumed as a single token, so counter++ / eval(p) reads as division and does not skip the eval guard. Braces are balanced in host code as well as interpolation, ${ records its own brace, and unmatched or crossed (), [], and {} are rejected. A control head such as if (ok) { is still a statement, not a call.

Review follow-up from yashrajp22 (three findings raised on 9db61d04): an identity escape in a module specifier let ex\eca miss the module guard, the delimiter stack held only openers so delimiters.count(")") was always zero and a bracket inside a call, such as ${format(items[0])}, lost ownership, and the { handler pushed a paren boundary that only the non-interpolation close popped, so a valid nested object in an interpolation, such as ${({name: item.name}).name}, was rejected. The first is fixed by failing closed on undecodable specifiers, the second and third by the matched-pair stack and the removal of the boundary bookkeeping. A mutation check confirms each change is load-bearing: reverting the brace rule, the module rule, the identifier decode, the paren pairing or the bracket pairing each fails at least one committed test.

Review follow-up from yashrajp22 (P1 raised on 2026-11-13): the slash classifier lost the member role of a keyword after a dot, so ${obj.return / eval(payload) / 2} skipped the eval guard. Member context after . and # is now preserved, with span-helper and inspection-ledger regressions for return, delete, and typeof, a private-name case, and controls that keep a genuine keyword regex a regex. The dotted and private cases fail against the previous revision.

Review follow-up from rng1995 (required finding raised on b4c142b9): the opening parenthesis recorded a control head from the identifier text alone, even when the identifier was a member. In obj.if() / eval(input) / 2 the first close then set last_closed_control, so the next slash opened the regex-skip path and could grant ownership. The control-head decision now includes the recorded member role, so a keyword member call does not become a statement head. The new span-helper regression fails on the previous revision, the ledger case exercises the same path, and a genuine if (ok) regex remains a regex.

Verification

Rebased onto upstream main at 48e0f942 (125 commits ahead of the previous merge base 3c2c5d7a), so the branch is linear and six commits deep with no merge commit: 3684151a adds the bounded scanner, c340e45c decodes string escapes before the shell-surface checks, 47627367 closes the four older findings from yashrajp22, e333c99d closes the three newer ones, 498ddfb8 keeps keyword property names from opening a regex, and 7ce5e954 keeps member calls out of control heads. The merge base with upstream/main is 48e0f942. Conflicts were CHANGELOG.md, where both branches added an entry at the same insertion point, and the analyzer import block; the resolution keeps both entries and both imports. The rebase also adapted the moved _is_shell_execution_module import and kept the undecodable-benign-string test on a valid lone-surrogate escape for the native parser.

As run in this checkout on 7ce5e954:

  • pytest tests/nodes/analyzers/test_typescript_template_ownership.py tests/nodes/analyzers/test_typescript_template_ownership_delimiters.py tests/nodes/analyzers/test_host_language_shell_ownership.py tests/nodes/analyzers/test_javascript_template_ownership.py -q: 1148 passed
  • pytest tests/nodes/analyzers -q: 16928 passed, 4 skipped, 5 deselected, 4 xfailed
  • ruff check src/ tests/: passed
  • ruff format --check src/ tests/: 428 files already formatted

The full non-integration run was started locally and reached 64% with no failures before a 20 minute command timeout; CI runs the complete suite. The previous full run on the pre-rebase tree passed with 24723 passed, 40 skipped, 261 deselected, 4 xfailed in 1041.65s.

The new regressions in test_typescript_template_ownership_delimiters.py were run with the relevant change reverted: reverting the brace rule fails the division-only and the sink regressions, reverting the module rule fails the identity-escape case, reverting the identifier decode fails the four escape spellings, and reverting either delimiter pairing fails the bracket cases. Each new case therefore fails without its fix. The benign companions stay owned on both revisions, which keeps the guards from overreaching. The member-context regressions were also run against the previous scanner: the seven dotted cases and the private-name case fail there, while the genuine keyword-regex control passes on both revisions. The new member-call span-helper regression returned spans on the previous scanner, while the genuine if (ok) regex control passed on both revisions.

The .ts and .tsx CLI repro (skillspector scan --no-llm --format json) on the pre-rebase head b4c142b9 reports analysis_completeness.status is complete and coverage_percent is 100.0, with no issues.

CI on 7ce5e954 is queued after the force-push.

Scope

This is not a TypeScript parser or a shell-sink/dataflow model. It proves template literal ranges for complete TypeScript source and keeps the original conservative shell reading for anything it cannot prove. It does not model data flow through decoded names, so decoded comparisons apply to literal spellings only. JSX attribute templates are not owned and are not covered by a dedicated test; the conservative rejection stays until JSX syntax has its own coverage.

Refs #884

@bniladridas bniladridas left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Change walkthrough for the TypeScript template ownership path. Each thread explains the hunk and what to check.

Comment thread src/skillspector/typescript_tokens.py Resolved
Comment thread src/skillspector/typescript_tokens.py Resolved
Comment thread src/skillspector/typescript_tokens.py Resolved
Comment thread src/skillspector/typescript_tokens.py Resolved

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[SkillSpector Review]

Decision: Changes Requested

Value and readiness

The complete-source TypeScript path addresses #884's ordinary template-literal completeness problem, and the TSX mapping, bounded walks and conservative controls are useful. The new lexical proof still grants ownership to a real shell-execution template, so it is not ready to approve.

Material findings

Required — preserve the execution-surface guard for string spellings, src/skillspector/typescript_tokens.py:132-138 and 342-346. For example, this valid TypeScript uses Node's child-process module:

import * as cp from "node:child_\x70rocess";
cp["exec"](`${format(n)}`);

The module specifier's string value is node:child_process, and the computed member is the ordinary exec method. However, skip_string skips the escape and compares the raw source substring to the module allowlist, so this import is not rejected. The "exec" token is also handled as a string; only bare identifier tokens are compared with _SHELL_EXECUTION_CALLS. The remaining tokens and balanced interpolation pass the walk, so the function returns ownership for the execution template. _has_shell_command_word_exhaustion then skips its opening backtick and interpolation candidates through template_source.owns, dropping the conservative parse-limit evidence that this same complex template requires on an execution surface. The JavaScript path checks parsed module values and statically named computed members; this TypeScript path does neither. Decode supported string/identifier spellings or fail closed when they cannot be proven, and preserve execution-member checks for computed string properties. Add escaped-module and computed-execution-member regressions through both the helper and inspection ledger; the existing plain module/import and direct-call controls do not cover this case.

PIC tradeoffs

Reducing false partial results is valuable, but ownership must retain the existing conservative behavior when the template can supply a shell command. Recognizing syntax without accounting for its string value is insufficient for that proof.

Verification and gaps

Reviewed pinned head de9e5a1d933c452b1ceeb116084139afab54925f: complete six-file diff, new scanner and all new/modified tests, surrounding template ownership and shell completeness paths, JavaScript execution guard, file mappings, #884 and its corrections, all review/thread/discussion records. There are no prior own marked reviews. Live head metadata still matches the inventory. Hosted lint, extension, DCO and Docker checks pass; unit CI reports 17,830 passed and 15 failed. Compared every failing identity with the hosted baseline run at e14c450b260958ed3ebd83c94c09c4b093e3e656 (run 41513800480): all 15 match exactly and concern existing PowerShell/quoted-printf tests. The new TypeScript module has no reported test failure, but the execution spelling above has no regression. This is a static ownership/candidate-suppression proof, not a runtime reproduction or complete scanner-verdict claim. No contributor code, tests, imports, builds, setup, hooks, regexes, scanner invocations or snippets were executed.

@bniladridas
bniladridas force-pushed the investigate/884-typescript-template-ownership branch from de9e5a1 to e8b516b Compare November 4, 2026 10:39
bniladridas added a commit to bniladridas/SkillSpector that referenced this pull request Nov 4, 2026
…checks

The TypeScript template scanner compared raw source bytes against the shell execution module allowlist and the shell execution call names, so an escaped specifier such as "node:child_\x70rocess" or a computed member such as cp["exec"] slipped past the checks and the file was reported as fully inspected. Decode \xNN, \uNNNN, \u{...}, the single-character and line-continuation escapes without evaluation, return None on malformed, unsupported, or partially decoded strings so the conservative read and its partial status remain, and compare decoded module specifiers and computed or dotted member names against the existing lists.

Refs NVIDIA#990

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
@bniladridas
bniladridas force-pushed the investigate/884-typescript-template-ownership branch from e8b516b to 5645cbb Compare November 4, 2026 16:06
bniladridas added a commit to bniladridas/SkillSpector that referenced this pull request Nov 4, 2026
…checks

The TypeScript template scanner compared raw source bytes against the shell execution module allowlist and the shell execution call names, so an escaped specifier such as "node:child_\x70rocess" or a computed member such as cp["exec"] slipped past the checks and the file was reported as fully inspected. Decode \xNN, \uNNNN, \u{...}, the single-character and line-continuation escapes without evaluation, return None on malformed, unsupported, or partially decoded strings so the conservative read and its partial status remain, and compare decoded module specifiers and computed or dotted member names against the existing lists. The shared call list also carries the JavaScript keyword "function", which is a declaration keyword in TypeScript and must not suppress ownership of a benign template.

Refs NVIDIA#990

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
@bniladridas
bniladridas force-pushed the investigate/884-typescript-template-ownership branch from 5645cbb to 5778ef7 Compare November 4, 2026 16:27
bniladridas added a commit to bniladridas/SkillSpector that referenced this pull request Nov 4, 2026
…checks

The TypeScript template scanner compared raw source bytes against the shell execution module allowlist and the shell execution call names, so an escaped specifier such as "node:child_\x70rocess" or a computed member such as cp["exec"] slipped past the checks and the file was reported as fully inspected. Decode \xNN, \uNNNN, \u{...}, the single-character and line-continuation escapes without evaluation, return None on malformed, unsupported, or partially decoded strings so the conservative read and its partial status remain, and compare decoded module specifiers and computed or dotted member names against the existing lists. The shared call list also carries the JavaScript keyword "function", which is a declaration keyword in TypeScript and must not suppress ownership of a benign template.

Refs NVIDIA#990

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
bniladridas added a commit to bniladridas/SkillSpector that referenced this pull request Nov 4, 2026
…checks

The TypeScript template scanner compared raw source bytes against the shell execution module allowlist and the shell execution call names, so an escaped specifier such as "node:child_\x70rocess" or a computed member such as cp["exec"] slipped past the checks and the file was reported as fully inspected. Decode \xNN, \uNNNN, \u{...}, the single-character and line-continuation escapes without evaluation, return None on malformed, unsupported, or partially decoded strings so the conservative read and its partial status remain, and compare decoded module specifiers and computed or dotted member names against the existing lists. The shared call list also carries the JavaScript keyword "function", which is a declaration keyword in TypeScript and must not suppress ownership of a benign template.

Refs NVIDIA#990

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
@bniladridas
bniladridas force-pushed the investigate/884-typescript-template-ownership branch from 5778ef7 to b15673f Compare November 4, 2026 23:01
@bniladridas

Copy link
Copy Markdown
Contributor Author

Fixed in b15673f, the second commit on the rebased branch (it was 5778ef7 before the rebase onto upstream main 62c2fe8).

Review finding: the string path compared raw bytes, so import * as cp from "node:child_\x70rocess" and cp["exec"] were not recognized and the execution template was owned.

The string path no longer compares raw bytes. _decode_string_source resolves \xNN, \uNNNN, \u{...}, the single-character and line-continuation escapes without evaluation and returns None on malformed, unsupported, or partially decoded strings, so an undecodable specifier keeps the conservative read and cannot establish or clear ownership. Decoded module specifiers after from, import, and require are checked against the allowlist, and decoded computed members such as cp["exec"] and template members such as cp[`exec`] are checked against _SHELL_EXECUTION_CALLS; dotted members are compared as written.

Regressions cover escaped module names (hex, unicode, braced unicode, escaped require, and an escaped module with a direct call), computed execution members (string, template, and upper case), malformed escapes with a shell call present, an undecodable benign string that must not claim evidence, and a non-module receiver such as labels["kind"]. Both the helper and the inspection ledger are asserted; the ledger cases expect PARTIAL with static_parse_limit.

The branch also includes the earlier fix for 583a68c0, which added "function" to the shared _SHELL_EXECUTION_CALLS. In TypeScript that is a declaration keyword, so the scanner excludes it from the comparison; without the exclusion a generic function body suppressed ownership of a benign template. test_declaration_keywords_do_not_read_as_execution_calls fails without that exclusion.

On the rebased branch b15673fd: full unit suite 20122 passed, 40 skipped, 258 deselected, 4 xfailed; ruff check src tests clean; the three analyzer test files 785 passed.

@bniladridas

Copy link
Copy Markdown
Contributor Author

Ready for re-review at b15673f.

The branch is now rebased onto upstream main at 62c2fe86, so this also resolves the merge conflict that made the PR CONFLICTING. The rebase replaced 02225879/5778ef76 with 1fe27f80/b15673fd; the diff content is unchanged apart from one ruff format line.

The execution-surface finding from the review on de9e5a1d is addressed in the string-decoding path described in the comment above, with escaped-module and computed-execution-member regressions asserted through both the helper and the inspection ledger.

On b15673fd locally: full unit suite 20122 passed, 40 skipped, 258 deselected, 4 xfailed; ruff check src tests clean; pytest -m "not integration and not provider" tests/ matches. Hosted lint, DCO Check, changes, docker-smoke and OpenCode TypeScript Tests pass; test-unit is running. The body now carries only this base's numbers.

@yashrajp22 yashrajp22 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Source review of b15673fd3fb8beab3b01b5e0b449a290b3cfeabb against 62c2fe8622f580ac292d4078c3b71f790194dbbd found four remaining template-ownership gaps, detailed inline.

I inspected the changed source, affected callers and tests. A completed Greptile review of the same comparison raised two overlapping findings, which I checked against the source. This is source-only evidence: I have not run tests or scanner reproductions, or verified fresh wheels and sample scans. Behavioral verification and the full review remain incomplete.

Comment thread src/skillspector/typescript_tokens.py Resolved
Comment thread src/skillspector/typescript_tokens.py Resolved
Comment thread src/skillspector/typescript_tokens.py Resolved
Comment thread src/skillspector/typescript_tokens.py Resolved
@bniladridas
bniladridas force-pushed the investigate/884-typescript-template-ownership branch from f4b6491 to 9db61d0 Compare November 7, 2026 16:36
bniladridas added a commit to bniladridas/SkillSpector that referenced this pull request Nov 7, 2026
…checks

The TypeScript template scanner compared raw source bytes against the shell execution module allowlist and the shell execution call names, so an escaped specifier such as "node:child_\x70rocess" or a computed member such as cp["exec"] slipped past the checks and the file was reported as fully inspected. Decode \xNN, \uNNNN, \u{...}, the single-character and line-continuation escapes without evaluation, return None on malformed, unsupported, or partially decoded strings so the conservative read and its partial status remain, and compare decoded module specifiers and computed or dotted member names against the existing lists. The shared call list also carries the JavaScript keyword "function", which is a declaration keyword in TypeScript and must not suppress ownership of a benign template.

Refs NVIDIA#990

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
@bniladridas

Copy link
Copy Markdown
Contributor Author

Commit hashes in my earlier comments and replies predate the rebase onto e48d771a, so they no longer resolve on this branch. Current mapping: 1fe27f80 → 32b79cb3, b15673fd → ead0715d, f4b64916 → 9db61d04. The fixes described in those comments are unchanged and present in all three commits; only the hashes moved.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[SkillSpector Review]
Request changes at 9db61d04fe7b847c464fdf7938678e25652cb030.

Value and readiness: Complete-source TypeScript template ownership addresses the corrected #884 reproducer and its ordinary formatting/path cases. The previous own marked review's escaped-module/computed-execution-member reproducer is addressed by decoded comparisons, with helper and ledger controls. The four later human findings are also addressed for their reported forms: exact lowercase function is distinguished from Function; loader callee context survives (; postfix ++/-- are consumed together; and shared delimiter tracking rejects the reported missing/crossed delimiters. Remaining execution-guard bypasses keep this head unready.

Material findings:

  • [P1, required] src/skillspector/typescript_tokens.py:571-594 recognizes identifiers only with the ASCII _IDENTIFIER pattern and accepts an unrecognized backslash through the punctuation fallback. Valid TypeScript \u0065val(`${payload.code}`); names the ordinary eval function, but the scanner reads the backslash as punctuation and u0065val as an unrelated identifier. No execution_name('eval') check occurs; the balanced dynamic template is returned as owned. _TypeScriptTemplateOwnership then exposes these spans through owns(), and static_patterns_tool_misuse.py:3431-3432 skips the template's conservative shell-command candidates. Decode valid identifier Unicode escapes before the execution guard, or return None when identifier escapes cannot be proven. Add escaped-identifier and escaped-member controls through both the helper and ledger. This is distinct from decoding string literals in module/property positions.
  • [P1, required] src/skillspector/typescript_tokens.py:221-222 allows a regex after every closing brace, without proving whether it closed a statement block or an expression. In valid const n = {} / eval(payload) / 2; const label = `${item.name}`;, the first slash is division after an object expression; the current walk instead skips / eval(payload) / as a regex, so the eval guard is never visited and the later dynamic template gains ownership. The added postfix-increment regression closes one form of this ambiguity but not closing object/function expressions. Track sufficient brace context, or fail closed on ambiguous slash-after-brace syntax, and add an object-expression division regression alongside the genuine regex-after-control/block positives.

PIC tradeoffs: Reducing false partial results must preserve conservative coverage when runtime code execution remains possible. These fixes should keep the demonstrated benign forms owned while withholding ownership from lexical forms the scanner cannot distinguish safely.

Verification and gaps: Reviewed the entire seven-file diff, complete new scanner/tests, surrounding exact-head template ownership/candidate-suppression callers and file mappings, #884 including its corrected trigger/impact, all normalized discussion/review/thread bodies, and the prior rng1995 marked review plus four later human followups. Hosted CI run 42392193808 has this exact head_sha and succeeds; the unit log includes the new TypeScript module and reports 21,038 passed, 24 skipped, 258 deselected and 4 xfailed. All six reported checks succeeded. Existing regressions do not cover either remaining form. Findings are static lexical/control-flow proofs, not locally reproduced scanner-verdict claims. No contributor code, tests, imports, builds, setup, hooks, regex probes or snippets were executed.

@yashrajp22 yashrajp22 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Source re-review of 9db61d04fe7b847c464fdf7938678e25652cb030 against e48d771a26f7398b36256ceb8d8f94adce3d5c44 found three remaining bugs: an execution-module decoding fallback and two regressions in delimiter tracking, detailed inline. The four original reported examples are addressed in source.

I inspected all seven changed files and affected callers/tests, then checked every suggestion from a completed Greptile review of this exact comparison. An additional slash-context gap is already reported in the existing review, so I have not duplicated it.

This is source-only evidence. I have not run candidate tests, scanner reproductions, fresh-wheel checks or corpus scans. Behavioral verification and the full review remain incomplete, including issue #884's broader JavaScript/JSX/inline-HTML requirements.

Comment thread src/skillspector/typescript_tokens.py Resolved
Comment thread src/skillspector/typescript_tokens.py Resolved
Comment thread src/skillspector/typescript_tokens.py Resolved
@bniladridas

Copy link
Copy Markdown
Contributor Author

Reproduction report for the five newest review items, run at head 9db61d04 with no source edits. Focused tests were written against typescript_template_spans directly, run, and then deleted, so the tree is clean. The existing tests/nodes/analyzers/test_typescript_template_ownership.py still passes 57 of 57 at this head, so the results below are behavioural gaps rather than test noise.

Two of the five items do not reproduce as described. Those corrections are called out per item, because a fix written from the review text alone would miss the real cause or break a passing case.

Item 5 (escaped module specifier): reproduced, but only for the identity escape

Expected: import launch from "ex\eca" still names execa, so the template literal in launch(\...`)` stays unowned.

Actual at head: owned. The guard is bypassed.

Fails before any fix: yes.

  • import launch from "ex\eca"; followed by launch(\${command.name}`);` returns a span, so it is owned. Expected unowned.
  • import launch from "\u0065xeca"; with the same call is already unowned, so the unicode-escape form of this finding is not a bug.

Cause: _decode_string_source accepts \u0065 and rejects \e. On rejection, module_string (typescript_tokens.py:248-252) falls back to testing the raw slice ex\eca, which is not a module name, and the guard misses. The fault is the raw-source fallback, not the decoder's escape table.

Smallest regression test:

def test_an_identity_escape_in_a_module_specifier_is_unowned():
    source = 'import launch from "ex\\eca";\nlaunch(`${command.name}`);'
    assert typescript_template_spans(source, lambda: None) is None

Item 6 (nested calls and arrays): reproduced

Expected: ${format(items[0])} and [format(1)] are accepted.

Actual at head: both return None and stay unowned. ${format(1)}, ${[1, 2]} and ${items[0]} are owned, so the combination of a call and a computed member is what fails.

Fails before any fix: yes, both cases.

Cause: at ] (typescript_tokens.py:504-511) the guard is delimiters.count(")") > delimiters.count("]"). The stack only ever holds openers, so count(")") is always zero and the guard never fires, while the ( opened by format( is still pending when ] arrives. The same guard also does a full-stack count on every closer, which makes nesting cost quadratic; that is a secondary concern, not the bug.

Smallest regression test: two asserts, ${format(items[0])} and ${[format(1)]}, both is not None.

Item 7 (parenthesised object in interpolation): reproduced

Expected: ${({name: item.name}).name} is accepted.

Actual at head: None, unowned. ${(x)} and ${x.y} are owned, so the object brace inside the parentheses is the trigger.

Fails before any fix: yes.

Cause: at { (typescript_tokens.py:463-470) the code appends to paren_stack. The interpolation close at } (:474-476) requires len(paren_stack) to equal the recorded boundary, and that extra append breaks the equality.

Smallest regression test: one assert, ${({name: item.name}).name} is not None. ${({})} is a useful companion, since it also returns None today.

Item 8 (unicode identifier escape): reproduced, but the named cause is incomplete

Expected: \u0065val is read as eval, so the enclosing template is unowned.

Actual at head: owned.

Fails before any fix: yes.

Cause: _IDENTIFIER (typescript_tokens.py:33) is ASCII only, so the backslash reaches the generic punctuation fallback (:593-594) and u0065val is then read as an ordinary identifier. The name never reaches execution_name, and the template in the same scan is still owned. Widening the identifier regex alone will not fix this, because the backslash is not part of any identifier token; the escaped identifier has to be decoded before classification.

One note on test shape: \u0065val(${p}) is a bad case to write, because an escaped backtick inside a template is a literal backtick and no template literal exists at all. The regression test must pass an ordinary argument.

Smallest regression test:

def test_an_identifier_escape_spelling_eval_is_unowned():
    assert typescript_template_spans("const x = `\\u0065val(payload)`;", lambda: None) is None

Item 9 (slash after braces): P1 claim reproduced; the stated control case is broken for a different reason

Expected: const n = {} / eval(payload) / 2 is division, so eval is visited and a later template is unowned; a genuine regex after a block stays a regex.

Actual at head: the P1 claim holds. const n = {} / eval(payload) / 2; followed by const label = \${item.name}`;is owned.regex_allowed()returnsTrueunconditionally for} (typescript_tokens.py:221-222), so / eval(payload) /` is consumed as a regex.

The control case does not hold today, and not because of the slash. if (ok) { run(); }\nconst r = /ab+c/g; followed by const label = \${item.name}`;is unowned, and a bare{ run(); }block with no regex at all is also unowned. The non-interpolation} branch (:487-495) resets braces = 0and never re-checks, so a top-level block close leaves the scanner unable to continue. A top-levelconst r = /ab+c/g;` on its own is owned, so regex handling itself is fine.

Consequence for the fix: narrowing regex_allowed() for } would satisfy item 9 while valid blocks stayed broken. The two must be settled together, and each fix must be tested against the other.

Smallest regression tests, both required:

def test_division_after_an_object_literal_is_unowned():
    source = "const n = {} / eval(payload) / 2;\nconst label = `${item.name}`;"
    assert typescript_template_spans(source, lambda: None) is None

def test_a_block_close_does_not_end_the_scan():
    source = "if (ok) { run(); }\nconst r = /ab+c/g;\nconst label = `${item.name}`;"
    assert typescript_template_spans(source, lambda: None) is not None

Overlap with the older brace-balance finding

The older finding about top-level brace balance and crossed delimiters was left untouched, but the block-close defect above is the same code path. It should be re-reviewed jointly with item 9 rather than fixed twice, and a fix for one must run the other's case.

Status

Item As described Reproduced Correction
5 identity escape hides the module yes the unicode-escape variant is unaffected
6 nested call and array rejected yes the same guard is also quadratic by inspection
7 parenthesised object rejected yes
8 identifier escape hides eval yes widening the regex does not fix it; decode first
9 slash after } read as regex yes the control case fails on block close, unconnected to the slash

No code was changed and no thread was resolved while producing this. The next step is to agree the corrected cases, then rebase onto current main and use these as regression tests. Items 5 to 8 need one coordinated scanner change, item 9 and the block-close defect need another, and neither should land in isolation.

@bniladridas
bniladridas force-pushed the investigate/884-typescript-template-ownership branch from 9db61d0 to 7834047 Compare November 10, 2026 23:05
bniladridas added a commit to bniladridas/SkillSpector that referenced this pull request Nov 10, 2026
…checks

The TypeScript template scanner compared raw source bytes against the shell execution module allowlist and the shell execution call names, so an escaped specifier such as "node:child_\x70rocess" or a computed member such as cp["exec"] slipped past the checks and the file was reported as fully inspected. Decode \xNN, \uNNNN, \u{...}, the single-character and line-continuation escapes without evaluation, return None on malformed, unsupported, or partially decoded strings so the conservative read and its partial status remain, and compare decoded module specifiers and computed or dotted member names against the existing lists. The shared call list also carries the JavaScript keyword "function", which is a declaration keyword in TypeScript and must not suppress ownership of a benign template.

Refs NVIDIA#990

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
bniladridas added a commit to bniladridas/SkillSpector that referenced this pull request Nov 10, 2026
… names

The bounded TypeScript template reader lost track of which bracket ends a scope, because the ``)`` and ``]`` handlers tested the other bracket's open and close counts, which are always equal once the opener has been popped, so a bracket inside a call or an array literal could end the scan early; delimiters are now stored as matched opener and closer pairs and each closer checks the pair it actually ends, and the paren boundary bookkeeping that only existed to compensate for that is removed.

A slash after ``}`` was always read as a regex, so ``const n = {} / eval(p) / 2`` skipped the call; a brace now divides. An undecodable module specifier is treated as naming the execution module instead of falling back to the raw text, and identifiers are matched with escapes and decoded before classification, so ``\u0065val(payload)`` can no longer slip past the call check while a benign escaped name stays owned. Escapes inside a template are literal text, so that regression is in code context only, and JSX attribute templates stay on the conservative path.

Refs NVIDIA#990

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
@bniladridas

Copy link
Copy Markdown
Contributor Author

Reassessment of the seven open findings against head 7834047e (rebase-990-rehearsal force-updated). Nothing below resolves a thread; the state stays request-changes.

Method: each reviewer snippet was run verbatim against typescript_template_spans and against has_bounded_parse_exhaustion(..., file_type="typescript") at 7834047e. "Executed" means I ran it and read the result in this session. "Source" means I read the code path and the named test, without executing that specific case.

Four older findings

# Reviewer scenario Expected Actual at 7834047e Regression test Status Basis
1 new Function(\${payload.code}`)();` unowned unowned; Function(...)() also unowned; lowercase function helper(${p}) {} still owned test_the_function_constructor_stays_a_shell_execution_surface, test_a_lowercase_function_declaration_is_not_an_execution_call fixed executed
2 const launch = require('execa'); launch(\${command.name}`);` unowned unowned; await import('node:child_process') unowned; require('node:fs') still owned test_a_loaded_execution_module_keeps_its_samples_unowned, test_module_loaders_checked_through_the_call_parens_keep_ownership, test_shell_execution_module_loaded_without_reaching_a_sink_is_not_claimed fixed executed
3 counter++ / eval(payload) / 2 then template unowned unowned, eval guard reached test_postfix_increment_before_a_slash_does_not_open_a_regex fixed executed
4 if (ok) { const label = \${item.name}`;` unowned unowned; crossed ([)] unowned; closed block still owned test_an_incomplete_block_does_not_claim_ownership, test_delimiters_must_nest_in_the_matching_order, test_closing_blocks_keep_later_templates_owned fixed executed

Three newer findings (threads marked outdated by the force update)

# Reviewer scenario Expected Actual at 7834047e Regression test Status Basis
5 import launch from "ex\eca"; launch(\${command.name}`);` unowned unowned at scanner level, and the analyzer still emits the parse-limit diagnostic test_an_identity_escape_in_a_module_specifier_is_unowned (scanner); analyzer path checked by hand, see note fixed executed
6 \${format(items[0])}`and`${[format(1)]}`` owned both owned, analyzer diagnostic suppressed test_a_bracket_inside_a_call_stays_owned (scanner); analyzer path checked by hand, see note fixed executed
7 \${({name: item.name}).name}`` owned owned; callback block inside an interpolation also owned; analyzer diagnostic suppressed test_a_parenthesised_object_in_an_interpolation_stays_owned (scanner); analyzer path checked by hand, see note fixed executed

Note on 5, 6, 7: the committed regressions cover the scanner directly, and I confirmed the analyzer outcome by hand. They do not yet have a committed end-to-end analyzer test the way the older findings do. If that gap matters for review I can add one.

Related coverage from this head

This is where most of the change landed, so the checks are broader:

  • Division after an object literal keeps a sink unowned (test_division_after_an_object_literal_keeps_the_sink_unowned), including the reviewer's {} / eval(...) case.
  • A division-only case, with no call present, stays owned (test_a_slash_after_an_expression_brace_divides_without_a_call). This one fails if the brace rule is reverted, so item 9 is covered on its own.
  • Escaped call names are decoded before classification (test_an_identifier_escape_spelling_eval_is_unowned, four spellings), while a benign escaped name stays owned.

Executed results

  • 7834047e is the current remote head of investigate/884-typescript-template-ownership.
  • Scanner probes: 15 of 15 match expected.
  • Analyzer probes for 5, 6, 7: 5 of 5 match expected.
  • test_typescript_template_ownership.py plus the new delimiters file: 82 passed.
  • Filtered analyzer regressions for the older findings: 11 passed.
  • Full analyzer suite at 7834047e: 13879 passed, 4 skipped, 4 xfailed, 0 failed. Ruff passes.

No code was changed for this reassessment and no commits were pushed. Implicit approval is not claimed; reviewers should confirm the fixes and close the threads themselves.

bniladridas added a commit to bniladridas/SkillSpector that referenced this pull request Nov 10, 2026
… names

The bounded TypeScript template reader lost track of which bracket ends a scope, because the ``)`` and ``]`` handlers tested the other bracket's open and close counts, which are always equal once the opener has been popped, so a bracket inside a call or an array literal could end the scan early; delimiters are now stored as matched opener and closer pairs and each closer checks the pair it actually ends, and the paren boundary bookkeeping that only existed to compensate for that is removed.

A slash after ``}`` was always read as a regex, so ``const n = {} / eval(p) / 2`` skipped the call; a brace now divides. An undecodable module specifier is treated as naming the execution module instead of falling back to the raw text, and identifiers are matched with escapes and decoded before classification, so ``\u0065val(payload)`` can no longer slip past the call check while a benign escaped name stays owned. Escapes inside a template are literal text, so that regression is in code context only, and JSX attribute templates stay on the conservative path.

Refs NVIDIA#990

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
@bniladridas
bniladridas force-pushed the investigate/884-typescript-template-ownership branch from 7834047 to c4b1abe Compare November 10, 2026 23:14
@bniladridas

Copy link
Copy Markdown
Contributor Author

Reassessment of rng1995's P1 findings at current head c4b1abed (identical to 7834047e apart from ruff format line wrapping). This is evidence for you to check, not a request to change the review state.

P1: escaped identifier escapes the execution guard

\u0065val(${payload.code});

  • Scanner: typescript_template_spans returns None, so the template is not owned.
  • End to end: skillspector scan --no-llm --format json reports status: partial and coverage_percent: 0.0, and no issue is raised from an owned template.
  • Analyzer: has_bounded_parse_exhaustion(..., file_type="typescript") returns the diagnostic, and the ledger records PARTIAL with static_parse_limit.
  • Escaped computed member, as in your requested control: cp["ex\u0065c"](${cmd}) is not owned, the same as the plain cp["exec"] form.

Existing controls:

  • test_an_identifier_escape_spelling_eval_is_unowned covers \u0065val, \x65val, ev\u0061l and \u{65}val, and test_an_identifier_escape_spelling_a_benign_name_stays_owned keeps a benign escaped name owned.
  • test_computed_execution_members_keep_the_execution_surface checks the scanner and analyzer for computed members.
  • test_ledger_keeps_partial_status_for_escaped_execution_surfaces checks the ledger outcome and reason code.

P1: slash after a closing brace

const n = {} / eval(payload) / 2; const label = ${item.name};

  • Scanner: returns None, so the template is not owned and the eval guard is visited.
  • Analyzer: returns the diagnostic, and the ledger records PARTIAL with static_parse_limit.
  • Overcorrection check, since you asked for the genuine positives to stay owned: a regex after a control block (if (ok) { render(); } then /ab+c/g) and a regex after a for body are both still owned.

Existing controls:

  • test_division_after_an_object_literal_keeps_the_sink_unowned uses your snippet plus an empty-object argument and a parenthesised object.
  • test_a_slash_after_an_expression_brace_divides_without_a_call has no call at all, so only the division reading keeps the template owned.
  • test_a_regex_after_a_block_stays_a_regex and test_a_block_close_before_a_template_keeps_the_template_owned are the benign companions.

Reverting the brace rule makes the first two fail, so the change is load bearing rather than incidental.

One note on the review text

The P1 description says regex_allowed() "allows a regex after every closing brace". Reading the code at 9db61d04, the } branch returned True, meaning a slash after a closing brace, whether the brace closed a block or an expression, was treated as starting a regex. The reported snippet and the defect agree; only the wording is inverted. Mentioning it so the write-up and the code line up for future readers, not to dispute the finding.

Verification basis

Both review snippets were run by hand at c4b1abed at the scanner, analyzer and ledger levels, and the CLI run was on a .ts file. I have not added dedicated analyzer-level regression tests for the two exact snippets; the controls listed above are the existing coverage. If you want them, I can add only those tests and leave the source untouched.

No code, threads or review state were changed for this comment.

@bniladridas
bniladridas force-pushed the investigate/884-typescript-template-ownership branch from c4b1abe to a2c6aae Compare November 12, 2026 05:12
bniladridas added a commit to bniladridas/SkillSpector that referenced this pull request Nov 12, 2026
…checks

The TypeScript template scanner compared raw source bytes against the shell execution module allowlist and the shell execution call names, so an escaped specifier such as "node:child_\x70rocess" or a computed member such as cp["exec"] slipped past the checks and the file was reported as fully inspected. Decode \xNN, \uNNNN, \u{...}, the single-character and line-continuation escapes without evaluation, return None on malformed, unsupported, or partially decoded strings so the conservative read and its partial status remain, and compare decoded module specifiers and computed or dotted member names against the existing lists. The shared call list also carries the JavaScript keyword "function", which is a declaration keyword in TypeScript and must not suppress ownership of a benign template.

Refs NVIDIA#990

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
bniladridas added a commit to bniladridas/SkillSpector that referenced this pull request Nov 12, 2026
… names

The bounded TypeScript template reader lost track of which bracket ends a scope, because the ``)`` and ``]`` handlers tested the other bracket's open and close counts, which are always equal once the opener has been popped, so a bracket inside a call or an array literal could end the scan early; delimiters are now stored as matched opener and closer pairs and each closer checks the pair it actually ends, and the paren boundary bookkeeping that only existed to compensate for that is removed.

A slash after ``}`` was always read as a regex, so ``const n = {} / eval(p) / 2`` skipped the call; a brace now divides. An undecodable module specifier is treated as naming the execution module instead of falling back to the raw text, and identifiers are matched with escapes and decoded before classification, so ``\u0065val(payload)`` can no longer slip past the call check while a benign escaped name stays owned. Escapes inside a template are literal text, so that regression is in code context only, and JSX attribute templates stay on the conservative path.

Refs NVIDIA#990

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[SkillSpector Review]

Decision: Changes Requested

Value and readiness

The TypeScript/TSX ownership path addresses #884's corrected everyday-template reproducer, and the reported prior findings are now repaired. A distinct remaining slash-context case can still hide an execution call from the ownership guard, so this revision is not ready to approve.

Material findings

[P1, required] Preserve property-name context when deciding whether / starts a regex, src/skillspector/typescript_tokens.py:218. This valid TypeScript divides by the result of an ordinary eval call:

const label = `${obj.return / eval(payload) / 2}`;

The identifier branch at :581 overwrites the preceding . context and records return as a plain identifier. regex_allowed() then classifies it using _EXPRESSION_PREFIX_WORDS, although return here is a member name and its completed member expression is the left division operand. The first slash therefore enters skip_regex, which consumes / eval(payload) / without visiting execution_name('eval'). The remaining interpolation and source delimiters balance, so the enclosing dynamic template receives an owned span. _TypeScriptTemplateOwnership exposes that span through owns(), and static_patterns_tool_misuse.py:3767 skips the template's shell-command candidates. This drops the conservative completeness evidence that the execution guard is intended to preserve. Retain the token's member/keyword role, or fail closed when that role is uncertain, and add dotted-keyword division cases through both the span helper and ledger, with genuine keyword/regex controls. The new brace and postfix controls do not cover this context. This is a static lexical/caller trace, not a locally executed scanner-verdict claim.

All prior required examples were checked and are resolved rather than repeated: escaped module/computed members; exact lowercase function versus Function; loader context through (; postfix ++/--; unmatched/crossed delimiters; undecodable module fallback; call/array delimiter pairing and nested interpolation objects; escaped identifiers; and slash-after-object-brace handling. Their source guards and committed regression cases remain present.

PIC tradeoffs

The stated scope can remain TypeScript/TSX; JavaScript/JSX and inline HTML follow separate paths. Improving completeness must still retain conservative coverage when lexical ambiguity could hide execution. No new public-output policy decision is needed for the correction above.

Verification and gaps

Reviewed the complete actual diff, full new scanner and both test files, changed ownership/file-mapping callers and adjacent context, exact-head shared JavaScript execution-name list, #884 plus all corrected-trigger/impact followups, every prior review/reply/discussion and thread state, and all six successful hosted checks. Seven substantive external review threads remain unresolved despite the source corrections. Pre-fetch, post-fetch and post-review heads match the frozen inventory. Author runtime and mutation-test reports were read as supplied evidence, not independently reproduced. No contributor code, tests, imports, builds, hooks, scanner, regex probes or model calls were executed.

Reviewed head: a2c6aae98a36d82420cdefbf1fb3f753eeb2587f.

bniladridas added a commit to bniladridas/SkillSpector that referenced this pull request Nov 13, 2026
…regex

After a dot, ``return``, ``delete``, and ``typeof`` are property names, not expression prefixes, but the scanner classified the identifier by spelling alone, so ``${obj.return / eval(payload) / 2}`` read the middle slash as a regex opener, skipped the ``eval`` call, and claimed the template; the same hole existed after ``#`` for private names such as ``this.#return``. Track whether the last identifier followed ``.`` or ``#`` and let that member flag veto the keyword set before the slash decision. Add span-helper regressions for the three dotted keywords, the same cases through the inspection ledger, a private-name case, and controls that keep member division benign and a genuine keyword regex a regex; the new cases fail on the previous revision.

Refs NVIDIA#990

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
@bniladridas

Copy link
Copy Markdown
Contributor Author

Progress update at b4c142b9.

The latest P1 finding is fixed: after . or #, an identifier is a property name even when it spells a keyword, so ${obj.return / eval(payload) / 2} divides and reaches the eval guard. Regressions cover the span helper, the inspection ledger, a private name, and genuine keyword regex controls.

All seven review threads have current-head evidence and are resolved. The cited regressions pass here, including the analyzer-level outcomes for the three newer findings.

CI on b4c142b9: changes, lint, DCO, OpenCode TypeScript Tests and docker-smoke pass. test-unit is still running, so this is not a merge-readiness claim.

This is a progress update, not a self-approval. Maintainers should make the formal decision.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[SkillSpector Review]

Decision: Changes Requested

Value and readiness

Everyday TypeScript templates benefit from ownership proof. The direct keyword-property correction is present. The proof still treats a related member call as a control statement, so the execution boundary needs another correction.

Material findings

Required — src/skillspector/typescript_tokens.py:454–470. The opening parenthesis records a control head solely from the identifier text, even after the new identifier branch has recorded that the name is a member. In a valid expression such as obj.if() / eval(input) / 2 inside a template interpolation, the first closing parenthesis sets last_closed_control to true. The slash then starts the regex-skip path at lines 229–230 and 441–450. It skips the execution-name check for the expression between the slashes and can grant ownership to the enclosing template. Use the recorded member role in the control-head decision, or withhold ownership when the role cannot be established. Add a member-call division regression through both the span helper and the completeness ledger, with a genuine control-head regex as the positive control.

The prior direct keyword-property case and the earlier delimiter, escaped-name and module safeguards remain covered by the current code and tests. No duplicate thread is needed.

PIC tradeoffs

None requiring a separate decision. The stated scope remains TypeScript template ownership with a conservative fallback.

Verification and gaps

Compared the complete current feature diff with the fully reviewed previous feature diff. Read the changed lexer state and test cases, the caller ownership path, current review threads and author reply. Six hosted checks succeeded. Findings follow the source control flow. No contributor code, tests or scanner were executed locally.

Reviewed head: b4c142b9ac156f6bd41fd1e0686e0746b3adbd41.

Add a bounded TypeScript template scanner used only when the whole file is available. Benign template literals no longer borrow shell backtick ownership, while tagged templates, shell execution surfaces, non-host shebangs, malformed delimiters, and ambiguous regex/division syntax stay on the conservative path.

Map .tsx files to TypeScript so the same path applies to TSX sources.

Refs NVIDIA#884

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
…checks

The TypeScript template scanner compared raw source bytes against the shell execution module allowlist and the shell execution call names, so an escaped specifier such as "node:child_\x70rocess" or a computed member such as cp["exec"] slipped past the checks and the file was reported as fully inspected. Decode \xNN, \uNNNN, \u{...}, the single-character and line-continuation escapes without evaluation, return None on malformed, unsupported, or partially decoded strings so the conservative read and its partial status remain, and compare decoded module specifiers and computed or dotted member names against the existing lists. The shared call list also carries the JavaScript keyword "function", which is a declaration keyword in TypeScript and must not suppress ownership of a benign template.

Refs NVIDIA#990

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
Four review findings let the bounded TypeScript template reader claim ownership of byte ranges it had not proven:

- The casefolded call-name comparison folded ``Function`` into the ``function`` declaration keyword, so ``new Function(`${code}`)()`` was owned. Only the exact lowercase keyword is a declaration now.
- The ``(`` handler overwrote the last token, so module specifiers in ``require(...)`` / ``import(...)`` were never compared with the execution-module list. The callee name now survives the paren.
- A collided ``+`` left ``+`` as the last token, so ``counter++ / eval(p) /`` read as a regex and skipped the ``eval`` guard. Postfix ``++``/``--`` are consumed as one token.
- Brace balance was only tracked in interpolation mode and delimiter nesting was never ordered, so an incomplete block or a crossed ``([)]`` still returned spans. A shared delimiter stack now rejects both.

Each finding has a regression that fails on the previous revision and passes here; the benign guards stay owned.

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
… names

The bounded TypeScript template reader lost track of which bracket ends a scope, because the ``)`` and ``]`` handlers tested the other bracket's open and close counts, which are always equal once the opener has been popped, so a bracket inside a call or an array literal could end the scan early; delimiters are now stored as matched opener and closer pairs and each closer checks the pair it actually ends, and the paren boundary bookkeeping that only existed to compensate for that is removed.

A slash after ``}`` was always read as a regex, so ``const n = {} / eval(p) / 2`` skipped the call; a brace now divides. An undecodable module specifier is treated as naming the execution module instead of falling back to the raw text, and identifiers are matched with escapes and decoded before classification, so ``\u0065val(payload)`` can no longer slip past the call check while a benign escaped name stays owned. Escapes inside a template are literal text, so that regression is in code context only, and JSX attribute templates stay on the conservative path.

Refs NVIDIA#990

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
…regex

After a dot, ``return``, ``delete``, and ``typeof`` are property names, not expression prefixes, but the scanner classified the identifier by spelling alone, so ``${obj.return / eval(payload) / 2}`` read the middle slash as a regex opener, skipped the ``eval`` call, and claimed the template; the same hole existed after ``#`` for private names such as ``this.#return``. Track whether the last identifier followed ``.`` or ``#`` and let that member flag veto the keyword set before the slash decision. Add span-helper regressions for the three dotted keywords, the same cases through the inspection ledger, a private-name case, and controls that keep member division benign and a genuine keyword regex a regex; the new cases fail on the previous revision.

Refs NVIDIA#990

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
A keyword after `. ` or `#` is a member name, so `obj.if()` is a call rather than a statement head. The opening paren still recorded a control head from the identifier text, and the matching close then let the following slash open a regex that skipped `eval(input)` and claimed the template. Include the recorded member role in the control-head decision. Add member-call division regressions through the span helper and the completeness ledger, plus a genuine `if (...)` regex control. Rebase onto current main also moved module matching into `javascript_callables` and switched this test to the native parser, so import the shared matcher and use a valid lone-surrogate escape in the undecodable-string case. Refs NVIDIA#884.

Signed-off-by: Niladri Das <125604915+bniladridas@users.noreply.github.com>
@bniladridas
bniladridas force-pushed the investigate/884-typescript-template-ownership branch from b4c142b to 7ce5e95 Compare November 20, 2026 04:37
@bniladridas

Copy link
Copy Markdown
Contributor Author

Rebased onto 48e0f942 and fixed the member-call control-head path. obj.if() no longer marks a control head, so the slash divides and eval(input) is checked; regressions cover the span helper, the ledger, and a genuine if (ok) regex. Local targeted tests (1148), analyzer suite (16928), lint and format pass; test-unit is still running.

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