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
|
|
@ -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');
|
||||
|
||||
// Frankfurt has the eyeballs and no transit; all transit is in Amsterdam, 100G of wave away.
|
||||
const remoteTransit = (ev, flip) => {
|
||||
|
|
@ -50,7 +51,7 @@ test('fourteen attacks on a big network keep the save small, and 2.0 saves with
|
|||
const fs = require('node:fs'), path = require('node:path');
|
||||
const fx = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures', 'big-network.json'), 'utf8'));
|
||||
const { ev, errors } = load({ seed: 3 });
|
||||
ev(`S=migrate(JSON.parse(${JSON.stringify(JSON.stringify(fx.S || fx))}));UI.started=true;compute()`);
|
||||
ev(`S=migrate(JSON.parse(${lit(JSON.stringify(fx.S || fx))}));UI.started=true;compute()`);
|
||||
const before = ev('JSON.stringify(S).length');
|
||||
ev("S.day=Math.max(S.day,50);for(let i=0;i<14;i++){S.ddosStarts=[];ddosAttack(false);}compute()");
|
||||
assert.equal(ev('ddosAll().length'), 14);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue