Update the browser, editor, settings, and installer
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { addressInput, webUrl, publicAddress, resolvePublic } from '../src/policy.mjs';
|
||||
|
||||
test('addresses reject active schemes, credentials, controls and malformed URLs', () => {
|
||||
for (const url of ['javascript:alert(1)', 'file:///etc/passwd', 'data:text/html,hi', 'runestone-ui://shell', 'https://user:[email protected]', 'https://example.com\n']) assert.throws(() => webUrl(url));
|
||||
assert.equal(addressInput('a & b'), 'https://duckduckgo.com/?q=a%20%26%20b');
|
||||
assert.equal(addressInput('example.com'), 'https://example.com/');
|
||||
assert.equal(addressInput(''), 'about:blank');
|
||||
assert.equal(addressInput('test query', 'bing'), 'https://www.bing.com/search?q=test%20query');
|
||||
});
|
||||
test('private, mapped, multicast and reserved addresses are blocked', () => {
|
||||
for (const address of ['127.0.0.1', '10.0.0.1', '169.254.169.254', '192.168.1.2', '172.31.0.1', '100.64.1.1', '0.0.0.0', '224.0.0.1', '::1', '::', 'fc00::1', 'fe80::1', '::ffff:127.0.0.1', '2001:db8::1']) assert.equal(publicAddress(address), false, address);
|
||||
assert.equal(publicAddress('1.1.1.1'), true);
|
||||
assert.equal(publicAddress('2606:4700:4700::1111'), true);
|
||||
});
|
||||
test('DNS policy rejects mixed public/private answers and pins a validated result', async () => {
|
||||
await assert.rejects(resolvePublic('example.test', async () => [{ address: '1.1.1.1', family: 4 }, { address: '127.0.0.1', family: 4 }]));
|
||||
let calls = 0;
|
||||
const address = await resolvePublic('example.test', async () => { calls++; return [{ address: '1.1.1.1', family: 4 }]; });
|
||||
assert.equal(calls, 1); assert.equal(address.address, '1.1.1.1');
|
||||
});
|
||||
Reference in New Issue
Block a user