-
Notifications
You must be signed in to change notification settings - Fork 11
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
Fix secure coding error #2604
Fix secure coding error #2604
Conversation
|
||
public required init?(coder: NSCoder) { | ||
oneTimeError = coder.decodeObject(forKey: NSSecureCodingKeys.oneTimeError) as? Error | ||
operationErrors = coder.decodeObject(forKey: NSSecureCodingKeys.operationErrors) as? [Error] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should do something if these fail, but then also not sure if we can ever know since they're optional?
Would they ever fail? It feels like they shouldn't...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://developer.apple.com/documentation/foundation/nssecurecoding
I've zero idea if this may break in some way... but if we want to adhere to secure coding strictly, we should decode using decodeObject(of:forKey)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing everything looks good to me, and logically this should work. The mistake is pretty obvious, with a clear fix. I also tested with nil/no errors and it worked.
Let's see if Diego has any nonobvious pitfalls though
oneTimeError = coder.decodeObject(forKey: NSSecureCodingKeys.oneTimeError) as? Error | ||
operationErrors = coder.decodeObject(forKey: NSSecureCodingKeys.operationErrors) as? [Error] | ||
oneTimeError = coder.decodeObject(of: NSError.self, forKey: NSSecureCodingKeys.oneTimeError) | ||
operationErrors = coder.decodeArrayOfObjects(ofClass: NSError.self, forKey: NSSecureCodingKeys.operationErrors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me.
Task/Issue URL: https://app.asana.com/0/1203581873609357/1207056719863102/f
Description:
Fix issue sending XPC messages on error
Steps to test this PR:
/Library/Group\ Containers/HKE973VLUW.com.duckduckgo.macos.browser.dbp*
macos-browser/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionProcessor.swift
Line 64 in 4a45c4b
Internal references:
Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation