mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
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:
@@ -20,7 +20,8 @@ import {
|
||||
buildAudioSidecar,
|
||||
buildProbeFacts,
|
||||
hashProjectDir,
|
||||
listSiteFiles,
|
||||
isPrivateSitePath,
|
||||
listSiteFilesForUpload,
|
||||
wantsAudioSidecar,
|
||||
wantsProbeFacts,
|
||||
} from "@hyperframes/producer/distributed";
|
||||
@@ -116,7 +117,9 @@ export async function ensureSiteStored(
|
||||
} catch (error) {
|
||||
if ((error as Error).name !== "PLAN_ARTIFACT_MISSING") throw error;
|
||||
const localPath = projectDir && join(projectDir, path);
|
||||
if (!localPath || !(await hasContent(localPath, sha256))) return void missing.push(path);
|
||||
const reupload =
|
||||
localPath && !isPrivateSitePath(path) && (await hasContent(localPath, sha256));
|
||||
if (!reupload) return void missing.push(path);
|
||||
await putContentStoreFile(s3, localPath, bucket, sha256);
|
||||
}
|
||||
});
|
||||
@@ -156,7 +159,7 @@ export async function deploySite(opts: DeploySiteOptions): Promise<SiteHandle> {
|
||||
if (!statSync(opts.projectDir).isDirectory()) {
|
||||
throw new Error(`[deploySite] projectDir is not a directory: ${opts.projectDir}`);
|
||||
}
|
||||
const files = listSiteFiles(opts.projectDir);
|
||||
const files = listSiteFilesForUpload(opts.projectDir, opts.onNotice);
|
||||
const siteId = opts.siteId ?? hashProjectDir(opts.projectDir, files);
|
||||
const projectS3Uri = siteManifestUri(opts.bucketName, siteId);
|
||||
|
||||
|
||||
@@ -4,7 +4,12 @@ import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import type { SFNClient } from "@aws-sdk/client-sfn";
|
||||
import type { SerializableDistributedRenderConfig } from "../events.js";
|
||||
import { SITE_MANIFEST_INVALID } from "../siteManifest.js";
|
||||
import { createHash } from "node:crypto";
|
||||
import {
|
||||
parseSiteManifest,
|
||||
SITE_MANIFEST_INVALID,
|
||||
serializeSiteManifest,
|
||||
} from "../siteManifest.js";
|
||||
import { asS3Client, FakeS3 } from "./__fixtures__/fakeS3.js";
|
||||
import { deploySite, type SiteHandle, siteHandleFromId } from "./deploySite.js";
|
||||
import { renderToLambda } from "./renderToLambda.js";
|
||||
@@ -272,6 +277,26 @@ describe("renderToLambda", () => {
|
||||
expect(sfn.starts).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("never re-uploads a private file an older site manifest still lists", async () => {
|
||||
const s3 = new FakeS3();
|
||||
const sfn = new FakeSFN();
|
||||
const site = await deploySite({ projectDir, bucketName: "test-bucket", s3: asS3Client(s3) });
|
||||
const token = "//registry.npmjs.org/:_authToken=secret";
|
||||
writeFileSync(join(projectDir, ".npmrc"), token);
|
||||
const manifestId = `test-bucket/sites/${site.siteId}/files.json`;
|
||||
const files = parseSiteManifest(s3.bodies.get(manifestId)!.toString());
|
||||
const sha256 = createHash("sha256").update(token).digest("hex");
|
||||
files.push({ path: ".npmrc", sha256, sizeBytes: token.length });
|
||||
s3.bodies.set(manifestId, Buffer.from(serializeSiteManifest(files)));
|
||||
s3.ops.length = 0;
|
||||
|
||||
await expect(renderWith(s3, sfn, site, projectDir)).rejects.toMatchObject({
|
||||
name: "SITE_FILES_MISSING",
|
||||
});
|
||||
expect(s3.ops.filter((op) => op.kind === "put")).toHaveLength(0);
|
||||
expect(sfn.starts).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("without a project dir, refuses with the missing-file count before starting", async () => {
|
||||
const s3 = new FakeS3();
|
||||
const sfn = new FakeSFN();
|
||||
|
||||
Reference in New Issue
Block a user