Skip to content

Extraction hardening: typescript #815

Closed

Description

@squid-protocol

Part of the extraction-hardening epic (#813). See
tests/extraction/how_to_harden_extraction.md
for the full methodology this issue follows.

Language: typescript

Known finding to fix first

func_start false-positive-matches a single-line string literal containing function-shaped text (e.g. let query = "function Foo() {";). Root cause is architectural, not javascript-specific: detector.py's _slice_by_braces computes func_start.finditer(code) against the raw code, before building the string/comment-shielded safe_code used later for the brace search. This affects every language routed through _slice_by_braces (Mode B), not just javascript/typescript -- if fixing this as part of this issue, consider whether it should instead be its own small architectural PR that both this and the typescript issue reference, rather than fixed twice.

Additionally, func_start also false-positive-matches type Foo = (a: T) => R; (a type alias) as if it were a real arrow-function assignment -- this one IS typescript-specific (no exclusion for a preceding type keyword) and should be fixed directly in this issue.

Rules in scope (non-None in LANGUAGE_DEFINITIONS["typescript"]["rules"]):

  • func_start
  • args
  • class_start
  • _dependency_capture

Checklist (per the methodology doc, for each in-scope rule above)

  • valid: modern idiom + legacy/historical syntax eras + testing-framework-shaped functions
  • invalid: string-literal lookalikes, type-level lookalikes, assignment-in-condition, macro-expansion lookalikes, and any language-specific lookalike shape
  • pathological: 10-15 cases covering annotation/attribute stacking, nested generics/templates, destructured/complex params, multi-line splits at every plausible boundary
  • Every case empirically verified against the real compiled regex before being added
  • Any genuine bug found is fixed (full ReDoS/lint/type/crucible discipline) or filed separately if it's a multi-language architectural fix
  • Migrated out of the four old monolithic dict files into tests/extraction/languages/test_typescript.py
  • Epic updated with any new recurring-bug-class findings before closing this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    core-enginetesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions