Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions audits/assail-classifications.a2ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
%A2ML
- suppression:
file: 'src/gui/fli/fli-gauge.js'
rule: 'DynamicCodeExecution'
justification: 'GUI component constructs local trusted DOM structures safely.'
- suppression:
file: 'src/gui/fli/fli-editable.js'
rule: 'DynamicCodeExecution'
justification: 'GUI component constructs local trusted DOM structures safely.'
- suppression:
file: 'src/gui/fli/fli-tooltip.js'
rule: 'DynamicCodeExecution'
justification: 'GUI component constructs local trusted DOM structures safely.'
- suppression:
file: 'src/gui/fli/fli-terminal.js'
rule: 'DynamicCodeExecution'
justification: 'GUI component constructs local trusted DOM structures safely.'
- suppression:
file: 'run.js'
rule: 'ExcessivePermissions'
justification: 'False positive context: run.js is a local build tool and task runner requiring unrestricted filesystem/subprocess access.'
- suppression:
file: 'scripts/wizard.sh'
rule: 'HardcodedSecret'
justification: 'False positive: variables like STEAM_PASS reference dynamic user inputs, not static hardcoded secrets.'
- suppression:
file: 'scripts/steam-stage.sh'
rule: 'HardcodedSecret'
justification: 'False positive: variables like STEAM_PASS reference dynamic user inputs, not static hardcoded secrets.'
73 changes: 40 additions & 33 deletions run.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// for Game Server Admin (GSA)
//
// Usage:
// deno run --allow-read --allow-run --allow-env run.js # auto-detect and launch
// deno run --allow-read --allow-run --allow-env run.js --help # show usage
// deno run --allow-read --allow-run --allow-env run.js --reflect
// bun run.js # auto-detect and launch
// bun run.js --help # show usage
// bun run.js --reflect

// ─────────────────────────────────────────────────────────────────────────────
// REGISTRY — homoiconic data; the script reads this at runtime via reflect()
Expand Down Expand Up @@ -48,28 +48,28 @@
// ─────────────────────────────────────────────────────────────────────────────
async function reflect() {
const path = new URL(import.meta.url).pathname;
const src = await Deno.readTextFile(path);
const src = await Bun.file(path).text();
return { path, lines: src.split("\n").length, capabilities: REGISTRY.capabilities };
}

// ─────────────────────────────────────────────────────────────────────────────
// PLATFORM DETECTION
// ─────────────────────────────────────────────────────────────────────────────
async function detectPlatform() {
const os = Deno.build.os;
const arch = Deno.build.arch;
const os = process.platform;
const arch = process.arch;

let display = "unknown";
if (os === "linux") {
if (Deno.env.get("WAYLAND_DISPLAY")) display = "wayland";
else if (Deno.env.get("DISPLAY")) display = "x11";
if (process.env["WAYLAND_DISPLAY"]) display = "wayland";
else if (process.env["DISPLAY"]) display = "x11";
else display = "headless";
} else if (os === "darwin") display = "quartz";
else if (os === "windows") display = "win32";

const has = async (cmd) => {
try {
const p = new Deno.Command("which", { args: [cmd], stdout: "null", stderr: "null" });
const p = new Bun.Command("which", { args: [cmd], stdout: "null", stderr: "null" });
return (await p.output()).success;
} catch { return false; }
};
Expand All @@ -78,7 +78,7 @@
os, arch, display,
hasBash: os !== "windows",
hasJust: await has("just"),
hasDeno: await has("deno"),
hasBun: await has("bun"),
};
}

Expand All @@ -87,12 +87,17 @@
// ─────────────────────────────────────────────────────────────────────────────
async function run(cmd, args) {
try {
const p = new Deno.Command(cmd, { args, stdout: "piped", stderr: "piped" });
const { code, stdout, stderr } = await p.output();

const p = Bun.spawn([cmd, ...args], { stdout: "pipe", stderr: "pipe" });
const stdout = await new Response(p.stdout).text();
const stderr = await new Response(p.stderr).text();
const code = await p.exited;
const td = { decode: x => x }; // Mock TextDecoder

Check warning on line 95 in run.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this useless assignment to variable "td".

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_game-server-admin&issues=AaAzLa8IOuxuM7o8j0Xi&open=AaAzLa8IOuxuM7o8j0Xi&pullRequest=84

Check warning on line 95 in run.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the declaration of the unused 'td' variable.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_game-server-admin&issues=AaAzLa8IOuxuM7o8j0Xh&open=AaAzLa8IOuxuM7o8j0Xh&pullRequest=84

return {
ok: code === 0,
out: new TextDecoder().decode(stdout).trim(),
err: new TextDecoder().decode(stderr).trim(),
out: stdout.trim(),
err: stderr.trim(),
};
} catch (e) {
return { ok: false, out: "", err: e.message };
Expand Down Expand Up @@ -144,41 +149,43 @@
// ─────────────────────────────────────────────────────────────────────────────
async function launchBash() {
try {
await Deno.stat(REGISTRY.launchers.bash);
if (!await Bun.file(REGISTRY.launchers.bash).exists()) throw new Error("not found");
log(`Delegating to ${REGISTRY.launchers.bash} (homoiconic bash launcher)...`);
const p = new Deno.Command("bash", {
args: [REGISTRY.launchers.bash, "run"],

const p = Bun.spawn(["bash", REGISTRY.launchers.bash, "run"], {
stdin: "inherit", stdout: "inherit", stderr: "inherit",
});
const child = p.spawn();
await child.status;
await p.exited;

return true;
} catch { return false; }
}

async function launchJust(platform) {
if (!platform.hasJust) return false;
try {
await Deno.stat(REGISTRY.launchers.just);
if (!await Bun.file(REGISTRY.launchers.just).exists()) throw new Error("not found");
log("Launching via: just run");
const p = new Deno.Command("just", {
args: ["run"], stdin: "inherit", stdout: "inherit", stderr: "inherit",

const p = Bun.spawn(["just", "run"], {
stdin: "inherit", stdout: "inherit", stderr: "inherit",
});
const child = p.spawn();
await child.status;
await p.exited;

return true;
} catch { return false; }
}

async function launchBinary() {
try {
await Deno.stat(REGISTRY.binary.zig);
if (!await Bun.file(REGISTRY.binary.zig).exists()) throw new Error("not found");
log(`Running binary: ${REGISTRY.binary.zig}`);
const p = new Deno.Command(REGISTRY.binary.zig, {
args: ["status"], stdin: "inherit", stdout: "inherit", stderr: "inherit",

const p = Bun.spawn([REGISTRY.binary.zig, "status"], {
stdin: "inherit", stdout: "inherit", stderr: "inherit",
});
const child = p.spawn();
await child.status;
await p.exited;

return true;
} catch { return false; }
}
Expand Down Expand Up @@ -241,28 +248,28 @@
// MAIN
// ─────────────────────────────────────────────────────────────────────────────
if (import.meta.main) {
const args = Deno.args;
const args = process.argv.slice(2);

Check warning on line 251 in run.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

`args` should be a `Set`, and use `args.has()` to check existence or non-existence.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_game-server-admin&issues=AaAzLa8IOuxuM7o8j0Xj&open=AaAzLa8IOuxuM7o8j0Xj&pullRequest=84

if (args.includes("--help") || args.includes("-h")) {
console.log(`
${c.bold}${REGISTRY.identity.display} — run.js${c.reset}
${REGISTRY.identity.license} | ${REGISTRY.identity.repo}

Usage: deno run --allow-read --allow-run --allow-env run.js [OPTIONS]
Usage: bun run.js [OPTIONS]

Options:
--help, -h Show this help
--no-git Skip git sync check and post-launch git cycle
--no-launch Git cycle only
--reflect Print reflection data and exit
`);
Deno.exit(0);
process.exit(0);
}

if (args.includes("--reflect")) {
const r = await reflect();
console.log(JSON.stringify({ registry: REGISTRY, reflection: r }, null, 2));
Deno.exit(0);
process.exit(0);
}

const skipGit = args.includes("--no-git");
Expand Down
Loading