feat: enforce resolved catalog path roles

This commit is contained in:
codex
2026-08-05 14:57:16 +03:00
parent 6fd670d08a
commit d6ed0ac592
3 changed files with 24 additions and 4 deletions
@@ -7,14 +7,14 @@ namespace Launcher.Next.Infrastructure;
/// local immutable staging by <see cref="IPackageSynchronizer"/>; it is never
/// an active launch root.
/// </summary>
public sealed class FileSystemCatalogPackageAcquirer(string catalogRoot) : IPackageCatalogPackageAcquirer
public sealed class FileSystemCatalogPackageAcquirer(ResolvedCatalogRoot catalogRoot) : IPackageCatalogPackageAcquirer
{
private const int MaxFiles = 256;
private const long MaxBytes = 512L * 1024 * 1024;
public async Task<CatalogPackage?> AcquireAsync(PackageRequirement requirement, CancellationToken cancellationToken)
{
var root = Path.GetFullPath(catalogRoot);
var root = catalogRoot.Value;
var candidate = Path.GetFullPath(Path.Combine(root, requirement.PackageId, requirement.RequiredVersion));
if (!Directory.Exists(root) || IsReparsePoint(root) || !IsWithin(root, candidate) || !Directory.Exists(candidate) || IsReparsePoint(candidate))
return null;