Skip to content

DevGuard v1.3.0 — AST Virtual Folding & Resilient Evasion Defense Engine

Latest

Choose a tag to compare

@OkyWoww OkyWoww released this 19 Nov 06:43

What's Changed in DevGuard v1.3.0

DevGuard v1.3.0 introduces the Lexical Constant Folding Engine (Pass-V & SpanMap), Non-Scoring Dynamic Import Visibility (DG004-DYN-01/02), and hardened Anti-Evasion Detectors (DG008-EV-01 & DG005-EV-01), while maintaining a strict Zero-Runtime Dependency policy ("dependencies": {}).


🚀 Highlights

Lexical Constant Folding Engine & Virtual View (Pass-V & SpanMap)

  • Deterministic Virtual Folding (FOLD-03 → FOLD-01 → FOLD-02 → FOLD-04): Synthesizes virtual source code V to defeat lexical evasion—including string concatenation ("ch" + "ild_process"), no-interpolation backtick templates, string array .join(), and safe bracket-to-dot member access (obj["member"]).
  • Strict $O(\log N)$ Coordinate Mapping (SpanMap): Binary-search interval mapping accurately projects folded virtual [line, endLine] spans back to original source positions O for GitHub PR inline review suggestions, inline suppressions, and SARIF reporting ([via-fold]).
  • Multi-Tiered DoS Guards & Priority Budgeting: Enforces hard deterministic caps (MAX_FOLD_DEPTH = 4, MAX_FOLD_OPERANDS = 64, MAX_FOLDED_LENGTH = 4096, MAX_FOLD_EDITS = 2000, MAX_BACKSCAN = 256) with priority scheduling for security-sensitive sinks and deduplicated SARIF fold_limit_exceeded (level: "note") notifications.

Non-Scoring Dynamic Import & Require Visibility (DG004-DYN-01 & DG004-DYN-02)

  • Runtime Specifier Visibility: Detects non-literal import(expr) and require(expr) calls (with local require shadow guard) to surface dynamic dependency loading without penalizing repository health scores (severity: "warning", properties.scoring: false).
  • Linear-Time Allowlist Matching: Evaluates base-branch .devguard.json path rules using linear-time glob matching (matchLinearGlob) immune to ReDoS backtracking.

Anti-Evasion Detectors (DG008-EV-01 & DG005-EV-01)

  • DG008-EV-01: Detects unbounded asynchronous do { ... } while (true | 1) loops with scope-aware nested break/return stripping and retry-counter mutation validation.
  • DG005-EV-01: Detects swallowed Promise .catch(() => {}) rejections across critical transaction, authentication, and database receiver chains while respecting immediate cleanup calls (unlink, rmSync, close, JSON.parse).

Precision & Usability Enhancements

  • False Positive Hardening: Eliminated false positives on benign RegExp.prototype.exec(), DOM helpers (page.$eval()), and JS/TS method declarations (async exec() {}), and expanded DG004 coverage for 2-argument import() and multi-line folded imports.
  • Expanded File Discovery & Coverage Telemetry: Added automatic support for .mjs, .cjs, .mts, and .cts, explicit partial coverage reporting for .py, and N/A score semantics when 0 code files are analyzed.
  • CLI & CI Reliability: Added --version / -v CLI flag support and deterministic in-process test execution across Linux (Node 22) and Windows.

📊 Benchmark & Validation Metrics

  • Corpus Benchmark: Evaluated across 129 curated test cases (48 TP, 63 TN with 0 corpus false positives, 18 EVASION vectors, and 6 newly solved evasions).
  • Pass-O vs Pass-O+V Performance Gate: +8.21% median overhead across the full 129-case corpus (+1.44% on non-fold baseline cases), well within the <= +25% release gate.
  • External OSS Validation: Audited 10 public JS/TS repositories (4,318 analyzed files) offline with 0 crashes and 0 analysis failures.
  • Test Suite: 82/82 passing scenarios (Corpus Benchmark + Tests 1–81 integration suite).
  • Runtime Dependencies: 0 ("dependencies": {}).