Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate appID from UUID type to String to avoid potential for crashes #218

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/TelemetryDeck/Signals/Signal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct SignalPostBody: Codable, Equatable {
let receivedAt: Date

/// The App ID of this signal
let appID: UUID
let appID: String

/// A user identifier. This should be hashed on the client, and will be hashed + salted again
/// on the server to break any connection to personally identifiable data.
Expand Down
2 changes: 1 addition & 1 deletion Sources/TelemetryDeck/Signals/SignalManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ final class SignalManager: SignalManageable, @unchecked Sendable {

let signalPostBody = SignalPostBody(
receivedAt: Date(),
appID: UUID(uuidString: configuration.telemetryAppID)!,
appID: configuration.telemetryAppID,
clientUser: CryptoHashing.sha256(string: customUserID ?? defaultUserIdentifier, salt: configuration.salt),
sessionID: configuration.sessionID.uuidString,
type: "\(signalName)",
Expand Down
32 changes: 16 additions & 16 deletions Tests/TelemetryDeckTests/TelemetryDeckTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ struct TelemetryDeckTests {
let signalCache = SignalCache<SignalPostBody>(logHandler: nil)

let signals: [SignalPostBody] = [
.init(receivedAt: Date(), appID: UUID(), clientUser: "01", sessionID: "01", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "02", sessionID: "02", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "03", sessionID: "03", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "04", sessionID: "04", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "05", sessionID: "05", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "06", sessionID: "06", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "07", sessionID: "07", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "08", sessionID: "08", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "09", sessionID: "09", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "10", sessionID: "10", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "11", sessionID: "11", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "12", sessionID: "12", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "13", sessionID: "13", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "14", sessionID: "14", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID(), clientUser: "15", sessionID: "15", type: "test", floatValue: nil, payload: [:], isTestMode: "true")
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "01", sessionID: "01", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "02", sessionID: "02", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "03", sessionID: "03", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "04", sessionID: "04", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "05", sessionID: "05", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "06", sessionID: "06", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "07", sessionID: "07", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "08", sessionID: "08", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "09", sessionID: "09", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "10", sessionID: "10", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "11", sessionID: "11", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "12", sessionID: "12", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "13", sessionID: "13", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "14", sessionID: "14", type: "test", floatValue: nil, payload: [:], isTestMode: "true"),
.init(receivedAt: Date(), appID: UUID().uuidString, clientUser: "15", sessionID: "15", type: "test", floatValue: nil, payload: [:], isTestMode: "true")
]

for signal in signals {
Expand Down Expand Up @@ -194,7 +194,7 @@ private class FakeSignalManager: @preconcurrency SignalManageable {

let signalPostBody = SignalPostBody(
receivedAt: Date(),
appID: UUID(uuidString: configuration.telemetryAppID)!,
appID: configuration.telemetryAppID,
clientUser: customUserID ?? "no user",
sessionID: configuration.sessionID.uuidString,
type: "\(signalType)",
Expand Down
Loading