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:
parent
e7729d0a1e
commit
dd6e4f4f8a
89 changed files with 316 additions and 213 deletions
|
|
@ -1,6 +1,7 @@
|
|||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
const { lit } = require('../scripts/lib/js-literal');
|
||||
|
||||
function setup(t) {
|
||||
const h = load();
|
||||
|
|
@ -148,7 +149,7 @@ test('boxes follow the traffic each city really sends: Russia and China have the
|
|||
// Goggle is throttled to half in Russia.
|
||||
assert.ok(Math.abs(ev("cacheDem('mmk','ggl')/cacheDem('mmk','akm')") - ev('NSH_RU.ggl*0.5/NSH_RU.akm')) < 1e-9);
|
||||
// In China only the networks on its own list get boxes.
|
||||
for (const id of nets('sha')) assert.ok(ev(`NSH_CN[${JSON.stringify(id)}]>0`), `${id} reaches Shanghai`);
|
||||
for (const id of nets('sha')) assert.ok(ev(`NSH_CN[${lit(id)}]>0`), `${id} reaches Shanghai`);
|
||||
// Elsewhere nothing changes: the world share.
|
||||
assert.ok(Math.abs(ev("cacheDem('fra','nfx')") - ev('(R.cityDem.fra||0)*NSH.nfx')) < 1e-6);
|
||||
assert.deepEqual(errors, []);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue