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
@@ -729,6 +729,28 @@ describe("serveStaticProjectHtml private project files", () => {
);
});
describe("serveStaticProjectHtml credential files", () => {
it.each([".npmrc", ".mcp.json", ".claude/x.json", ".aws/credentials", "id_ed25519", "cert.pem"])(
"answers %s with 404",
async (requestPath) => {
dir = mkdtempSync(join(tmpdir(), "hf-static-credentials-"));
for (const folder of [".claude", ".aws"]) mkdirSync(join(dir, folder));
for (const file of [".npmrc", ".mcp.json", ".claude/x.json", ".aws/credentials"]) {
writeFileSync(join(dir, file), "SECRET=1");
}
writeFileSync(join(dir, "id_ed25519"), "SECRET=1");
writeFileSync(join(dir, "cert.pem"), "SECRET=1");
writeFileSync(join(dir, "asset.txt"), "ok");
server = await serveStaticProjectHtml(dir, "<html></html>");
const res = await fetch(`${server.url}${requestPath}`);
expect(res.status).toBe(404);
expect(await res.text()).not.toContain("SECRET");
expect((await fetch(`${server.url}asset.txt`)).status).toBe(200);
},
);
});
describe("serveStaticProjectHtml page another site loads", () => {
const MARK = '<meta name="hyperframes-preview-for-another-site">';
const SANDBOX = "sandbox allow-scripts";