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

Make use of SQLITE_OPEN_FILEPROTECTION_COMPLETEUNTILFIRSTUSERAUTHENTICATION conditional. #12548

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

cprince-foreflight
Copy link
Contributor

@cprince-foreflight cprince-foreflight commented Mar 13, 2024

#10884

Testing

  • I ran Firebase remote config tests locally.

…CATION conditional for use of custom sqlite3.
Copy link

google-cla bot commented Mar 13, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@paulb777
Copy link
Member

Thanks! This is a much simpler solution than completely replacing sqlite. What is the implication of running without the SQLITE_OPEN_FILEPROTECTION_COMPLETEUNTILFIRSTUSERAUTHENTICATION when it's not available?

@cprince-foreflight
Copy link
Contributor Author

cprince-foreflight commented Mar 15, 2024

Thanks! This is a much simpler solution than completely replacing sqlite. What is the implication of running without the SQLITE_OPEN_FILEPROTECTION_COMPLETEUNTILFIRSTUSERAUTHENTICATION when it's not available?

Well, good question :). I see basically no docs for this. E.g., I wouldn't call this docs. I'm assuming from the naming that it relates to standard concepts of file protection/encryption with iOS.

I'm about to test this in our app (hence the DRAFT status), and hopefully my colleague aaron-foreflight will add his 2 cents.

@ncooke3
Copy link
Member

ncooke3 commented Mar 15, 2024

@cprince-foreflight, thanks! I think one case worth checking will be the following:

  1. use Remote Config without this change to initialize DB
  2. try to access the same DB again (without deleting the app) with the change
    This could help rule out the risk of the pre-change DB becoming inaccessible when it is accessed with one less flag after upgrading.

@cprince-foreflight
Copy link
Contributor Author

@cprince-foreflight, thanks! I think one case worth checking will be the following:

  1. use Remote Config without this change to initialize DB
  2. try to access the same DB again (without deleting the app) with the change
    This could help rule out the risk of the pre-change DB becoming inaccessible when it is accessed with one less flag after upgrading.

Definitely. And I think it's particularly important for step 2), when SQLITE_OPEN_FILEPROTECTION_COMPLETEUNTILFIRSTUSERAUTHENTICATION is not defined. Shall have to stare at this a bit to see if I can test it. Our use isn't exactly simple :).

@aaron-foreflight
Copy link

Thanks! This is a much simpler solution than completely replacing sqlite. What is the implication of running without the SQLITE_OPEN_FILEPROTECTION_COMPLETEUNTILFIRSTUSERAUTHENTICATION when it's not available?

I don't know the answer to this. A brave soul could dig through this aborted patch from Apple and maybe figure it out: https://www2.sqlite.org/src/info/c8ade949d4a2eb3b

@cprince-foreflight
Copy link
Contributor Author

@cprince-foreflight, thanks! I think one case worth checking will be the following:

  1. use Remote Config without this change to initialize DB
  2. try to access the same DB again (without deleting the app) with the change
    This could help rule out the risk of the pre-change DB becoming inaccessible when it is accessed with one less flag after upgrading.

Definitely. And I think it's particularly important for step 2), when SQLITE_OPEN_FILEPROTECTION_COMPLETEUNTILFIRSTUSERAUTHENTICATION is not defined. Shall have to stare at this a bit to see if I can test it. Our use isn't exactly simple :).

Well. Hmmm. My first thought to test this was to put together a demo/test app that creates a RCNConfigDBManager instance to try the tests above. However, it seems like RCNConfigDBManager isn't in scope when using the package imports.

So, I had to hack a bit, but got there. I added in a "testDb" static method to the "RemoteConfig" class which I can access from my app. That method is defined as:

+ (void) testDb {
    RCNConfigDBManager *manager = [[RCNConfigDBManager alloc] init];
}

And I call this from my test app that I run an iOS simulator.

Test 1

To start with, I deleted the app.

This has the original flags code:

 int flags = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE |
              SQLITE_OPEN_FILEPROTECTION_COMPLETEUNTILFIRSTUSERAUTHENTICATION |
              SQLITE_OPEN_FULLMUTEX;

I set various breakpoints after that and when I run my test, I get to:
Screenshot 2024-04-02 at 3 09 19 PM

That is here.

After it gets to this breakpoint, I let it continue execution.

Test 2

I then stop the app. I do not remove it.
I change to the new flag code:

int flags = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE | SQLITE_OPEN_FULLMUTEX;
#ifdef SQLITE_OPEN_FILEPROTECTION_COMPLETEUNTILFIRSTUSERAUTHENTICATION
flags |= SQLITE_OPEN_FILEPROTECTION_COMPLETEUNTILFIRSTUSERAUTHENTICATION;
#endif

And I re-run/re-launch the app.I get to the same place again. That is here.
Screenshot 2024-04-02 at 3 05 28 PM

Conclusion

I think this is a successful (non-failure) result. Happy to upload the full test code, but I've got the sdk inside of it, so it's somewhat large (122MB). Please let me know.

@cprince-foreflight
Copy link
Contributor Author

I repro'd those test steps on my iPhone hardware too. Between Test 1 and Test 2 I restarted my device to ensure that I had to sign back in. Same results as on simulator.

@paulb777 paulb777 added this to the 10.25.0 - M147 milestone Apr 4, 2024
@cprince-foreflight
Copy link
Contributor Author

I ran another test sequence, on my iPhone. Test 1 was the same with this setup:
Test1
Test 2 had:
Test2

Between Test 1 and Test 2 I powered down my iPhone and powered it backup to ensure it was locked prior to Test 2.
Same (positive) results. On both tests:
Result

@cprince-foreflight cprince-foreflight marked this pull request as ready for review April 5, 2024 14:55
Copy link
Contributor

@karenyz karenyz left a comment

Choose a reason for hiding this comment

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

thanks for the detailed testing notes for the upgrade case!

@ncooke3 ncooke3 merged commit d5b3519 into firebase:main Apr 22, 2024
67 checks passed
ncooke3 added a commit that referenced this pull request Apr 22, 2024
ncooke3 added a commit that referenced this pull request Apr 22, 2024
cgrindel-self-hosted-renovate bot referenced this pull request in cgrindel/rules_swift_package_manager May 1, 2024
….25.0" (#1056)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
|
[firebase/firebase-ios-sdk](https://togithub.com/firebase/firebase-ios-sdk)
| minor | `from: "10.24.0"` -> `from: "10.25.0"` |

---

### Release Notes

<details>
<summary>firebase/firebase-ios-sdk (firebase/firebase-ios-sdk)</summary>

###
[`v10.25.0`](https://togithub.com/firebase/firebase-ios-sdk/releases/tag/10.25.0):
Firebase Apple 10.25.0

[Compare
Source](https://togithub.com/firebase/firebase-ios-sdk/compare/10.24.0...10.25.0)

The Firebase Apple SDK (10.25.0) is now available. For more details, see
the [Firebase Apple SDK release
notes.](https://firebase.google.com/support/release-notes/ios#10.25.0)

To install this SDK, see [Add Firebase to your
project.](https://firebase.google.com/docs/ios/setup)

#### What's Changed

- \[FirebaseCoreInternal] Switch to implementation-only import of GULs
by [@&#8203;ncooke3](https://togithub.com/ncooke3) in
[https://github.com/firebase/firebase-ios-sdk/pull/12714](https://togithub.com/firebase/firebase-ios-sdk/pull/12714)
- \[AppCheck, Database, InAppMessaging, MLModelDownloader, Performance,
Sessions] Migrate to GoogleUtilities's storage container by
[@&#8203;ncooke3](https://togithub.com/ncooke3) in
[#&#8203;12752](https://togithub.com/firebase/firebase-ios-sdk/issues/12752),
[#&#8203;12753](https://togithub.com/firebase/firebase-ios-sdk/issues/12753),
[#&#8203;12757](https://togithub.com/firebase/firebase-ios-sdk/issues/12757),
[#&#8203;12759](https://togithub.com/firebase/firebase-ios-sdk/issues/12759),
[#&#8203;12762](https://togithub.com/firebase/firebase-ios-sdk/issues/12762),
[#&#8203;12773](https://togithub.com/firebase/firebase-ios-sdk/issues/12773)
- Use declspec in Firestore on Windows machines by
[@&#8203;a-maurice](https://togithub.com/a-maurice) in
[https://github.com/firebase/firebase-ios-sdk/pull/12758](https://togithub.com/firebase/firebase-ios-sdk/pull/12758)
- \[CI] Stop Xcode 14, start Xcode 15.3 by
[@&#8203;paulb777](https://togithub.com/paulb777) in
[https://github.com/firebase/firebase-ios-sdk/pull/12746](https://togithub.com/firebase/firebase-ios-sdk/pull/12746)
- \[Performance] Migrate to GoogleUtilities's storage container by
[@&#8203;ncooke3](https://togithub.com/ncooke3) in
[https://github.com/firebase/firebase-ios-sdk/pull/12759](https://togithub.com/firebase/firebase-ios-sdk/pull/12759)
- Todos and workarounds for tests not yet ready for macos-14 by
[@&#8203;paulb777](https://togithub.com/paulb777) in
[https://github.com/firebase/firebase-ios-sdk/pull/12781](https://togithub.com/firebase/firebase-ios-sdk/pull/12781)
- Another macos-14 CI workaround by
[@&#8203;paulb777](https://togithub.com/paulb777) in
[https://github.com/firebase/firebase-ios-sdk/pull/12787](https://togithub.com/firebase/firebase-ios-sdk/pull/12787)
- \[CI] Update grpc dependent jobs to macos-14 by
[@&#8203;paulb777](https://togithub.com/paulb777) in
[https://github.com/firebase/firebase-ios-sdk/pull/12790](https://togithub.com/firebase/firebase-ios-sdk/pull/12790)
- \[Firestore] Remove DocumentID setter warning by
[@&#8203;andrewheard](https://togithub.com/andrewheard) in
[https://github.com/firebase/firebase-ios-sdk/pull/12756](https://togithub.com/firebase/firebase-ios-sdk/pull/12756)
- \[App Check] Bump dependency on AppCheckCore to 10.19.0+ by
[@&#8203;ncooke3](https://togithub.com/ncooke3) in
[https://github.com/firebase/firebase-ios-sdk/pull/12806](https://togithub.com/firebase/firebase-ios-sdk/pull/12806)
- Allow Blob of data with zero length. by
[@&#8203;tom-andersen](https://togithub.com/tom-andersen) in
[https://github.com/firebase/firebase-ios-sdk/pull/12694](https://togithub.com/firebase/firebase-ios-sdk/pull/12694)
- \[Infra] Switch zip building over to Xcode 15.2 by
[@&#8203;ncooke3](https://togithub.com/ncooke3) in
[https://github.com/firebase/firebase-ios-sdk/pull/12737](https://togithub.com/firebase/firebase-ios-sdk/pull/12737)
- Make use of
SQLITE_OPEN_FILEPROTECTION_COMPLETEUNTILFIRSTUSERAUTHENTICATION
conditional. by
[@&#8203;cprince-foreflight](https://togithub.com/cprince-foreflight) in
[https://github.com/firebase/firebase-ios-sdk/pull/12548](https://togithub.com/firebase/firebase-ios-sdk/pull/12548)
- \[Release Tooling] Consistent approach to resources when building on
Xcode 15 by [@&#8203;ncooke3](https://togithub.com/ncooke3) in
[https://github.com/firebase/firebase-ios-sdk/pull/12821](https://togithub.com/firebase/firebase-ios-sdk/pull/12821)
- \[Release Tooling] Cleanup unused folder references by
[@&#8203;ncooke3](https://togithub.com/ncooke3) in
[https://github.com/firebase/firebase-ios-sdk/pull/12825](https://togithub.com/firebase/firebase-ios-sdk/pull/12825)
- Analytics 10.25.0 by [@&#8203;pcfba](https://togithub.com/pcfba) in
[https://github.com/firebase/firebase-ios-sdk/pull/12843](https://togithub.com/firebase/firebase-ios-sdk/pull/12843)
- Update `FIRAuthInterop` to use `_Nullable_result` annotation by
[@&#8203;andrewheard](https://togithub.com/andrewheard) in
[https://github.com/firebase/firebase-ios-sdk/pull/12841](https://togithub.com/firebase/firebase-ios-sdk/pull/12841)
- Disable quickstart CI that doesn't work with Xcode 15 by
[@&#8203;paulb777](https://togithub.com/paulb777) in
[https://github.com/firebase/firebase-ios-sdk/pull/12846](https://togithub.com/firebase/firebase-ios-sdk/pull/12846)

#### New Contributors

- [@&#8203;mrs1669](https://togithub.com/mrs1669) made their first
contribution in
[https://github.com/firebase/firebase-ios-sdk/pull/12760](https://togithub.com/firebase/firebase-ios-sdk/pull/12760)
- [@&#8203;a-maurice](https://togithub.com/a-maurice) made their first
contribution in
[https://github.com/firebase/firebase-ios-sdk/pull/12758](https://togithub.com/firebase/firebase-ios-sdk/pull/12758)
- [@&#8203;cprince-foreflight](https://togithub.com/cprince-foreflight)
made their first contribution in
[https://github.com/firebase/firebase-ios-sdk/pull/12548](https://togithub.com/firebase/firebase-ios-sdk/pull/12548)

**Full Changelog**:
firebase/firebase-ios-sdk@10.24.0...10.25.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMDkuNCIsInVwZGF0ZWRJblZlciI6IjM2LjEwOS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: Self-hosted Renovate Bot <361546+cgrindel-self-hosted-renovate[bot]@users.noreply.github.enterprise.com>
@firebase firebase locked and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants