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): retain artifact-lock compatibility and require fresh scan evidence

Rahmanedbb2ad9d673
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index bbe1f9b5..e2b9dec4 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -15,6 +15,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Fixed**
+- `security` retain artifact-lock compatibility and require fresh scan evidence
- `security` pin store paths and eliminate unsafe file-read patterns
- `mcp` add explicit browser sign-in for reviewed embedded apps
- `security` gate on actual GitHub open findings
diff --git a/lib/security-store-path.test.ts b/lib/security-store-path.test.ts
index 680dec71..2ea436f1 100644
--- a/lib/security-store-path.test.ts
+++ b/lib/security-store-path.test.ts
@@ -10,6 +10,11 @@ async function fixture() { const root = await fs.mkdtemp(path.join(os.tmpdir(),
afterEach(async () => { for (const root of roots.splice(0)) await fs.rm(root, { recursive: true, force: true }); });
describe("pinned owner security-store paths", () => {
+ it("supports the existing hidden artifact-lock basename", async () => {
+ const root = await fixture();
+ const pinned = await pinSecurityStorePath(path.join(root, ".artifacts"));
+ try { expect(pinned.file).toMatch(/\/\.artifacts$/); } finally { await pinned.directory.close(); }
+ });
it("rejects traversal and non-canonical symlink ancestors before creating a target", async () => {
const root = await fixture(), outside = await fixture();
await fs.symlink(outside, path.join(root, "alias"));
diff --git a/lib/security-store-path.ts b/lib/security-store-path.ts
index 9d5c7bb9..39f34015 100644
--- a/lib/security-store-path.ts
+++ b/lib/security-store-path.ts
@@ -19,7 +19,7 @@ export async function pinSecurityStorePath(storePath: string) {
if (typeof storePath !== "string" || storePath.includes("\0") || !path.isAbsolute(storePath)) throw new Error("Security store needs an absolute path");
const absolute = path.resolve(storePath);
const name = path.basename(absolute);
- if (!/^[A-Za-z0-9_][A-Za-z0-9_.-]{0,220}$/.test(name)) throw new Error("Invalid security-store filename");
+ if (!/^[A-Za-z0-9_.-]{1,221}$/.test(name) || name === "." || name === "..") throw new Error("Invalid security-store filename");
const allowed = [os.homedir(), ...(process.env.OS_FS_WRITE_ROOTS ?? "").split(":").filter(Boolean),
...STORE_ENV.flatMap((key) => process.env[key] ? [path.dirname(expand(process.env[key]!))] : []),
...DIRECTORY_ENV.flatMap((key) => process.env[key] ? [expand(process.env[key]!)] : []),
diff --git a/scripts/security-alerts.mjs b/scripts/security-alerts.mjs
index fd6251cb..cc91ebea 100644
--- a/scripts/security-alerts.mjs
+++ b/scripts/security-alerts.mjs
@@ -39,6 +39,9 @@ try {
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");
+ if (!recent.value.some((scan) => scan.tool?.name === "CodeQL" && scan.commit_sha === branch.commit.sha && !scan.error)) {
+ throw new Error("CodeQL has not completed successfully for the current default-branch commit");
+ }
const rows = [];
for (const alert of alerts) {
if (!Number.isSafeInteger(alert.number)) throw new Error("Invalid GitHub alert number");
diff --git a/scripts/security-alerts.test.ts b/scripts/security-alerts.test.ts
index 6970da92..d13b99d9 100644
--- a/scripts/security-alerts.test.ts
+++ b/scripts/security-alerts.test.ts
@@ -6,7 +6,7 @@ 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 } = {}) {
+function run(options: { count?: number; denied?: boolean; noAnalysis?: boolean; paginate?: boolean; stale?: 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)=>{
@@ -16,7 +16,7 @@ function run(options: { count?: number; denied?: boolean; noAnalysis?: boolean;
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'}];
+ if(url.includes('/analyses?'))value=options.noAnalysis?[]:[{id:1,commit_sha:(options.stale?'b':'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,
@@ -33,6 +33,7 @@ describe("GitHub open-alert evidence", () => {
});
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 old clean scan current", () => { expect(run({ stale: true }).status).toBe(2); });
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); });
});