mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:10:45 +00:00
fix(plugins): harden bundled runtime dep staging
This commit is contained in:
@@ -183,6 +183,12 @@ function assertSafeInstalledDistPath(relativePath, params) {
|
||||
return candidatePath;
|
||||
}
|
||||
|
||||
function isStagedRuntimeNodeModulesPath(relativePath) {
|
||||
return /^dist\/extensions\/[^/]+\/node_modules(?:\/|$)/u.test(
|
||||
normalizeRelativePath(relativePath),
|
||||
);
|
||||
}
|
||||
|
||||
function listInstalledDistFiles(params = {}) {
|
||||
const readDir = params.readdirSync ?? readdirSync;
|
||||
const distRoot = resolveInstalledDistRoot(params);
|
||||
@@ -197,6 +203,10 @@ function listInstalledDistFiles(params = {}) {
|
||||
if (!currentDir) {
|
||||
continue;
|
||||
}
|
||||
const relativeCurrentDir = normalizeRelativePath(relative(packageRoot, currentDir));
|
||||
if (isStagedRuntimeNodeModulesPath(relativeCurrentDir)) {
|
||||
continue;
|
||||
}
|
||||
for (const entry of readDir(currentDir, { withFileTypes: true })) {
|
||||
const entryPath = join(currentDir, entry.name);
|
||||
if (entry.isSymbolicLink()) {
|
||||
@@ -232,6 +242,10 @@ function pruneEmptyDistDirectories(params = {}) {
|
||||
const pathLstat = params.lstatSync ?? lstatSync;
|
||||
|
||||
function prune(currentDir) {
|
||||
const relativeCurrentDir = normalizeRelativePath(relative(packageRoot, currentDir));
|
||||
if (isStagedRuntimeNodeModulesPath(relativeCurrentDir)) {
|
||||
return;
|
||||
}
|
||||
for (const entry of readDir(currentDir, { withFileTypes: true })) {
|
||||
if (entry.isSymbolicLink()) {
|
||||
throw new Error(
|
||||
|
||||
Reference in New Issue
Block a user