mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
Answer a test's HTTPS request without echoing it back.
CodeQL alert #583 (js/reflected-xss): tests/httpsServer.test.cjs's server answered `served ${req.url} ...`, sending the request back as the body. It now names the page by comparison, as plain text. tests/noReflectedRequest.test.cjs keeps the shape out of every file: no res.end/res.write/res.send writes a request's url, query, params, headers or body into the response. Test code only, so nothing for Admin Panel / Problems to record. Thanks to GitHub CodeQL and xet7 !
This commit is contained in:
1 parent
b8a6fc371b
commit
73fcfb8545
2 files changed
+57
-1
No files matched your search
@@ -51,7 +51,14 @@ test('the redirect keeps only the path, and names a host the browser asked for o
|
||||
test('pages and websocket upgrades over TLS, through the existing HTTP server; a renewed certificate without a restart', { skip: !HAS_OPENSSL && 'needs openssl' }, async () => {
|
||||
const dir = fs.mkdtempSync(path.join(ROOT, '.tools', 'tmp', 'https-'));
|
||||
const first = selfSigned(dir, 'first.example');
|
||||
const app = http.createServer((req, res) => res.end(`served ${req.url} encrypted=${!!req.socket.encrypted}`));
|
||||
// The page is named by comparison, never by echoing req.url back: a
|
||||
// response that reflects the request is the reflected-XSS shape (CodeQL
|
||||
// #583), even in a test (tests/noReflectedRequest.test.cjs).
|
||||
const app = http.createServer((req, res) => {
|
||||
const page = req.url === '/hello' ? '/hello' : 'another page';
|
||||
res.setHeader('Content-Type', 'text/plain; charset=utf-8');
|
||||
res.end(`served ${page} encrypted=${!!req.socket.encrypted}`);
|
||||
});
|
||||
let upgraded = false;
|
||||
app.on('upgrade', (req, socket) => { upgraded = true; socket.end('HTTP/1.1 101 Switching Protocols\r\n\r\n'); });
|
||||
const env = { HTTPS_PORT: '1', HTTPS_CERT_FILE: first.cert, HTTPS_KEY_FILE: first.key };
|
||||
|
||||
Reference in new issue
Block a user