Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Update checks send no validator back to a feed

Țugui Dragoșe42cbc4acf12
diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift
index 67e7c286..922aa3ab 100644
--- a/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Updates/UpdateChecker.swift
@@ -6,8 +6,9 @@ public struct UpdateChecker: Sendable {
private static let maximumFeedBytes = 4 * 1_024 * 1_024
/// Settings for Peel's own session, used instead of the shared one: no cookies, no cache, and time limits.
- /// A feed server should not set a cookie, read one left by another app's check, or hold a connection open.
- private static var configuration: URLSessionConfiguration {
+ /// A feed server should not set a cookie, read one left by another app's check, get back a validator it could
+ /// make unique to this Mac, or hold a connection open.
+ static var configuration: URLSessionConfiguration {
let configuration = URLSessionConfiguration.ephemeral
configuration.timeoutIntervalForRequest = 15
configuration.timeoutIntervalForResource = 30
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UpdatePrivacyTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UpdatePrivacyTests.swift
index d354670f..12c13f9a 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/UpdatePrivacyTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/UpdatePrivacyTests.swift
@@ -1,5 +1,5 @@
import Foundation
-import PeelCore
+@testable import PeelCore
import Synchronization
import Testing
@@ -37,4 +37,13 @@ private final class RecordingProtocol: URLProtocol, @unchecked Sendable {
#expect(await checker.status(for: sold, preference: .appStore) == .failed)
#expect(RecordingProtocol.hosts.withLock { $0 } == ["itunes.apple.com"])
}
+
+ /// A feed server can make an `ETag` or a date unique to one Mac and read it back in the next request (RFC 9110,
+ /// section 17.14), so the session keeps no cache that would send one back.
+ @Test func keepsNothingAFeedServerCouldReadBack() {
+ let configuration = UpdateChecker.configuration
+ #expect(configuration.urlCache == nil)
+ #expect(configuration.requestCachePolicy == .reloadIgnoringLocalCacheData)
+ #expect(configuration.httpCookieStorage == nil)
+ }
}