Fix CodeQL code-scanning alerts

- Values pasted into eval'd or inline-script code go through lit() (scripts/lib/js-literal.js), which escapes <, >, /, U+2028 and U+2029 after JSON.stringify
- build test and i18n-check read script tags with a DOM parser or a plain search, not HTML regexes
- mcp.js parses the Authorization header without a backtracking regex
This commit is contained in:
Frederic Jung 2026-11-05 21:24:26 +01:00
parent e7729d0a1e
commit dd6e4f4f8a
No known key found for this signature in database
89 changed files with 316 additions and 213 deletions

View file

@ -9,6 +9,7 @@ const os = require('node:os');
const path = require('node:path');
const page = require('../scripts/lib/page');
const { openPage, playGame } = require('../scripts/lib/route-fuzz');
const { lit } = require('../scripts/lib/js-literal');
function pages() {
const head = path.join(os.tmpdir(), `tubes-fuzz-test-${process.pid}-head.html`);
@ -29,7 +30,7 @@ test('random games route the same as main, with and without the routing cache, m
// Seeds that start a normal game, a sandbox, a scenario and a puzzle, with transit, exchanges, PNIs and RouteScript.
for (const seed of [20, 23, 27, 26]) {
const g = playGame(P, seed, { moves: 35 });
assert.equal(g.div, null, `seed ${seed} diverged: ${JSON.stringify(g.div, null, 1)}`);
assert.equal(g.div, null, `seed ${seed} diverged: ${lit(g.div, null, 1)}`);
assert.ok(g.moves >= 35, `seed ${seed} played its moves`);
assert.deepEqual(g.errors, [], `seed ${seed}: no page errors`);
}