Repository navigation
Description
Summary
In javascript_tokens.py, _has_shell_execution_call() decides whether a JavaScript file has a shell-execution surface. When it returns True, javascript_template_spans() leaves every template literal in the file unresolved. The file is then reported as partially inspected, and a SKILL.md that references it gets AE1 "Incomplete referenced artifact analysis" (HIGH).
Two common, non-executing patterns make _has_shell_execution_call() return True:
RegExp.prototype.exec: any member call namedexecmatches_SHELL_EXECUTION_CALLS, even when the receiver is a regular-expression literal.- A template literal passed to an imported helper: any imported identifier that receives a template literal argument is treated as a possible executor, even when the helper is a sibling module inside the same bundle and has no execution surface.
In both cases a one-file change that keeps the program semantics identical takes a minimal skill from SAFE to CAUTION with a HIGH finding.
This looks related to, but distinct from, #884 (the printf-substitution path in static_patterns_tool_misuse). The repros below differ only in the exec call or the import, and the template literals are identical, so the deciding factor here is _has_shell_execution_call().
Environment
- SkillSpector v2.13.4 (tag
v2.13.4, commit54824463) - Python 3.14.3, Windows 11
skillspector scan <dir> --no-llm --format json
Reproducer 1: regex literal .exec()
SKILL.md
---
name: date-format-demo
description: Formats an ISO calendar date (YYYY-MM-DD) as YYYY/MM/DD. Use when the user asks to reformat a date.
---
# Date format demo
Run `node scripts/format-date.mjs 2026-01-31` and show the printed result to the user.scripts/format-date.mjs
export function formatDate(text) {
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text);
return m ? `${m[1]}/${m[2]}/${m[3]}` : null;
}
console.log(formatDate(process.argv[2] ?? ''));Control variant: change only the second line to const m = text.match(/^(\d{4})-(\d{2})-(\d{2})$/);.
| Variant | Score | Recommendation | Coverage | Findings |
|---|---|---|---|---|
/.../.exec(text) |
25 MEDIUM | CAUTION | 50.0% (1 full, 1 partial) | AE1 HIGH: scripts/format-date.mjs (partial) |
text.match(/.../) |
0 LOW | SAFE | 100.0% (2 full) | none |
Reproducer 2: template literal passed to an imported helper
SKILL.md
---
name: greeting-demo
description: Prints a short greeting for a given name. Use when the user asks for a greeting.
---
# Greeting demo
Run `node scripts/greet.mjs Ada` and show the printed result to the user.scripts/format.mjs
export function formatMessage(text) {
return text.trim();
}scripts/greet.mjs
import { formatMessage } from './format.mjs';
console.log(formatMessage(`Hello, ${process.argv[2] ?? 'world'}`));Control variant: define the same formatMessage function locally in greet.mjs instead of importing it.
| Variant | Score | Recommendation | Coverage | Findings |
|---|---|---|---|---|
imported formatMessage |
25 MEDIUM | CAUTION | 66.7% (2 full, 1 partial) | AE1 HIGH: scripts/greet.mjs (partial) |
local formatMessage |
0 LOW | SAFE | 100.0% (3 full) | none |
Unit-level probe
from skillspector.javascript_tokens import parse_javascript_source, _has_shell_execution_call
noop = lambda: None
def probe(src):
return _has_shell_execution_call(parse_javascript_source(src, noop), noop)| Source (abridged) | Result |
|---|---|
const m = /^(\d{4})-(\d{2})$/.exec(t); return m ? `${m[1]}` : null; |
True |
const m = t.match(/^(\d{4})-(\d{2})$/); return m ? `${m[1]}` : null; |
False |
const DAY = /^(\d{4})$/; const m = DAY.exec(t); return m ? `${m[1]}` : null; |
True |
return /^\d+$/.test(t) ? `n:${t}` : null; |
False |
import { formatMessage } from './format.mjs'; formatMessage(`Hello, ${name}`) |
True |
import { formatMessage } from './format.mjs'; formatMessage('Hello, ' + name) + `!` |
False |
function formatMessage(s) { return s.trim(); } formatMessage(`Hello, ${name}`) |
False |
Where it comes from (v2.13.4)
_SHELL_EXECUTION_CALLS(javascript_tokens.py:1477) includesexec. The identifier and property scan in_has_shell_execution_call()(around lines 1709-1726) returnsTruefor anyproperty_identifierspelledexecunder amember_expression, without looking at the receiver. Themember_expressioncallee branch (around lines 1761-1764) has the same effect.- The imported-callable branch (around lines 1775-1787) returns
Truewhenever an imported identifier receives atemplate_stringargument, or an identifier bound to one. The inline comment explains this is a deliberate fail-closed choice ("does not claim interprocedural argument-flow analysis"), and I understand the rationale.
Suggested directions
- Receiver-aware
exec: do not treat.exec(...)as shell execution when the receiver is aregexliteral node, or an identifier whose only binding is a regex literal ornew RegExp(...). This keepschild_process.exec,cp.execand unknown receivers fail-closed while removing the most common JavaScript idiom from the trigger set. - Bundle-local imports: for relative imports that resolve to a file inside the scanned skill, reuse the callee module's own
_has_shell_execution_call()result, or an exported-function summary, instead of assuming the worst. Imports from shell modules, packages, unresolved paths or dynamic specifiers would stay fail-closed. - Report the reason: if the conservative behaviour is kept, surfacing the decisive trigger in the ledger entry would let skill authors see why a file is partial. For example,
shell_surface: member "exec" at 2:41orshell_surface: imported callable "formatMessage" received template literal.
Related: calling a function parameter (for example a Promise resolve callback) also marks the file as shell-executing through the uncertain-binding path. That is consistent with the documented intent for injected parameters, so I mention it only because it compounds with the cases above in real modules.
Workaround concern
Today the practical workarounds are to rewrite re.exec(s) as s.match(re) (fine and idiomatic), or to restructure helpers so no template literal reaches an imported function. The second pushes authors toward code shaped around the analyzer rather than toward clearer code, which seems contrary to the goal of making skills easier to analyze correctly.
Happy to test a patch or provide more cases.
Activity
Varshith-Kali commentedon Nov 9, 2026
I can take this one. _has_shell_execution_call() treats any member call named exec as shell execution without checking the receiver, so /.../.exec(text) on a regex literal scores AE1 HIGH. I will make exec receiver-aware (ignore regex-literal and regex-bound receivers, keep child_process.exec, cp.exec and unknown receivers fail-closed) with regression tests.
yunze7373 commentedon Nov 9, 2026
Thanks for picking this up. I tested #1072 (
550b782c) against the cases from this issue. The bound forms (const re = /.../; re.exec(...)andnew RegExp(...).exec(...)) are now owned.cp.exec(...)and unknown receivers stay fail-closed. The literal form already passes onmain.Some data for direction 2, which #1072 intentionally leaves open. I traced which
return Truebranch fires for every.mjsfile in a real ~25-module skill on the #1072 branch:import fs from 'node:fs'; fs.writeFileSync('out.txt', `${x}\n`)Trueimport fs from 'node:fs'; fs.writeFileSync('out.txt', String(x) + '\n')Falseimport path from 'node:path'; path.join(`${d}`, 'x')TrueA narrow first step for direction 2 could be to treat default/namespace imports from non-executing Node built-ins (
node:fs,node:fs/promises,node:path,node:os,node:url,node:crypto,node:util, ...) as owned receivers.child_process,vm,worker_threadsand module loaders would stay fail-closed. Bundle-local relative imports could follow later.The remaining 5 files come from the uncertain-binding branch:
new Promise((resolve, reject) => ... resolve(v))).max = Number.MAX_SAFE_INTEGER, are recorded as uncertain bindings.fix(analyzer): ignore regex .exec() when detecting shell execution (N…
fix(analyzer): ignore regex .exec() when detecting shell execution (N…