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

use none-deprecated archive functions when possible #394

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ShiCheng-Lu
Copy link
Contributor

@ShiCheng-Lu ShiCheng-Lu commented Sep 24, 2024

The archive function that we were using was deprecated, and it was giving security warnings to customers integrating the SDK. The new, secure archive functions were introduces with iOS 11.0. So for iOS 11.0 +, we are switching to using the secure archive functions in order to avoid security issues.

I the archiving and unarchiving of RadarLog is already tested. I tested it with original archiving with new unarchiving just to make sure that previously saved data do not become invalid after this function change.

For RadarReplay, I added the test for archiving and unarchiving by creating the replayParam the same way it was created in /track, then using the writeNewReplayToBuffer and loadReplaysFromPersistentStore methods to verify the archiving/unarchiving is working. Same test with old archiving to verify updating sdk doesn't invalidate existing stored data.

(+267 lines might look scary, but most of it is in RadarTestUtil to construct the track param for replay test)

@ShiCheng-Lu ShiCheng-Lu force-pushed the shicheng/fence-2079-switch-from-unarchiveobjectwithdata-to branch from 758811d to 7e87e5e Compare September 25, 2024 13:20
[[NSUserDefaults standardUserDefaults] setObject:replaysData forKey:@"radar-replays"];
}

- (void)loadReplaysFromPersistentStore {
NSData *replaysData = [[NSUserDefaults standardUserDefaults] objectForKey:@"radar-replays"];
if (replaysData) {
NSArray *replays = [NSKeyedUnarchiver unarchiveObjectWithData:replaysData];
NSArray *replays;
if (@available(iOS 11.0, *)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused about iOS 11 version gate since NSSecureCoding is available from iOS 6

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the archivedDataWithRootObject: requireingSecureCoding: function is only introduced in iOS 11.0. the function that we were using (without the second param) is the one raising security alerts.

@@ -18,4 +18,181 @@ + (NSDictionary *)jsonDictionaryFromResource:(NSString *)resource {
return jsonDict;
}

+ (NSMutableDictionary *)createTrackParamWithLocation:(CLLocation *_Nonnull)location
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess using the default values returned by radarState and radarSettings is perfectly fine in this case, but can we just put a comment noting that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added function docstring in the header file for this behaviour

@@ -1489,6 +1490,22 @@ - (void)test_RadarLogBuffer_purge {
[[RadarLogBuffer sharedInstance]clearBuffer];
}

- (void)test_RadarReplayBuffer_writeAndRead {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for adding this test

…used for RadarTestUtils.createTrackParamWithLocation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants