mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
fix(ci): pass the security invariants and clear the code-scanning alerts
- 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]>
This commit is contained in:
1 parent
d8a9c1f881
commit
ee06e8ca77
5 files changed
+15
-25
No files matched your search
+8
-8
@@ -497,17 +497,17 @@ const authenticate = async (req, res, from) => {
|
||||
// stands in for them; one that is not is refused here, whatever else
|
||||
// the request says. (Whether the request offers a token is not what
|
||||
// decides: only the server's own answer for it.)
|
||||
if (body.refresh_token !== undefined) {
|
||||
const saved = accounts.byToken(body.refresh_token);
|
||||
if (!saved) {
|
||||
failuresByAddress.record(from.key);
|
||||
// error_code 100 = expired refresh token
|
||||
send(res, 401, {error_code: 100});
|
||||
return;
|
||||
}
|
||||
const saved = accounts.byToken(body.refresh_token); // null for none, or for one that is not good
|
||||
if (saved) {
|
||||
await signInChecked(res, body, from, saved, true, device);
|
||||
return;
|
||||
}
|
||||
if (body.refresh_token !== undefined) {
|
||||
failuresByAddress.record(from.key);
|
||||
// error_code 100 = expired refresh token
|
||||
send(res, 401, {error_code: 100});
|
||||
return;
|
||||
}
|
||||
// a password is not looked at before the captcha. the custom client
|
||||
// knows these errors; the official launcher shows them as a wrong password.
|
||||
const captchaProblem = await captcha.check(body, from, "login", accounts.byName(accountKey));
|
||||
|
||||
Reference in new issue
Block a user