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.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
fix(security): enforce actual branch code-scanning alerts
Rahmane561cf4d983a
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.ymlindex 5b62cad4..abd03cbf 100644--- a/.github/workflows/codeql.yml+++ b/.github/workflows/codeql.yml@@ -45,6 +45,6 @@ jobs:- name: Inspect actual branch findings after SARIF processingif: github.event_name == 'push'- run: node scripts/security-alerts.mjs --inventory --include-closed --ref "$GITHUB_REF"+ run: node scripts/security-alerts.mjs --include-closed --ref "$GITHUB_REF"env:GITHUB_TOKEN: ${{ github.token }}diff --git a/.github/workflows/security-alerts.yml b/.github/workflows/security-alerts.ymlindex 001e0a6c..4dccb8df 100644--- a/.github/workflows/security-alerts.yml+++ b/.github/workflows/security-alerts.yml@@ -34,6 +34,13 @@ jobs:with:node-version: 22- name: Report real open alerts and fail when findings remain- run: node scripts/security-alerts.mjs+ shell: bash+ run: |+ set -euo pipefail+ if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then+ node scripts/security-alerts.mjs --ref "$GITHUB_REF"+ else+ node scripts/security-alerts.mjs+ fienv:GITHUB_TOKEN: ${{ github.token }}diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex 2d695027..2c64ab3c 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -20,6 +20,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.**Fixed**+- `security` enforce actual branch code-scanning alerts- `security` make import preview confirmations opaque- `security` key portable import preview confirmations- `mcp` render one bounded inline Page previewdiff --git a/scripts/codeql-report.mjs b/scripts/codeql-report.mjsindex 0cbf0b80..475dcf97 100644--- a/scripts/codeql-report.mjs+++ b/scripts/codeql-report.mjs@@ -1,11 +1,27 @@#!/usr/bin/env node-// Read-only evidence: report every SARIF result without filtering/deleting diagnostics.+// Exact CodeQL SARIF inventory. It never dismisses findings and never prints source+// snippets or raw diagnostic messages that could contain sensitive values. GitHub+// open-alert state is the enforcement boundary because it respects reviewed/dismissed+// findings while still failing newly open branch alerts.import fs from "node:fs";import path from "node:path";+const directory = process.argv[2];if (!directory) throw new Error("usage: node scripts/codeql-report.mjs <SARIF directory>");const files = fs.readdirSync(directory).filter((name) => name.endsWith(".sarif"));if (!files.length) throw new Error("CodeQL produced no SARIF file");++function commandValue(value) {+ return String(value ?? "").replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/:/g, "%3A").replace(/,/g, "%2C");+}+function safeLocation(row) {+ const p = row?.locations?.[0]?.physicalLocation;+ const raw = typeof p?.artifactLocation?.uri === "string" ? p.artifactLocation.uri : ".github";+ const file = /^[A-Za-z0-9_./-]{1,500}$/.test(raw) && !raw.includes("..") ? raw : ".github";+ const line = Number.isSafeInteger(p?.region?.startLine) && p.region.startLine > 0 ? p.region.startLine : 1;+ return { file, line };+}+let count = 0;for (const name of files) {const data = JSON.parse(fs.readFileSync(path.join(directory, name), "utf8"));@@ -13,12 +29,15 @@ for (const name of files) {for (const run of data.runs) {if (run.tool?.driver?.name !== "CodeQL" || !Array.isArray(run.results)) throw new Error("Unexpected SARIF tool/result shape");for (const row of run.results) {- const rule = run.tool.driver.rules?.find((rule) => rule.id === row.ruleId);- const locations = (row.locations ?? []).map(({ physicalLocation: p }) => ({ path: p?.artifactLocation?.uri, line: p?.region?.startLine }));- console.log(`CODEQL_FINDING ${JSON.stringify({ rule: row.ruleId, severity: rule?.properties?.["security-severity"], message: row.message?.text, locations })}`);+ const rule = run.tool.driver.rules?.find((candidate) => candidate.id === row.ruleId);+ const ruleId = typeof row.ruleId === "string" ? row.ruleId.slice(0, 160) : "unknown-rule";+ const severity = String(rule?.properties?.["security-severity"] ?? rule?.properties?.severity ?? "unknown").slice(0, 40);+ const { file, line } = safeLocation(row);+ console.log(`CODEQL_FINDING ${JSON.stringify({ rule: ruleId, severity, location: { path: file, line } })}`);+ console.log(`::warning file=${commandValue(file)},line=${line},title=${commandValue(`CodeQL SARIF · ${ruleId}`)}::${commandValue(`${severity} result present; open-alert enforcement runs after upload`)}`);count++;}}}console.log(`CODEQL_RESULT_COUNT ${count}`);-console.log("This is a diagnostic inventory, not a clearance decision; GitHub open-alert checks are separate.");+console.log("SARIF inventory complete; actual open-alert enforcement runs after GitHub processes this upload.");diff --git a/scripts/codeql-report.test.ts b/scripts/codeql-report.test.tsnew file mode 100644index 00000000..ea81bf67--- /dev/null+++ b/scripts/codeql-report.test.ts@@ -0,0 +1,52 @@+import { spawnSync } from "node:child_process";+import { mkdtempSync, rmSync, writeFileSync } 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(results: unknown[]) {+ const root = mkdtempSync(path.join(tmpdir(), "mso-codeql-report-")); roots.push(root);+ writeFileSync(path.join(root, "result.sarif"), JSON.stringify({+ runs: [{+ tool: { driver: { name: "CodeQL", rules: [{ id: "js/example", properties: { "security-severity": "8.1" } }] } },+ results,+ }],+ }));+ return spawnSync(process.execPath, [path.join(process.cwd(), "scripts/codeql-report.mjs"), root], { encoding: "utf8", timeout: 10_000 });+}++describe("exact CodeQL SARIF inventory", () => {+ it("reports a zero-result analysis", () => {+ const result = run([]);+ expect(result.status).toBe(0);+ expect(result.stdout).toContain("CODEQL_RESULT_COUNT 0");+ expect(result.stdout).toContain("open-alert enforcement runs after GitHub processes this upload");+ });++ it("reports results without treating reviewed SARIF as the open-alert policy", () => {+ const result = run([{+ ruleId: "js/example",+ message: { text: "sensitive diagnostic should never be printed" },+ locations: [{ physicalLocation: { artifactLocation: { uri: "lib/example.ts" }, region: { startLine: 17 } } }],+ }]);+ expect(result.status).toBe(0);+ expect(result.stdout).toContain("CODEQL_RESULT_COUNT 1");+ expect(result.stdout).toContain("CodeQL SARIF · js/example");+ expect(result.stdout).toContain("lib/example.ts");+ expect(result.stdout).not.toContain("sensitive diagnostic");+ expect(result.stderr).not.toContain("sensitive diagnostic");+ });++ it("does not let a hostile SARIF path escape the annotation boundary", () => {+ const result = run([{+ ruleId: "js/example",+ locations: [{ physicalLocation: { artifactLocation: { uri: "../../secret.env" }, region: { startLine: 3 } } }],+ }]);+ expect(result.status).toBe(0);+ expect(result.stdout).toContain("file=.github,line=3");+ expect(result.stdout).not.toContain("../../secret.env");+ });+});