fix: every composition file server refuses credential and tool-state files (#7889)

* wip: paused before review

* test: cover credential files on the preview routes and the deploy notice

* refactor: name the inspector's file lookup for what it serves

* fix(cli): a link to a private file outside the project keeps its own left-out reason

* fix: escape the upload notice and skip private files from old manifests
This commit is contained in:
Michael Wang
2026-11-16 01:42:08 +00:00
committed by GitHub
parent ed93a13125
commit 014326b40b
22 changed files with 456 additions and 93 deletions
+1 -46
View File
@@ -15,7 +15,7 @@ import {
} from "@hyperframes/studio-server/outside-file";
import { isPrivateProjectFile, realFilePath } from "@hyperframes/studio-server/safe-path";
import { mkdirWithinProject } from "@hyperframes/core";
import { projectPathSegments } from "@hyperframes/core/safe-path";
import { isCredentialOrToolStatePath } from "@hyperframes/core/safe-path";
import { publishRegistryFile, registryRoot, registryTargetPath } from "../registry/publication.js";
export { isEnvOrGitPath, isPrivateOutsideFile, linksOutside };
@@ -203,51 +203,6 @@ export function receivedRecordStatus(
return { path: join(nearest.root, RECEIVED_RECORD), listed: records.flatMap(listedUnder) };
}
const CREDENTIAL_FILES = new Set([
".npmrc",
".yarnrc",
".yarnrc.yml",
".pypirc",
"pip.conf",
"pip.ini",
".netrc",
"_netrc",
".git-credentials",
".gitconfig",
".mcp.json",
]);
const CREDENTIAL_FOLDERS = new Set([
".ssh",
".aws",
".gnupg",
".docker",
".kube",
".azure",
".claude",
".codex",
".cursor",
".agents",
".gemini",
".vscode",
".idea",
]);
const CREDENTIAL_CONFIG_FOLDERS = new Set(["gcloud", "gh"]);
const KEY_FILE = /^(?:id_(?:rsa|dsa|ecdsa|ed25519).*|.*\.(?:pem|key|p12|pfx))$/;
export function isCredentialOrToolStatePath(relPath: string): boolean {
const segments = projectPathSegments(relPath);
const name = segments.at(-1) ?? "";
return (
CREDENTIAL_FILES.has(name) ||
KEY_FILE.test(name) ||
segments.some(
(segment, at) =>
CREDENTIAL_FOLDERS.has(segment) ||
(segment === ".config" && CREDENTIAL_CONFIG_FOLDERS.has(segments[at + 1] ?? "")),
)
);
}
const leavesProject = (path: string): boolean =>
isAbsolute(path) || path.split(/[\\/]/)[0] === "..";