mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-25 02:32:55 +02:00
Use a dedicated ScriptDeath type to signal script termination instead of WorkerScript
Problem with throwing WorkerScript is that the termination signal object can pass through user code, which permits user to modify that object and all parts of the game state accessible through it.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { WorkerScript } from "./WorkerScript";
|
||||
|
||||
/**
|
||||
* Script death marker.
|
||||
*
|
||||
* IMPORTANT: the game engine should not base any of it's decisions on the data
|
||||
* carried in a ScriptDeath instance.
|
||||
*
|
||||
* This is because ScriptDeath instances are thrown through player code when a
|
||||
* script is killed. Which grants the player access to the class and the ability
|
||||
* to construct new instances with arbitrary data.
|
||||
*/
|
||||
export class ScriptDeath {
|
||||
/** Process ID number. */
|
||||
pid: number;
|
||||
|
||||
/** Filename of the script. */
|
||||
name: string;
|
||||
|
||||
/** IP Address on which the script was running */
|
||||
hostname: string;
|
||||
|
||||
/** Status message in case of script error. */
|
||||
errorMessage = "";
|
||||
|
||||
constructor(ws: WorkerScript) {
|
||||
this.pid = ws.pid;
|
||||
this.name = ws.name;
|
||||
this.hostname = ws.hostname;
|
||||
this.errorMessage = ws.errorMessage;
|
||||
|
||||
Object.freeze(this);
|
||||
}
|
||||
}
|
||||
|
||||
Object.freeze(ScriptDeath);
|
||||
Object.freeze(ScriptDeath.prototype);
|
||||
Reference in New Issue
Block a user