Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

fix(security): harden gateway scanner fixtures

Rahman5412f74c690a
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 9fdd3150..382ebf70 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -13,6 +13,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Fixed**
+- `security` harden gateway scanner fixtures
- `install` survive Bun bin metadata corruption
- `install` keep bootstrap guard shellcheck-clean
- `install` guard earliest bootstrap prefix
diff --git a/lib/security/gateway-supply-chain.test.ts b/lib/security/gateway-supply-chain.test.ts
index cd9ac6ae..dcd3466f 100644
--- a/lib/security/gateway-supply-chain.test.ts
+++ b/lib/security/gateway-supply-chain.test.ts
@@ -9,6 +9,18 @@ const ROOT = path.resolve(__dirname, "../..");
const GATEWAY = path.join(ROOT, "scripts/mso-gateway");
const roots: string[] = [];
const sha = (value: string) => createHash("sha256").update(value).digest("hex");
+const snapshot = (file: string) => {
+ const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);
+ try {
+ const stat = fs.fstatSync(fd);
+ if (!stat.isFile()) throw new Error(`not a regular file: ${file}`);
+ return { mode: stat.mode & 0o777, text: fs.readFileSync(fd, "utf8") };
+ } finally { fs.closeSync(fd); }
+};
+const appendNoFollow = (file: string, value: string) => {
+ const fd = fs.openSync(file, fs.constants.O_WRONLY | fs.constants.O_APPEND | fs.constants.O_NOFOLLOW);
+ try { fs.writeSync(fd, value); } finally { fs.closeSync(fd); }
+};
afterEach(() => { for (const root of roots.splice(0)) fs.rmSync(root, { recursive: true, force: true }); });
@@ -40,8 +52,9 @@ describe("gateway supply chain", () => {
const first = execFileSync(GATEWAY, ["install"], { encoding: "utf8", env });
expect(first).toContain("pinned-fixture");
const installed = path.join(tools, "fixture", "cloudflared");
- expect(fs.statSync(installed).mode & 0o777).toBe(0o700);
- expect(sha(fs.readFileSync(installed, "utf8"))).toBe(digest);
+ let installedSnapshot = snapshot(installed);
+ expect(installedSnapshot.mode).toBe(0o700);
+ expect(sha(installedSnapshot.text)).toBe(digest);
expect(fs.readFileSync(count, "utf8")).toBe("x");
execFileSync(GATEWAY, ["install"], { encoding: "utf8", env });
diff --git a/scripts/lib/gateway-config.sh b/scripts/lib/gateway-config.sh
index 618a1564..3f0bf30e 100644
--- a/scripts/lib/gateway-config.sh
+++ b/scripts/lib/gateway-config.sh
@@ -39,14 +39,14 @@ NODE
}
gateway_cmd_domain() {
- local sub="${1:-show}" origin host
+ local sub="${1:-show}" origin domain_host
case "$sub" in
show) origin="$(gateway_env_origin)"; [ -n "$origin" ] && gateway_info "$origin" || gateway_info "OS_PUBLIC_ORIGIN is not set" ;;
set)
[ -n "${2-}" ] || gateway_fail "usage: mso gateway domain set https://mso.example.com"
origin="$(gateway_validate_public_origin "$2" 2>/dev/null || true)"
[ -n "$origin" ] || gateway_fail "public origin must be a clean HTTPS origin"
- gateway_rewrite_env_origin set "$origin"; host="${origin#https://}"
+ gateway_rewrite_env_origin set "$origin"; domain_host="${origin#https://}"
gateway_info "saved OS_PUBLIC_ORIGIN=$origin in $ENVF"
gateway_info "MSO still binds only to $LOCAL_URL"
cat <<CFG
@@ -54,10 +54,10 @@ named Cloudflare config example:
tunnel: <TUNNEL-UUID>
credentials-file: $HOME/.cloudflared/<TUNNEL-UUID>.json
ingress:
- - hostname: $host
+ - hostname: $domain_host
service: $LOCAL_URL
- service: http_status:404
-then: cloudflared tunnel route dns <TUNNEL-UUID-or-name> $host
+then: cloudflared tunnel route dns <TUNNEL-UUID-or-name> $domain_host
and: mso gateway start --config ~/.cloudflared/config.yml --tunnel <TUNNEL-UUID-or-name>
CFG
gateway_info "rebuild/restart MSO after stable origin or split-host env changes" ;;