mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-19 13:20:36 +08:00
Notaries sign notebooks now
This commit is contained in:
parent
ffb3523d05
commit
6dd44de19f
@ -262,7 +262,7 @@ class NotebookTrustApp(BaseIPythonApplication):
|
||||
self.exit(1)
|
||||
with io.open(notebook_path, encoding='utf8') as f:
|
||||
nb = current.read(f, 'json')
|
||||
sign.trust_notebook(nb, self.notary.secret, self.notary.signature_scheme)
|
||||
self.notary.sign(nb)
|
||||
with io.open(notebook_path, 'w', encoding='utf8') as f:
|
||||
current.write(nb, f, 'json')
|
||||
|
||||
|
@ -214,7 +214,10 @@ class FileNotebookManager(NotebookManager):
|
||||
except Exception as e:
|
||||
raise web.HTTPError(400, u"Unreadable Notebook: %s %s" % (os_path, e))
|
||||
model['content'] = nb
|
||||
sign.mark_trusted_cells(nb, self.notary.secret, self.notary.scheme)
|
||||
trusted = self.notary.check_signature(nb)
|
||||
if not trusted:
|
||||
self.log.warn("Notebook %s/%s is not trusted", model['path'], model['name'])
|
||||
self.notary.mark_cells(nb, trusted)
|
||||
return model
|
||||
|
||||
def save_notebook_model(self, model, name='', path=''):
|
||||
@ -238,8 +241,11 @@ class FileNotebookManager(NotebookManager):
|
||||
os_path = self.get_os_path(new_name, new_path)
|
||||
nb = current.to_notebook_json(model['content'])
|
||||
|
||||
if sign.check_trusted_cells(nb):
|
||||
sign.trust_notebook(nb, self.notary.secret, self.notary.scheme)
|
||||
if self.notary.check_cells(nb):
|
||||
self.notary.sign(nb)
|
||||
else:
|
||||
self.log.warn("Saving untrusted notebook %s/%s", new_path, new_name)
|
||||
|
||||
|
||||
if 'name' in nb['metadata']:
|
||||
nb['metadata']['name'] = u''
|
||||
|
Loading…
x
Reference in New Issue
Block a user