Apply code-review fixes: identity/pagination, load races, TLS pin, leaks
Addresses a multi-agent code review (26 confirmed findings + a URLSession leak) across correctness, concurrency, security, and cleanup: - MongoDocument.id: deterministic fallback (was UUID() on every access) to stop SwiftUI List/ForEach identity churn; getAll pagination drives its cursor off the real _id via documentId, so a missing _id stops paging instead of looping on a fabricated cursor. - View models: per-load generation guard (+ captured-tab guard on ONU detail) so a cancelled or overlapping load can't commit stale results or land data on the wrong tab. - JSONValue.intValue: guard Int(d) against NaN/inf/out-of-range (crash). - ServerTrustEvaluator: hash the real SubjectPublicKeyInfo (prepend the algorithm-specific ASN.1 SPKI header) so a standard openssl-captured public-key pin actually matches; unknown key types fail closed. - AppEnvironment.configure: clear stale cookies + Keychain creds on host change. - FirmwareFile.isCompatible: empty metadata no longer passes as compatible-for-all. - APIClient: invalidate URLSession on deinit (per-configure/probe leak). - Dashboard best-effort sections keep last-good on transient failure; unified optical thresholds; LoginView prefill-once; populatedBuckets unique ForEach id; Format rounding rollover; dead-code/docstring/dedup cleanups. Verification pending on the Mac (no Swift toolchain on the Linux dev box). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8de962eeb8
commit
203465913c
21 changed files with 303 additions and 103 deletions
|
|
@ -11,7 +11,7 @@ final class OLTRepository {
|
|||
}
|
||||
|
||||
func allConfigs() async throws -> [OLTConfigDoc] {
|
||||
try await client.getAll(.oltConfigs, idOf: { $0.id })
|
||||
try await client.getAll(.oltConfigs, idOf: { $0.documentId })
|
||||
}
|
||||
|
||||
/// Map of OLT id → operator name (`OLT.Name`), via projection. Skips names
|
||||
|
|
@ -19,7 +19,7 @@ final class OLTRepository {
|
|||
func nameMap() async throws -> [String: String] {
|
||||
var query = APIQuery()
|
||||
query.projection = ["OLT.Name": 1]
|
||||
let configs: [OLTConfigDoc] = try await client.getAll(.oltConfigs, baseQuery: query, idOf: { $0.id })
|
||||
let configs: [OLTConfigDoc] = try await client.getAll(.oltConfigs, baseQuery: query, idOf: { $0.documentId })
|
||||
return configs.reduce(into: [:]) { map, config in
|
||||
if let name = config.name, !name.isEmpty, name != config.id { map[config.id] = name }
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ final class OLTRepository {
|
|||
}
|
||||
|
||||
func allStates() async throws -> [OLTStateDoc] {
|
||||
try await client.getAll(.oltStates, idOf: { $0.id })
|
||||
try await client.getAll(.oltStates, idOf: { $0.documentId })
|
||||
}
|
||||
|
||||
func state(id: String) async throws -> OLTStateDoc {
|
||||
|
|
@ -88,6 +88,10 @@ final class OLTRepository {
|
|||
let _: JSONValue = try await client.action("PUT", .oltReset(id: id), as: JSONValue.self)
|
||||
}
|
||||
|
||||
// NOTE: the four methods below (disable-onu / broadcast-enable + their pending
|
||||
// reads) are not yet wired to any screen. Their request shapes are documented
|
||||
// but UNEXERCISED — verify against a live box before building UI on them.
|
||||
|
||||
/// `PUT /olts/<olt>/disable-onu/<onu>/` with body `{ "disable": Bool }` (unwrapped).
|
||||
func setONUDisabled(olt: String, onu: String, disabled: Bool) async throws {
|
||||
let _: JSONValue = try await client.send(
|
||||
|
|
@ -127,7 +131,7 @@ final class ControllerRepository {
|
|||
}
|
||||
|
||||
func allConfigs() async throws -> [ControllerConfigDoc] {
|
||||
try await client.getAll(.controllerConfigs, idOf: { $0.id })
|
||||
try await client.getAll(.controllerConfigs, idOf: { $0.documentId })
|
||||
}
|
||||
|
||||
func config(id: String) async throws -> ControllerConfigDoc {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue