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
|
|
@ -20,12 +20,15 @@ const M = require('./military/movements');
|
|||
|
||||
const COL = { fiber: 'fiber', hardware: 'hardware', capital: 'capital' };
|
||||
|
||||
// Credit `amount` of `res` to a POP (settled first, no storage cap: it is a refund of what left the POP).
|
||||
// Credit `amount` of `res` to a POP (settled first, capped by the Rack hall: escrow cannot be used to store past it).
|
||||
function refund(db, townId, res, amount, at) {
|
||||
const town = loadTown(db, townId);
|
||||
if (!town) return;
|
||||
settle(db, town, at);
|
||||
db.run('UPDATE towns SET ' + COL[res] + ' = ' + COL[res] + ' + ? WHERE id = ?', amount, townId);
|
||||
// Capped like cancelBuild: stock already above the Rack hall cap stays, but a refund never lifts it further.
|
||||
const cap = Math.max(R.storageCap(town), town.res[res]);
|
||||
const next = Math.min(cap, town.res[res] + amount);
|
||||
db.run('UPDATE towns SET ' + COL[res] + ' = ? WHERE id = ?', next, townId);
|
||||
}
|
||||
|
||||
const getOffer = (db, id) => db.get('SELECT * FROM trade_offers WHERE id = ?', id) || null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue