fix(mitm): exact host membership in MITM hosts test (CodeQL false positive) (#4386)

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.
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-06-20 10:21:55 -03:00
committed by GitHub
parent 0db0437fe7
commit fe70c4c5ad
2 changed files with 9 additions and 1 deletions

View File

@@ -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

View File

@@ -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"), []);
});