From fe70c4c5adbf7ac2807a2caab3de3e08cbc695df Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza <8016841+diegosouzapw@users.noreply.github.com> Date: Sat, 20 Jun 2026 10:21:55 -0300 Subject: [PATCH] fix(mitm): exact host membership in MITM hosts test (CodeQL false positive) (#4386) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getMitmToolHosts returns string[], so .includes(host) is Array.prototype.includes (exact membership). CodeQL's js/incomplete-url-substring-sanitization heuristic misreads it as a String.includes() URL-substring sanitization check and raises a HIGH alert. Switch to .some(h => h === host) — identical semantics, explicit intent, no flagged pattern. Surfaced post-v3.8.30 (#4325) once the test landed on main. Test-only change (no runtime behavior); the suite still passes and the CodeQL re-scan on merge clears the alert. --- CHANGELOG.md | 4 ++++ tests/unit/mitm-tool-hosts.test.ts | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad75f22224..fe198feac1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ _In development — bullets added per PR; finalized at release._ +### 🔒 Security + +- **fix(mitm): exact host membership in the MITM hosts test (CodeQL false positive)** — `tests/unit/mitm-tool-hosts.test.ts` checked host membership with `Array.includes(host)`, which CodeQL's `js/incomplete-url-substring-sanitization` heuristic misreads as a `String.includes()` URL-substring sanitization test (HIGH false positive). Switched to `.some((h) => h === host)` — identical semantics, no flagged pattern. ([#4386](https://github.com/diegosouzapw/OmniRoute/pull/4386)) + --- ## [3.8.30] — 2026-06-20 diff --git a/tests/unit/mitm-tool-hosts.test.ts b/tests/unit/mitm-tool-hosts.test.ts index 9023cfabf7..84a22f17b6 100644 --- a/tests/unit/mitm-tool-hosts.test.ts +++ b/tests/unit/mitm-tool-hosts.test.ts @@ -21,6 +21,10 @@ test("MITM_TOOL_HOSTS stays in sync with the canonical MITM target registry", () }); test("getMitmToolHosts returns the hosts for a known tool and [] for unknown ids", () => { - assert.ok(getMitmToolHosts("antigravity").includes("cloudcode-pa.googleapis.com")); + // Exact host membership in the returned string[] — `.some(h => h === host)` rather than + // `.includes(host)` so CodeQL's js/incomplete-url-substring-sanitization heuristic does not + // misread an Array.prototype.includes() membership check as a String.includes() URL-substring + // test. Same semantics (the array contains exactly this host), explicit about intent. + assert.ok(getMitmToolHosts("antigravity").some((h) => h === "cloudcode-pa.googleapis.com")); assert.deepEqual(getMitmToolHosts("does-not-exist"), []); });