function compareMountsByContainerPath(a: SandboxFsMount, b: SandboxFsMount): number { const byLength = b.containerRoot.length - a.containerRoot.length; if (byLength !== 0) { return byLength;
} // Keep resolver ordering aligned with docker mount precedence: custom binds can // intentionally shadow default workspace mounts at the same container path. return mountSourcePriority(b.source) - mountSourcePriority(a.source);
}
function compareMountsByHostPath(a: SandboxFsMount, b: SandboxFsMount): number { const byLength = b.hostRoot.length - a.hostRoot.length; if (byLength !== 0) { return byLength;
} return mountSourcePriority(b.source) - mountSourcePriority(a.source);
}
function mountSourcePriority(source: SandboxFsMount["source"]): number { if (source === "bind") { return2;
} if (source === "agent") { return1;
} return0;
}
function dedupeMounts(mounts: SandboxFsMount[]): SandboxFsMount[] { const seen = new Set<string>(); const deduped: SandboxFsMount[] = []; for (const mount of mounts) { const key = `${mount.hostRoot}=>${mount.containerRoot}`; if (seen.has(key)) { continue;
}
seen.add(key);
deduped.push(mount);
} return deduped;
}
function findMountByContainerPath(mounts: SandboxFsMount[], target: string): SandboxFsMount | null { for (const mount of mounts) { if (isPathInsideContainerRoot(mount.containerRoot, target)) { return mount;
}
} returnnull;
}
function findMountByHostPath(mounts: SandboxFsMount[], target: string): SandboxFsMount | null { for (const mount of mounts) { if (isPathInsideHost(mount.hostRoot, target)) { return mount;
}
} returnnull;
}
function isPathInsideHost(root: string, target: string): boolean { const canonicalRoot = resolveSandboxHostPathViaExistingAncestor(path.resolve(root)); const resolvedTarget = path.resolve(target); // Preserve the final path segment so pre-existing symlink leaves are validated // by the dedicated symlink guard later in the bridge flow. const canonicalTargetParent = resolveSandboxHostPathViaExistingAncestor(
path.dirname(resolvedTarget),
); const canonicalTarget = path.resolve(canonicalTargetParent, path.basename(resolvedTarget)); const rel = path.relative(canonicalRoot, canonicalTarget); if (!rel) { returntrue;
} return !(rel.startsWith("..") || path.isAbsolute(rel));
}
function toHostSegments(relativePosix: string): string[] { return relativePosix.split("/").filter(Boolean);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.