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

@ -2,6 +2,7 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { load } = require('./harness');
const { lit } = require('../scripts/lib/js-literal');
const start = (ev) => ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=1e9;for(const g of GOALS)S.done[g.id]=0");
@ -11,7 +12,7 @@ test('each network operators\' meeting only comes to a city where it really meet
// the conference calendar
assert.deepEqual(JSON.parse(ev("JSON.stringify(CONFS.filter(cf=>!nogOk(cf.n,cf.c)).map(cf=>cf.n+'@'+cf.c))")), []);
// the rules themselves, on cities people know
const ok = (n, c) => ev(`nogOk(${JSON.stringify(n)},${JSON.stringify(c)})`);
const ok = (n, c) => ev(`nogOk(${lit(n)},${lit(c)})`);
for (const c of ['chi', 'ash', 'sea', 'hnl']) assert.ok(ok('NANOG 99', c), `NANOG in ${c}`);
for (const c of ['lon', 'tor', 'mex']) assert.ok(!ok('NANOG 99', c), `no NANOG in ${c}`);
for (const c of ['sin', 'tok', 'syd', 'akl', 'bom', 'suv']) assert.ok(ok('APRICOT 2027', c), `APRICOT in ${c}`);