mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
- Remove package-lock.json: the server uses no npm packages, which the invariants check enforces (no supply chain to attack). - Allow the two hosts the server really calls in .github/allowed-hosts.json: cdn.jsdelivr.net (Twemoji pictures, lib/emoji.js) and vision.googleapis.com (the optional SafeSearch check, lib/image-moderation.js). The github.com mention in lib/emoji.js was only a comment, now reworded. - logText strips line feeds with .replace(/\n/g, ""), the form CodeQL's js/log-injection recognises as a sanitiser. The old [\r\n]+ to a space was just as safe, but not recognised, so every log line using it was flagged (34 alerts on main, 35 on this branch). - /authenticate: the saved sign-in is decided by what the server finds for the refresh token, not by whether the request has one (js/user-controlled-bypass). A token that is not good is still refused with error_code 100. Co-Authored-By: Claude Opus 5.5 <[email protected]>
18 lines
791 B
JavaScript
18 lines
791 B
JavaScript
"use strict";
|
|
|
|
// a value from outside (a username, an address, what a client sent) as it
|
|
// may go into a line of the server's log: on one line, and with no control
|
|
// characters, so that it cannot pass for a line of the server's own (a name
|
|
// with a line break in it, "...\n[admin] signed in") or move the terminal's
|
|
// cursor about. (U+2028 and U+2029, which end a line too, are in the second.)
|
|
const OTHER_BREAKS_AND_CONTROLS = new RegExp("[\x00-\x1f\x7f-\x9f\u2028\u2029]", "g");
|
|
|
|
// (line feeds go first, and to nothing: the form code scanning knows as a
|
|
// log's sanitiser. carriage returns, and the rest, are then replaced.)
|
|
const logText = value => String(value)
|
|
.replace(/\n/g, "")
|
|
.replace(/\r/g, " ")
|
|
.replace(OTHER_BREAKS_AND_CONTROLS, "?");
|
|
|
|
module.exports = {logText};
|