Commit 06061c87 by Dan Cech Committed by GitHub

skip symlinks to directories when generating plugin manifest (#30721)

parent 52a8f2bf
......@@ -13,7 +13,7 @@ async function* walk(dir: string, baseDir: string): AsyncGenerator<string, any,
} else if (d.isFile()) {
yield path.posix.relative(baseDir, entry);
} else if (d.isSymbolicLink()) {
const realPath = fs.realpathSync(entry);
const realPath = await (fs.promises as any).realpath(entry);
if (!realPath.startsWith(baseDir)) {
throw new Error(
`symbolic link ${path.posix.relative(
......@@ -22,9 +22,13 @@ async function* walk(dir: string, baseDir: string): AsyncGenerator<string, any,
)} targets a file outside of the base directory: ${baseDir}`
);
}
// if resolved symlink target is a file include it in the manifest
const stats = await (fs.promises as any).stat(realPath);
if (stats.isFile()) {
yield path.posix.relative(baseDir, entry);
}
}
}
}
export async function buildManifest(dir: string): Promise<ManifestInfo> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment