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

Redesigned the framework to make it less vulnerable to native exceptions. #955

Merged
merged 3 commits into from
Oct 20, 2022

Conversation

radetsky
Copy link
Contributor

@radetsky radetsky commented Oct 3, 2022

Second attempt. Excuse me for the formatting issue, but my eyes already can not work with 2 spaces.

  1. I have made changes to the code that should catch any exceptions.
  2. All suggestions from the previous PR are included and fixed.
  3. Examples and tests will be included as different PR.

Copy link
Collaborator

@ilammy ilammy left a comment

Choose a reason for hiding this comment

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

Much better, good job 👍

It would be nice to get some tests for 2- vs. 3-argument forms of Secure Message signatures, and this should be good for merge.

@vixentael
Copy link
Contributor

can we please split formatting PR and real value PR?

Mixing those two makes reviewing harder. Plus, why exactly do we do formatting as a hotfix into release branch?

@vixentael
Copy link
Contributor

Basically, everything that @ilammy said here
#951 (comment)

Copy link
Contributor

@vixentael vixentael left a comment

Choose a reason for hiding this comment

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

This is a great PR, thank you @radetsky for implementing all the changes.

I have couple of questions / concerns.

  1. Error handling on iOS side. I can be wrong, but from my perspective, we should check "if error != nil" as well.

  2. Breaking changes. As I understood, we switched from the "exception" based flow to the "error" based flow. I'd consider this a breaking change that affects 0.14.X users.

Keeping in mind your desire to improve SecureMessage interface (remove private/public key where they are not needed), what do you think about making this PR a part of 0.15.0 instead?

NSError *error;

cell = [self newSealMode:symmetricKey error:&error];
if (cell == nil) {
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we check for error here as well? is it possible to have error and non-nil cell?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#951 (comment)
We already discussed it with @ilammy
He asked me to make it right.

Copy link
Contributor

@vixentael vixentael Oct 12, 2022

Choose a reason for hiding this comment

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

@ilammy asked you to check that value is not nil, not to stop checking if error is present.

I suggest you check both, that "if value == nil OR error != nil".

My suggestions are based on a certain paranoia level, the "Of course, it is never null in the current version of the code" argument, and Cocoa Error handling guides:

if (!theData && theError)
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/CreateCustomizeNSError/CreateCustomizeNSError.html#//apple_ref/doc/uid/TP40001806-CH204-BAJIIGCC

if (xmlDoc == nil && err)
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/RecoverFromErrors/RecoverFromErrors.html#//apple_ref/doc/uid/TP40001806-CH206-BCIDEGGF

Please pay attention that Cocoa guides use "AND" while I suggesting using "OR": the object was not created OR the error occurred.

Copy link
Contributor

Choose a reason for hiding this comment

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

@radetsky didn't get any comments from you here.

src/wrappers/themis/react-native-themis/ios/RCTThemis.m Outdated Show resolved Hide resolved
src/wrappers/themis/react-native-themis/ios/RCTThemis.m Outdated Show resolved Hide resolved
@radetsky
Copy link
Contributor Author

We do not do breaking changes. iOS principal error handling was reworked because of suggestions from @ilammy and Apple Developer documentation. But the interface of the library was not changed. I spent a lot of time writing an application with tests to check and prove it.

@vixentael
Copy link
Contributor

We do not do breaking changes. iOS principal error handling was reworked because of suggestions from @ilammy and Apple Developer documentation

Does the previous published Themis RN wrapper version uses the exception flow?

@vixentael
Copy link
Contributor

@radetsky does the previous published Themis RN wrapper version uses the exception flow? Because now I see that we switched to the error flow.

@vixentael vixentael added the O-ReactNative ⚛️ ReactNative platform label Oct 20, 2022
@vixentael
Copy link
Contributor

okay, @radetsky says that switching between exception flow and error flow affects only internal logic, the interface for the user is the same. let's merge

@vixentael vixentael merged commit 04ba4b9 into release/0.14 Oct 20, 2022
radetsky added a commit that referenced this pull request Nov 1, 2022
…ons. (#955)

* redesigned the framework to make it less vulnerable to native exceptions. Second try.

* restore previous format

* no more short names
radetsky added a commit that referenced this pull request Nov 1, 2022
…ons. (#955)

* redesigned the framework to make it less vulnerable to native exceptions. Second try.

* restore previous format

* no more short names
radetsky added a commit that referenced this pull request Nov 1, 2022
…ons. (#955) (#962)

* redesigned the framework to make it less vulnerable to native exceptions. Second try.

* restore previous format

* no more short names
@radetsky radetsky deleted the react-native-themis-0.14.10 branch November 2, 2022 15:40
@ilammy ilammy added this to the 0.14.0 milestone Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-ReactNative ⚛️ ReactNative platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants