-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
Added a feature that prompts a user when a new Zim file is opened. #1192
Conversation
…y don't trust newly opened zim file's source
@Jaifroid I was able to view and browse files once I confirmed the source with the 'trust' button in the pop up. |
I'm pretty sure the tests are failing due to the alert. I think you'll have to add an option to bypass this (trust all local ZIM archives), and enable the bypass for tests. You can add a simple |
@Jaifroid Only one of the e2e tests failed. Can you re-run? |
A couple of quick observations before you go much further with this PR:
|
The user can enable this feature in the expert settings via the "Enable source verification" checkbox which will be unchecked by default for testing purposes. This can however be changed to have the feature checked by default if necessary. |
I would say that the feature should be on by default, since it is a security feature: users should be protected by default. In a testing context, of course, it will be turned off in code. |
Also, you will see that code scanning is producing a high-risk alert. I'm not at all sure why it's being flagged as high risk -- I can only assume it is based on the naming of the variables (with the word What is your assessment of the actual risk here? I can't see a way of encrypting the data without including the keys for encrypting and decrypting them in the app. Since this is an offline solution, we can't use server-based encryption/decryption. |
This feature can be enabled by default by simply changing a Boolean to true. I disabled it by default so that it can be tested, thinking it can be changed in production. Either we automatically disable this during testing or tweak the tests to accommodate this feature. Do you see another way @Jaifroid ? |
We store the names of the zim files that the user flags as "trusted" in local storage as a continuous string of file names separated by "|". |
Should I try changing the key to something else? |
On security, I agree. I think this is a false positive based on matching the word "trusted". However, I don't think we should change the variable name because of that. On the default, I suggest turning the feature on by default. In the testing script(s) you then need to set the appropriate param so that tests will be able to load the ZIMs they test against without interruption. Note that Unit tests contain their own |
So I just have to manually change the params object in the tests/unit/js/init.js |
Yes, for Unit tests, just set the param in that
The first would be the more useful in a way because it would also be testing your code's UI. The same test runners run in GitHub actions as in Browser Stack, so you should be able to see if your code is working in your PR, and when it's working with the GitHub e2e tests, I can make a mirror PR (which I won't merge) that will allow your code to run on Browser Stack as well, to be sure all is working well. |
Thanks a lot for the info! |
I've made the necessary changes, please go ahead with the Browser Stack tests @Jaifroid |
@Greeshmanth1909 Thanks! I ran the Linux tests twice. The first one appeared to be a random failure, but the second one looks like an issue with the PR. You can see the error messages here: https://github.com/kiwix/kiwix-js/actions/runs/7708040000/job/21006685376?pr=1192, and you can examine the session on Browser Stack (and view the video) here: https://automate.browserstack.com/builds/02e2058e5efa9ad2a556c82e00ff2ebaa6322d33/sessions/39e1472142df23ca14a8c9ea71fc746bd2081e29?auth_token=e6d8704fd572b3fdee6dfa06f7d84dbc7367cdf8f437f38e5db0ed06439297d5 One thing I noticed is that the failed session was already running in jQuery mode, but your dialogue box asking if the user trusts the source still popped up. If you add code to prevent the popup showing if the user is already in jQuery mode (just check The tests will need to be adjusted also so that the detection of the dialogue box doesn't occur in the jquery test. You can easily tell in the test code if it is running in jquery or sw mode with |
NB I think the cause of the failure is probably a timeout due to the fact that that Firefox test is running on a very old version (56), albeit one we actively support. However, that Firefox only supports jQuery mode, so we shouldn't adjust timings just yet. If you eliminate the dialogue box in jQuery mode, then a number of the tests on very old browsers should run as normal, and then we can focus on the newer browsers. |
I've translated the strings into French and Spanish using deepl. |
Thanks! Sorry for slow response -- was busier than I thought at w/e. |
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.
Many thanks for making a stab at the translations! I've added my suggested changes, and there are a few strings you forgot. In this review, I only focused on the translation strings, and didn't test the code. I'll do that for the final time when you've completed the UI.
UI is always pesky: lots of fiddly details that coders don't really see the point of, but users always obsess over... So, it's like the icing on the cake that makes the whole thing desirable form a UX perspective!
I should get this done by tonight! |
There's a 110% chance I missed something here, lol. |
Last few now! Hopefully we'll be done pending final testing. |
The same test failed last time too, is this something that we should be worried about? |
This is just a flaky test, unfortunately. There's some race condition because sometimes it works and sometimes it fails, and it seems to depend on the overall load on the system... |
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.
Congratulations on this PR! It all looks good to me now, apart from one tiny little correction below. I'll do a bit more testing of the switch from a local extension to the remote code and vice versa, but in the meantime, after you've done the one little correction, let me know if you're happy for the PR to be merged.
Thanks! Please go ahead and merge this PR. |
Just to confirm that the flow seems to work well from JQuery mode in an extension through to SW mode. The user will likely be asked twice if they trust the source because the list of secure archives in the local code is not the same list as is maintained in remote code -- but this is inevitable, and will only affect a user who is switching to SW mode for the first time and has an archive loaded (a rare situation, since most users capable of running the app in SW mode will have switched when they first loaded the app). So, all OK! Thanks once again for this PR which will increase people's awareness of security. I'll merge when the Linux test is complete. |
Might resolve #974
An alert will appear when a user opens a file for the first time asking weather they trust the source of the file or not. If they do, the file will be read in the usual way. If the user does not trust the source, the file will be read in JQuery mode.
The option to disable this feature was not added.
Once the user says they trust a particular file, the same prompt will not appear for that file in the future.