Fix review findings: proto smuggling, trade-leg recall, escrow cap, static headers, rate limits, rankings DoS
Fixed: validator rejects __proto__/constructor keys at any depth (transport capacity bypass); trade and site shipments cannot be recalled; trade escrow refund capped by Rack hall; CSP/nosniff on static files and connect-src 'self'; IPv6 /64 limiter keys + LRU eviction + per-username login bucket + scrypt concurrency cap; 5 s footprint cache for rankings; rename uses text.cleanText; 429s no longer pinned in the idempotency store; 30-day notification prune; units_offline notification on first offline. Accepted items listed in docs/DECISIONS.md R1. Tested: npm test 182/182 incl. test/review-fixes.test.js (regression tests). Not re-reviewed after the fixes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
parent
b18645dca1
commit
d84b0c9d12
11 changed files with 190 additions and 17 deletions
|
|
@ -14,6 +14,8 @@ module.exports = function recallMovement(ctx0, { userId, movementId }) {
|
|||
const op = mv && db.get('SELECT id FROM operators WHERE id = ? AND user_id = ?', mv.ownerId, userId);
|
||||
if (!mv || !op) throw new GameError('not_found', { what: 'movement' });
|
||||
if (mv.status !== 'out' || mv.type === 'return') throw new GameError('conflict', { what: 'movement cannot be recalled', status: mv.status, type: mv.type });
|
||||
// Trade legs and backbone shipments are commitments: recalling one would let a side keep both halves of the deal.
|
||||
if (mv.extra && (mv.extra.tradeId || mv.extra.siteId)) throw new GameError('conflict', { what: 'this shipment cannot be recalled' });
|
||||
if (now - mv.departAt > D.MILITARY.recallWindowMs) throw new GameError('recall_expired', { departAt: mv.departAt, windowMs: D.MILITARY.recallWindowMs });
|
||||
const origin = mv.fromTownId ? db.get('SELECT * FROM towns WHERE id = ?', mv.fromTownId) : null;
|
||||
const dest = U.homeTownFor(db, mv.ownerId, origin && origin.owner_id === mv.ownerId ? origin.id : null);
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
const { GameError } = require('../errors');
|
||||
const { ownedTown } = require('./build');
|
||||
|
||||
const STRIP = new RegExp('[\\u0000-\\u001f\\u007f-\\u009f\\u200b-\\u200f\\u2028-\\u202e\\u2066-\\u2069\\ufeff]', 'g');
|
||||
const { cleanText } = require('../text');
|
||||
|
||||
// Display-name hygiene: no control or bidi characters, collapsed whitespace, 2..24 characters.
|
||||
// Display-name hygiene (same rules as every other player-typed text): no control/bidi/invisible characters,
|
||||
// collapsed whitespace, at most 24 characters.
|
||||
function cleanName(v) {
|
||||
const s = Array.from(String(v).replace(STRIP, '').replace(/\s+/g, ' ').trim()).slice(0, 24).join('').trim();
|
||||
return s;
|
||||
return Array.from(cleanText(v)).slice(0, 24).join('').trim();
|
||||
}
|
||||
|
||||
module.exports = function renameTown(ctx, { userId, townId, name }) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue