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): gate on actual GitHub open findings

Rahman5b6bde70880d
diff --git a/.github/workflows/security-alerts.yml b/.github/workflows/security-alerts.yml
new file mode 100644
index 00000000..b4284ec6
--- /dev/null
+++ b/.github/workflows/security-alerts.yml
@@ -0,0 +1,39 @@
+name: Security alert inventory
+
+on:
+ push:
+ branches: [main, "security/**"]
+ workflow_run:
+ workflows: [CodeQL, Scorecard]
+ types: [completed]
+ branches: [main]
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+concurrency:
+ group: security-alert-inventory-${{ github.ref }}
+ cancel-in-progress: false
+
+jobs:
+ inventory:
+ name: Open default-branch security findings
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ permissions:
+ contents: read
+ security-events: read
+ steps:
+ - name: Checkout trusted repository revision
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ - name: Setup Node
+ uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
+ with:
+ node-version: 22
+ - name: Report real open alerts and fail when findings remain
+ run: node scripts/security-alerts.mjs
+ env:
+ GITHUB_TOKEN: ${{ github.token }}
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 4001f851..48ea6625 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -14,6 +14,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Fixed**
+- `security` gate on actual GitHub open findings
- `integrations` recover setup UI and cached chat links
- `release` wait for HTTP readiness before validating served assets
- `mcp` initialize page previews and verify embedded app readiness
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index 6e558082..d501234d 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -27,6 +27,8 @@ contract remain unchanged. Targeted contracts and a desktop/mobile browser harne
both standard MCP and legacy ChatGPT host paths. Toolset: `2026.09.05.1`.
# mso — Progress Log
+
+- **Default-branch security evidence (2026-09-05):** a screenshot still showed 21 open code-scanning alerts despite green analysis jobs. Add a read-only repository-native inventory with exact default-branch SHA, all paginated alert instances, recent analysis metadata and a nonzero exit while any finding remains. External owner API credentials currently fail authentication; the native Actions token has security-events read permission and is never exported. This captures the actual remediation backlog without disabling scanners or dismissing alerts.
- **Native integration preservation (2026-09-05):** merged published c164dbe without dropping the concurrent native credential setup. The short README retains its documentation link (99 lines). MCP 1.12.0 / toolset 2026.09.05.4 labels the combined maintenance, service-token, Page-readiness and native-integration contracts. This merge does not execute maintenance or reset real credentials.
- **Concurrent main reconciliation (2026-09-05):** preserved published MCP Page initialization/readiness changes e46c417 + changelog c4856d2 in the maintenance/PR integration branch without modifying the other session's unpublished work. MCP 1.11.1 / toolset 2026.09.05.2 records the combined compatible contract. The Settings maintenance files are unchanged from the isolated desktop/mobile acceptance at 2164d29; full repository and GitHub gates are rerun for the combined source.
- **PR integration validation (2026-09-05):** preserve the reviewed PR36/PR37 ancestry while repairing PR38 glob escaping/native Bun audit checks and PR37 code-generating visual-test fixtures. Direct-image boundary tests now cover malformed content and size/type limits. MCP server 1.11.0 / toolset 2026.09.05.1 records the compatible restricted-service-token/direct-image contract; widget resources and ordinary OAuth token behavior are unchanged. Publication still requires complete current-head local and remote gates, including late CodeQL findings—not only the workflow completion status.
diff --git a/docs/SECURITY-ASSURANCE.md b/docs/SECURITY-ASSURANCE.md
index adb20f44..30775236 100644
--- a/docs/SECURITY-ASSURANCE.md
+++ b/docs/SECURITY-ASSURANCE.md
@@ -25,6 +25,10 @@ The standing baseline is informed by **OWASP ASVS 5.0.0**. MSO does not claim an
All GitHub Actions referenced by the repository are pinned to immutable commit SHAs. Scanner containers used by the reproducible local gate are pinned to image digests. Managed-app release identities are separately recorded in `security/managed-app-artifacts.env`, while the core public-gateway client is recorded in `security/gateway-artifacts.env`; moving tags are never accepted as execution identities.
+## Actual open-alert inventory
+
+`Security alert inventory` uses the repository-scoped GitHub Actions token with read-only security permissions to enumerate and paginate default-branch alerts and their affected instances. It fails for any remaining open finding, or when the inventory/scan evidence cannot be read. It never dismisses alerts or changes scan configuration. Its status is deliberately separate from a successful CodeQL analysis job. The job logs and summary expose rule/path/severity evidence, never bearer credentials or secret-scanning values. `node scripts/security-alerts.mjs --inventory` is an explicit collection-only mode, not release clearance.
+
## GitHub security controls
The public repository enables:
diff --git a/scripts/security-alerts.mjs b/scripts/security-alerts.mjs
new file mode 100644
index 00000000..fd6251cb
--- /dev/null
+++ b/scripts/security-alerts.mjs
@@ -0,0 +1,70 @@
+#!/usr/bin/env node
+// Inspect GitHub's actual default-branch findings, not merely successful scan jobs.
+// Uses only a repository-scoped Actions token; never emits tokens or secret-scan values.
+import fs from "node:fs";
+import path from "node:path";
+
+const { GITHUB_TOKEN, GITHUB_REPOSITORY, GITHUB_STEP_SUMMARY, RUNNER_TEMP } = process.env;
+const args = process.argv.slice(2);
+if (args.some((arg) => arg !== "--inventory")) throw new Error("usage: node scripts/security-alerts.mjs [--inventory]");
+if (!GITHUB_TOKEN || !/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(GITHUB_REPOSITORY ?? "")) {
+ throw new Error("A repository-scoped GitHub token and repository identifier are required");
+}
+const root = `https://api.github.com/repos/${GITHUB_REPOSITORY}`;
+const directory = fs.mkdtempSync(path.join(RUNNER_TEMP || process.cwd(), "mso-code-scanning-"));
+fs.chmodSync(directory, 0o700);
+const safe = (value) => String(value ?? "").replace(/[\r\n|<>]/g, " ").slice(0, 500);
+async function get(suffix) {
+ const response = await fetch(root + suffix, { headers: {
+ Accept: "application/vnd.github+json", Authorization: `Bearer ${GITHUB_TOKEN}`,
+ "X-GitHub-Api-Version": "2022-11-28",
+ }, signal: AbortSignal.timeout(30_000) });
+ if (!response.ok) throw new Error(`GitHub security inventory unavailable (HTTP ${response.status})`);
+ return { value: await response.json(), more: /rel="next"/.test(response.headers.get("link") ?? "") };
+}
+async function pages(suffix) {
+ const all = [];
+ for (let page = 1; page <= 100; page++) {
+ const result = await get(`${suffix}${suffix.includes("?") ? "&" : "?"}per_page=100&page=${page}`);
+ if (!Array.isArray(result.value)) throw new Error("Invalid GitHub list response");
+ all.push(...result.value);
+ if (!result.more) return all;
+ }
+ throw new Error("Pagination incomplete; no clean result may be claimed");
+}
+try {
+ const repository = (await get("")).value;
+ const branch = (await get(`/branches/${encodeURIComponent(repository.default_branch)}`)).value;
+ const ref = `refs/heads/${repository.default_branch}`;
+ const alerts = await pages(`/code-scanning/alerts?state=open&ref=${encodeURIComponent(ref)}`);
+ const recent = await get(`/code-scanning/analyses?ref=${encodeURIComponent(ref)}&per_page=100`);
+ if (!Array.isArray(recent.value) || !recent.value.length) throw new Error("No scan evidence for the default branch");
+ const rows = [];
+ for (const alert of alerts) {
+ if (!Number.isSafeInteger(alert.number)) throw new Error("Invalid GitHub alert number");
+ const instances = await pages(`/code-scanning/alerts/${alert.number}/instances?ref=${encodeURIComponent(ref)}`);
+ rows.push({ number: alert.number, state: alert.state, tool: alert.tool?.name,
+ rule: alert.rule, html_url: alert.html_url, created_at: alert.created_at,
+ instances: instances.map(({ ref, analysis_key, category, state, message, location, classifications }) =>
+ ({ ref, analysis_key, category, state, message, location, classifications })) });
+ }
+ const report = { capturedAt: new Date().toISOString(), repository: GITHUB_REPOSITORY,
+ ref, head: branch.commit.sha, openCount: rows.length, alerts: rows,
+ recentAnalyses: recent.value.map(({ id, commit_sha, ref, created_at, category, error, tool }) =>
+ ({ id, commit_sha, ref, created_at, category, error, tool })),
+ olderAnalysesOmitted: recent.more };
+ fs.writeFileSync(path.join(directory, "code-scanning.json"), `${JSON.stringify(report, null, 2)}\n`, { mode: 0o600 });
+ console.log(`CODE_SCANNING_HEAD ${report.head}`);
+ console.log(`CODE_SCANNING_OPEN ${rows.length}`);
+ for (const alert of rows) console.log(`ALERT ${JSON.stringify(alert)}`);
+ const summary = ["## Default-branch code scanning", "", `Commit: \`${report.head}\` · **${rows.length} open findings**`, "",
+ "Analysis completion is not alert clearance. No alert was dismissed or deleted by this read-only job.", "",
+ "| Alert | Tool | Severity | Rule | Location |", "|---|---|---|---|---|",
+ ...rows.map((alert) => `| ${alert.number} | ${safe(alert.tool)} | ${safe(alert.rule?.security_severity_level ?? alert.rule?.severity)} | ${safe(alert.rule?.id)} | ${safe(alert.instances[0]?.location?.path)}:${alert.instances[0]?.location?.start_line ?? ""} |`), ""].join("\n");
+ if (GITHUB_STEP_SUMMARY) fs.appendFileSync(GITHUB_STEP_SUMMARY, summary);
+ console.log(`REPORT_DIRECTORY ${directory}`);
+ process.exitCode = rows.length && !args.includes("--inventory") ? 1 : 0;
+} catch (error) {
+ console.error(`INCOMPLETE: ${error.message}`);
+ process.exitCode = 2;
+}
diff --git a/scripts/security-alerts.test.ts b/scripts/security-alerts.test.ts
new file mode 100644
index 00000000..6970da92
--- /dev/null
+++ b/scripts/security-alerts.test.ts
@@ -0,0 +1,38 @@
+import { spawnSync } from "node:child_process";
+import { mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import { afterEach, describe, expect, it } from "vitest";
+
+const roots: string[] = [];
+afterEach(() => { for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }); });
+function run(options: { count?: number; denied?: boolean; noAnalysis?: boolean; paginate?: boolean } = {}) {
+ const root = mkdtempSync(path.join(tmpdir(), "mso-alert-report-test-")); roots.push(root);
+ const stub = `const options=${JSON.stringify(options)};
+ globalThis.fetch=async(url)=>{
+ if(options.denied)return new Response('{}',{status:403});
+ let value={default_branch:'main'};let headers={};
+ if(url.includes('/branches/'))value={commit:{sha:'a'.repeat(40)}};
+ if(url.includes('/alerts?')){value=Array.from({length:options.count??0},(_,i)=>({number:i+1,state:'open',tool:{name:'CodeQL'},rule:{id:'js/test',severity:'warning'}}));
+ if(options.paginate){if(url.includes('page=2'))value=[];else headers={link:'<https://api.github.com/next>; rel="next"'};}}
+ if(url.includes('/instances?'))value=[{ref:'refs/heads/main',state:'open',location:{path:'lib/test.ts',start_line:3},message:{text:'review me'}}];
+ if(url.includes('/analyses?'))value=options.noAnalysis?[]:[{id:1,commit_sha:'a'.repeat(40),tool:{name:'CodeQL'},ref:'refs/heads/main'}];
+ return new Response(JSON.stringify(value),{status:200,headers});
+ };await import(${JSON.stringify(path.join(process.cwd(), "scripts/security-alerts.mjs"))});`;
+ const result = spawnSync(process.execPath, ["--input-type=module", "-e", stub], { encoding: "utf8", timeout: 10_000,
+ env: { NODE_ENV: "test", PATH: process.env.PATH, GITHUB_TOKEN: "synthetic-test-value", GITHUB_REPOSITORY: "example/repository", RUNNER_TEMP: root } });
+ const reportDir = readdirSync(root).find((name) => name.startsWith("mso-code-scanning-"));
+ let report: { openCount: number; alerts: unknown[] } | undefined;
+ try { report = JSON.parse(readFileSync(path.join(root, reportDir ?? "", "code-scanning.json"), "utf8")); } catch { /* failed evidence is expected in negative cases */ }
+ return { ...result, report };
+}
+describe("GitHub open-alert evidence", () => {
+ it("does not turn 21 open alerts into a successful security check", () => {
+ const result = run({ count: 21 }); expect(result.status).toBe(1); expect(result.report?.openCount).toBe(21);
+ expect(result.stdout).not.toContain("synthetic-test-value"); expect(result.stderr).not.toContain("synthetic-test-value");
+ });
+ it("accepts zero findings only with scan evidence", () => { const result = run(); expect(result.status).toBe(0); expect(result.report?.openCount).toBe(0); });
+ it("fails closed on a denied security inventory", () => { const result = run({ denied: true }); expect(result.status).toBe(2); expect(result.stderr).toContain("INCOMPLETE"); });
+ it("does not call an unscanned repository clean", () => { expect(run({ noAnalysis: true }).status).toBe(2); });
+ it("follows pagination instead of treating a first page as the complete inventory", () => { const result = run({ count: 2, paginate: true }); expect(result.status).toBe(1); expect(result.report?.alerts).toHaveLength(2); });
+});