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

Prevent uploads from crashing with bad JSON #1063

Merged
merged 1 commit into from
Apr 6, 2021

Conversation

nickdowell
Copy link
Contributor

@nickdowell nickdowell commented Apr 6, 2021

Goal

If the metadata JSON contains non-object values at the top level, an exception will be thrown from -[BugsnagEvent sanitiseMetadata:redactedKeys:]

Changeset

-[BugsnagEvent sanitiseMetadata:redactedKeys:] now rejects top-level values that are are not dictionaries, and leaves a diagnostic showing the unexpected data.

@try / @catch blocks have also been added to prevent any other exceptions from causing a crash while preparing the payload for upload.

Testing

Tested locally by adding bad data to NSMutableDictionary *metadata before calling -[BugsnagEvent sanitiseMetadata:redactedKeys:]

@nickdowell nickdowell force-pushed the nickdowell/catch-json-exceptions branch from f28d260 to 17c44b0 Compare April 6, 2021 14:47
@github-actions
Copy link

github-actions bot commented Apr 6, 2021

Infer: No issues found 🎉

OCLint: No issues found 🎉

Bugsnag.framework binary size increased by 48 bytes from 1,102,912 to 1,102,960

Generated by 🚫 Danger

@nickdowell nickdowell marked this pull request as ready for review April 6, 2021 14:58
@nickdowell nickdowell requested review from kattrali and kstenerud April 6, 2021 14:59
@nickdowell nickdowell merged commit 05b6524 into next Apr 6, 2021
@nickdowell nickdowell deleted the nickdowell/catch-json-exceptions branch April 6, 2021 16:07
@nickdowell nickdowell mentioned this pull request Apr 7, 2021
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