Skip to content

[bug] eval regex flags Puppeteer $eval/$$eval and member methods #2913

Description

@rasimme

Affected surface

Plugin Scanner and the GitHub Action that packages it.

What happened?

The code-quality rule reports DANGEROUS_DYNAMIC_EXECUTION for Puppeteer page.$eval(...), page.$$eval(...), and any member call named object.eval(...). None of these is a bare/global JavaScript eval(...) call, and the example below contains no new Function(...).

The current matcher is EVAL_RE = re.compile(r"\beval\s*\(") in checks/code_quality.py. Because $ and . are non-word characters, all three member/identifier forms match the same regex.

Expected: retain a high-severity finding for an actual bare/direct eval(...) call and for new Function(...), but do not infer dynamic code execution solely from $eval, $$eval, or a member property named eval.

Minimal reproduction

Save this as fixture.js in a scan target:

export async function inspect(page) {
  const status = await page.$eval("#status", (node) => node.textContent);
  const count = await page.$$eval(".item", (nodes) => nodes.length);

  const object = { eval: () => "ordinary method" };
  object.eval();

  return { status, count };
}

Then run:

plugin-scanner scan .

All three call sites are classified as DANGEROUS_DYNAMIC_EXECUTION / “Dynamic code execution detected” by the regex, despite there being no bare eval(...) or new Function(...) call.

A token- or AST-aware callee check could distinguish a direct identifier named exactly eval from Puppeteer's $eval/$$eval identifiers and member-expression properties. Regression coverage could keep bare eval(...) and new Function(...) positive while making the three examples above negative.

Environment and downstream impact

This was reproduced with Plugin Scanner 3.0.123 through the catalog-pinned action while reviewing awesome-ai-plugins PR #288. The catalog report currently treats the resulting high-severity findings as part of the remediation required before review.

Once corrected, could you please identify:

  1. the Plugin Scanner release containing the fix;
  2. the hashgraph-online/ai-plugin-scanner-action release/commit that consumes it; and
  3. the supported way to rerun or request a rerun of the catalog scan for PR feat(dashboard): simplify queue UX, home dashboard, and watched-app setup #288?

No suppression or lower severity is requested; the goal is to preserve detection of real dynamic execution while avoiding these syntactic false positives.

Logs

Representative finding:

DANGEROUS_DYNAMIC_EXECUTION (high)
Dynamic code execution detected
<file> uses eval() or new Function().

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions