Each zone (Vanua Levu & Taveuni off Suva, the Out Islands off Nassau, and 16 more) is a pool of island homes at your POP in its city: no node and no link on the map, its Gbps join the city's demand. Rent backhaul at the city's teleport (about 35% sign up over GEO, 75% over MEO, 90% over Starblink from a gateway there) or, from level 3, lay a spur cable and everyone may sign up. The first order brings the island kit. Islanders pay island prices, their homes are IPv6-only in the NAT64 pool, and investors on a revenue share take their cut. A spur can be cut for weeks (failure 'wspur', chaos only): a satellite kept beside it carries the islands. Zones are off in puzzles, the Architect, scenarios and below level 2. The satellite geometry works on points now (satSeesAt, satPairAt, satKmAt; the city functions wrap them, with the same answers). Starblink serves a zone only from a gateway in its own city (16 of 18; a gateway anywhere in reach would serve the same 16), with its storm and rival rule; Nunavut and Southeast Alaska stay on GEO. Rules W6 and F12.
44 lines
3.8 KiB
JavaScript
44 lines
3.8 KiB
JavaScript
// A click's args name things the game looks up by key: S.pops[city], S.myIx[city]. A city that is '__proto__' or
|
||
// 'constructor', or any other name Object.prototype has ('toString': S.pops.toString is a function, so it reads as a
|
||
// POP), from an MCP agent or a request to a server-run network, must find nothing there, never a prototype or a
|
||
// built-in's statics: every action that takes one, with each such name in each usual arg, alone and next to the args
|
||
// that get an action that far (a kind, a quoted price), leaves the page's built-ins as they were, spends nothing on
|
||
// them, and writes no entry under that name anywhere in the game (S.popTiers.at.toString).
|
||
const test = require('node:test');
|
||
const assert = require('node:assert/strict');
|
||
const { load } = require('./harness');
|
||
|
||
const BAD = ['__proto__', 'constructor', 'prototype', 'toString', 'hasOwnProperty', 'valueOf'];
|
||
// The other args an action may need before it looks the name up: ptSave a kind, ptApply a kind and a price.
|
||
const WITH = { k: 'micro', cost: 0 };
|
||
const ARGS = ['city', 'id', 'net', 'k', 'c', 'v', 'a', 'b', 'to', 'from', 'link', 's', 'z'];
|
||
|
||
test('no action reaches a built-in through an arg that names one', (t) => {
|
||
// The development page: API_CMD is every action an agent may send (the MCP facade), the sent ones of a server's page.
|
||
const { ev, errors, dom } = load({ agent: true });
|
||
t.after(() => dom.window.close());
|
||
ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=1e12;S.lvl=6;for(const g of GOALS)S.done[g.id]=0;");
|
||
for (const c of ['fra', 'ams', 'lon', 'par']) ev(`ACT.buildPop({city:'${c}'})`);
|
||
ev("ACT.launchBB({city:'fra'});closeModal();UI.confirm=null;compute();");
|
||
// What the built-ins hold now: anything an action adds to them is found by name.
|
||
ev(`window.__fp=()=>{const o={};for(const [n,x] of [['Object',Object],['Object.prototype',Object.prototype],['Array',Array],['Array.prototype',Array.prototype],['Function.prototype',Function.prototype],['String.prototype',String.prototype]])o[n]=Object.getOwnPropertyNames(x).sort().join(',');
|
||
const e=[];for(const k in {})e.push(k);for(const k in [])e.push('[]'+k);o.enum=e.join(',');return o;};window.__fp0=__fp();
|
||
window.__clean=()=>{for(const [n,x] of [['Object',Object],['Object.prototype',Object.prototype],['Array',Array],['Array.prototype',Array.prototype],['Function.prototype',Function.prototype],['String.prototype',String.prototype]]){const had=new Set(__fp0[n].split(','));for(const k of Object.getOwnPropertyNames(x))if(!had.has(k))delete x[k];}};
|
||
window.__junk=(v)=>{const out=[],walk=(o,p,d)=>{if(!o||typeof o!=='object'||d>4)return;if(Object.prototype.hasOwnProperty.call(o,v)){out.push(p+'.'+v);delete o[v];}for(const k of Object.keys(o))walk(o[k],p+'.'+k,d+1);};walk(S,'S',0);return out;};`);
|
||
const acts = JSON.parse(ev('JSON.stringify(Object.keys(API_CMD).filter(k=>typeof ACT[k]==="function"&&!/^pz[A-Z]/.test(k)))'));
|
||
const hits = [];
|
||
for (const act of acts) {
|
||
for (const name of ARGS) {
|
||
for (const v of BAD) for (const extra of [{}, WITH]) {
|
||
const args = { ...extra, [name]: v };
|
||
const r = JSON.parse(ev(`(()=>{const c0=S.cash;let err=null;try{ACT[${JSON.stringify(act)}](${JSON.stringify(args)});}catch(e){err=String(e&&e.message||e);}
|
||
try{closeModal();}catch(e){}UI.confirm=null;const f=__fp(),d=Object.keys(f).filter(k=>f[k]!==__fp0[k]);if(d.length)__clean();return JSON.stringify({d,spent:c0-S.cash,err,junk:__junk(${JSON.stringify(v)})});})()`));
|
||
if (r.d.length) hits.push(`${act}(${JSON.stringify(args)}) changed ${r.d.join(', ')}${r.spent > 0 ? ` and spent ${r.spent}` : ''}`);
|
||
if (r.junk.length) hits.push(`${act}(${JSON.stringify(args)}) wrote ${r.junk.join(', ')}`);
|
||
}
|
||
}
|
||
}
|
||
t.diagnostic(`${acts.length} actions × ${ARGS.length} args × ${BAD.length} names × 2`);
|
||
assert.deepEqual(hits, []);
|
||
assert.deepEqual(errors, []);
|
||
});
|