- Notifications
You must be signed in to change notification settings - Fork5.5k
Allow notebooks to be trusted without triggering a save#2718
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
minrk left a comment
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.
Thanks! I left a few comments inline.
| # We need this check in case the notebook is | ||
| # trusted before save | ||
| ifnotself.notary.check_signature(nb): | ||
| self.check_and_sign(nb,path) |
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.
check_signature shouldn't be called beforecheck_and_sign, which consumes trust metadata. I think.save probably doesn't need to change at all.
| @json_errors | ||
| @web.authenticated | ||
| @gen.coroutine | ||
| defput(self,path=''): |
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.
POST is probably more appropriate for a request with no content.
| self.notary.sign(nb) | ||
| else: | ||
| self.log.warning("Saving untrusted notebook %s",path) | ||
| self.log.warning("Signing notebook %s",path) |
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.
This message is backwards. In this event, the notebook isnot signed. It is still untrusted.
| window.location.reload(); | ||
| nb.contents.trust(nb.notebook_path) | ||
| .then(function(res){ | ||
| nb.events.trigger("trust_changed.Notebook",true) |
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.
it should still trigger reload to get the newly trusted notebook without sanitized output.
And.save should only be avoided when the notebook is read-only. We should still save & reload for non-read-only notebooks to avoid losing unsaved changes (which is unavoidable for read-only).
Madhu94 commentedAug 2, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@minrk Thanks for the feedback! Took care of those comments. |
minrk left a comment
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.
Thanks for the quick turnaround!
| ifself.notary.check_cells(nb): | ||
| self.notary.sign(nb) | ||
| else: | ||
| self.log.warning("Saving untrusted notebook %s",path) |
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.
Maybe leave this at "Notebook %s is not trusted."
| },function(err){ | ||
| console.log(err); | ||
| }); | ||
| nb.save_notebook(); |
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.
Can you still trigger save here if the notebook is not read-only? That way we can avoid losing unsaved changes when the notebook is editable.
varp;if (nb.writableandnb.dirty) {p=nb.save_notebook();}else {p=Promise.resolve();}p.then(function () {returnnb.contents.trust...
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.
So if its read-only, we save it and then trust..Thanks, never noticed thedirty attribute.
Madhu94 commentedAug 2, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
gnestor commentedAug 4, 2017
@minrk Do you think this ready to merge? |
| self.notary.sign(nb) | ||
| # We're checking the signature *after* the | ||
| # trusted keys have been removed | ||
| ifnotself.notary.check_signature(nb): |
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.
I think this entire method should be left exactly as it was. Adding this check here is not correct because it prevents updating the signatures of trusted notebooks.
minrk commentedAug 4, 2017
@gnestor almost. There's one addition in check_and_sign that should be reverted, but the rest should be set. |
Madhu94 commentedAug 4, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Madhu94 commentedAug 4, 2017
I think this is a bug even on master. I noticed that without the check, the same signature was re-inserted each time the notebook was trusted. @minrk, I probably shouldn't check this here - the issue should be fixed in nbformat. So, I'll revert that change, squash my commits and then we're good to go? |
minrk commentedAug 5, 2017
@Madhu94 exactly right. This shouldn't be changed here, but fixed in nbformat itself. Thanks for digging in! |
Madhu94 commentedAug 5, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@minrk I rebased and squashed my commits and reverted that check in |
takluyver commentedAug 7, 2017
@minrk this is, I think, the last remaining PR for 5.1. Is it ready to go? |
minrk commentedAug 7, 2017
Yes, indeed. |
minrk commentedAug 7, 2017
Thanks,@Madhu94! |
Madhu94 commentedAug 18, 2017
Can I add this to the 5.1 changelog ? |
takluyver commentedAug 18, 2017
Yes, please do! |
Closes#195.
Trust should now add the notebook's signature without needing to trigger a save. Save will still trust the notebook, after checking and if it has not already been trusted.
I have not added an automatic refresh after trust, let me know if you think this would be a good idea.