Skip to content

Commit 6995433

Browse files
authored
Limit cache directories (#7225)
Manifest loading dumps serialized diagnostics files into the manifest cache, that's why the sandbox needs an exception for that. This generally seems a bit odd, but firstly, we can limit the access to the subdirectory that is actually being used instead of the entire cache.
1 parent cf6f4ae commit 6995433

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/PackageLoading/ManifestLoader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ public final class ManifestLoader: ManifestLoaderProtocol {
968968
// This provides some safety against arbitrary code execution when parsing manifest files.
969969
// We only allow the permissions which are absolutely necessary.
970970
if self.isManifestSandboxEnabled {
971-
let cacheDirectories = [self.databaseCacheDir, moduleCachePath].compactMap{ $0 }
971+
let cacheDirectories = [self.databaseCacheDir?.appending("ManifestLoading"), moduleCachePath].compactMap{ $0 }
972972
let strictness: Sandbox.Strictness = toolsVersion < .v5_3 ? .manifest_pre_53 : .default
973973
do {
974974
cmd = try Sandbox.apply(command: cmd, fileSystem: localFileSystem, strictness: strictness, writableDirectories: cacheDirectories)

0 commit comments

Comments
 (0)