Skip to content

Commit 01c8c16

Browse files
committed
fix(github-actions): properly assess the full path for artifact metadata (#2470)
Properly find the full path for artifact metadata, previously we were comparing a full path against a relative path which would always fail PR Close #2470
1 parent 06f921f commit 01c8c16

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

github-actions/previews/upload-artifacts-to-firebase/extract-artifact-metadata.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19398,11 +19398,14 @@ var artifactMetadata = {
1939819398
//
1939919399
async function main() {
1940019400
const [artifactDirPath] = process.argv.slice(2);
19401+
const fullArtifactDirPath = await fs.promises.realpath(artifactDirPath);
1940119402
for (const [key, name] of Object.entries(artifactMetadata)) {
19402-
const expectedPath = path.join(artifactDirPath, name);
19403+
const expectedPath = path.normalize(path.join(fullArtifactDirPath, name));
1940319404
const realPath = await fs.promises.realpath(expectedPath);
1940419405
if (expectedPath !== realPath) {
19405-
throw Error(`Value for unsafe-${key} not stored directly in file as expected, instead stored in ${realPath}`);
19406+
throw Error(`Value for unsafe-${key} not stored directly in file as expected,
19407+
expected: ${expectedPath}
19408+
got: ${realPath}`);
1940619409
}
1940719410
const content = await fs.promises.readFile(expectedPath, "utf8");
1940819411
const outputName = `unsafe-${key}`;

github-actions/previews/upload-artifacts-to-firebase/lib/extract-artifact-metadata.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,19 @@ import {artifactMetadata} from '../../constants.js';
2121

2222
async function main() {
2323
const [artifactDirPath] = process.argv.slice(2);
24+
/** The full path to the artifact directory. */
25+
const fullArtifactDirPath = await fs.promises.realpath(artifactDirPath);
2426

2527
for (const [key, name] of Object.entries(artifactMetadata)) {
2628
/** The expected path of the artifact */
27-
const expectedPath = path.join(artifactDirPath, name);
29+
const expectedPath = path.normalize(path.join(fullArtifactDirPath, name));
2830

2931
// We confirm that the provided artifact path is actually in the expected location instead of pointing somewhere
3032
// else to exfiltrate information.
3133
const realPath = await fs.promises.realpath(expectedPath);
3234
if (expectedPath !== realPath) {
3335
throw Error(
34-
`Value for unsafe-${key} not stored directly in file as expected, instead stored in ${realPath}`,
36+
`Value for unsafe-${key} not stored directly in file as expected,\n expected: ${expectedPath}\n got: ${realPath}`,
3537
);
3638
}
3739

0 commit comments

Comments
 (0)