mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 11:26:02 +00:00
fix(cli): upload archives never include credential or agent-state files (#7830)
* fix(cli): upload archives never include credential or agent-state files Publish, cloud render and feedback stage the project through one path. It now always leaves out package-manager and Git credentials (.npmrc, .yarnrc, .pypirc, pip.conf, .netrc, .git-credentials, .gitconfig), key files (id_rsa*, id_ed25519*, *.pem, *.key, *.p12, *.pfx), .ssh, .aws, .gnupg, .docker, .kube, .azure, .config/gcloud and .config/gh, agent and editor folders (.claude, .codex, .cursor, .agents, .gemini, .vscode, .idea) and .mcp.json, at any depth and in any letter case. This holds whatever .hyperframesignore says and whatever the HTML or CSS references. A reference can bring back a file the ignore rules skipped only when it is an image, video, audio, font, CSS or JS file, or when it is not in a hidden folder. Every file left out this way is reported, and a file the folder walk already reported is not reported again for each reference. * fix(cli): anchor both alternatives of the key-file pattern * fix(cli): a page's own scripts in a hidden folder still upload
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
rmSync,
|
||||
statSync,
|
||||
} from "node:fs";
|
||||
import { dirname, join, relative, resolve, sep } from "node:path";
|
||||
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
||||
import {
|
||||
isEnvOrGitPath,
|
||||
isPrivateOutsideFile,
|
||||
@@ -15,6 +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 { publishRegistryFile, registryRoot, registryTargetPath } from "../registry/publication.js";
|
||||
|
||||
export { isEnvOrGitPath, isPrivateOutsideFile, linksOutside };
|
||||
@@ -202,11 +203,71 @@ export function receivedRecordStatus(
|
||||
return { path: join(nearest.root, RECEIVED_RECORD), listed: records.flatMap(listedUnder) };
|
||||
}
|
||||
|
||||
/** Project files no composition loads, so none is served or uploaded for one: env files, Git data, tool records. */
|
||||
export function isPrivateCompositionFile(projectDir: string, filePath: string): boolean {
|
||||
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 (
|
||||
isEnvOrGitPath(relative(projectDir, filePath)) ||
|
||||
isEnvOrGitPath(relative(realFilePath(projectDir), realFilePath(filePath))) ||
|
||||
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] === "..";
|
||||
|
||||
const projectRelatives = (projectDir: string, filePath: string): string[] => [
|
||||
relative(projectDir, filePath),
|
||||
relative(realFilePath(projectDir), realFilePath(filePath)),
|
||||
];
|
||||
|
||||
/** Project files no composition loads, so none is served or uploaded: env, Git, credentials, tool and agent state. */
|
||||
export function isPrivateCompositionFile(projectDir: string, filePath: string): boolean {
|
||||
const paths = projectRelatives(projectDir, filePath);
|
||||
return (
|
||||
paths.some(isEnvOrGitPath) ||
|
||||
paths.some((path) => !leavesProject(path) && isCredentialOrToolStatePath(path)) ||
|
||||
isPrivateProjectFile(projectDir, filePath)
|
||||
);
|
||||
}
|
||||
|
||||
export function isHiddenProjectFile(projectDir: string, filePath: string): boolean {
|
||||
return projectRelatives(projectDir, filePath).some((path) =>
|
||||
path.split(/[\\/]/).some((segment) => segment.startsWith(".") && segment !== ".."),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user