mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Force POSIX style path separators for manifest generation (#30287)
* force POSIX style path separators * include posix style for symbolic links * include in error string
This commit is contained in:
@@ -7,19 +7,22 @@ const MANIFEST_FILE = 'MANIFEST.txt';
|
||||
|
||||
async function* walk(dir: string, baseDir: string): AsyncGenerator<string, any, any> {
|
||||
for await (const d of await (fs.promises as any).opendir(dir)) {
|
||||
const entry = path.join(dir, d.name);
|
||||
const entry = path.posix.join(dir, d.name);
|
||||
if (d.isDirectory()) {
|
||||
yield* await walk(entry, baseDir);
|
||||
} else if (d.isFile()) {
|
||||
yield path.relative(baseDir, entry);
|
||||
yield path.posix.relative(baseDir, entry);
|
||||
} else if (d.isSymbolicLink()) {
|
||||
const realPath = fs.realpathSync(entry);
|
||||
if (!realPath.startsWith(baseDir)) {
|
||||
throw new Error(
|
||||
`symbolic link ${path.relative(baseDir, entry)} targets a file outside of the base directory: ${baseDir}`
|
||||
`symbolic link ${path.posix.relative(
|
||||
baseDir,
|
||||
entry
|
||||
)} targets a file outside of the base directory: ${baseDir}`
|
||||
);
|
||||
}
|
||||
yield path.relative(baseDir, entry);
|
||||
yield path.posix.relative(baseDir, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user