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

Introduce Trust Book in Book Viewlet #9414

Merged
merged 39 commits into from
Mar 13, 2020
Merged

Conversation

joberume
Copy link
Contributor

@joberume joberume commented Mar 2, 2020

This change introduces a "Trust Book" function that trusts all notebooks in a Book. If a new notebook is introduced after having trusted the book, and it is not added to the table of contents of that book, then that trust will not be extended to that notebook (no inadvertent permission granting).

This PR fixes #8864

@joberume joberume changed the title Introduce Trust Notebook in Book Viewlet Introduce Trust Book in Book Viewlet Mar 2, 2020
extensions/notebook/src/book/bookTreeView.ts Outdated Show resolved Hide resolved
extensions/notebook/src/book/bookTreeView.ts Outdated Show resolved Hide resolved
extensions/notebook/src/book/bookTreeView.ts Outdated Show resolved Hide resolved
extensions/notebook/src/book/bookTreeView.ts Show resolved Hide resolved
src/sql/azdata.d.ts Outdated Show resolved Hide resolved
extensions/notebook/src/book/bookTrustManager.ts Outdated Show resolved Hide resolved
@Charles-Gagnon
Copy link
Contributor

You also have a merge conflict so make sure you're merging in the latest changes from master

@github-actions
Copy link

Coverage Status

Coverage decreased (-0.01%) to 30.521% when pulling 61209a3 on dev/joberume/trust-books into 6e14f13 on master.

* Determines whether a notebook is part of this book.
* @param notebookUri Notebook uri Full URI of the notebook.
*/
public hasNotebook(notebookUri: string): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think I agree that this is the best place for this. The tree item should be just about the actual tree itself and not necessarily know anything about the contents of the book (only that it may have child book tree items)

Also we already have a getNotebook method on that model. Why can't you just use that? https://github.com/microsoft/azuredatastudio/blob/master/extensions/notebook/src/book/bookModel.ts#L50

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved

Copy link
Contributor

@Charles-Gagnon Charles-Gagnon left a comment

Choose a reason for hiding this comment

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

Some issues I'm seeing :

  1. The trust isn't set immediately upon opening and when it is set it doesn't update the toolbar so it still shows untrusted. If you close and reopen the notebook it'll show correctly though
  2. There seems to be a lot of issues around getting the trust to persist correctly. I'm seeing a lot of instances where I've trusted a book but the notebooks under it are still showing as untrusted.

So those are obviously big issues. But at this point I think that aside from a few more clean up items I think we should just get this merged in and then your team can start fully testing it and fixing things one by one. That'll make it a lot easier to track and review the changes. This PR is too overloaded at this point and it's getting hard to review and track all the issues.

@chlafreniere You good with that?

@@ -41,6 +44,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
this.initialize(workspaceFolders).catch(e => console.error(e));
this.viewId = view;
this.prompter = new CodeAdapter();
this._bookTrustManager = new BookTrustManager(this.books, apiWrapper);
this._apiWrapper = apiWrapper ? apiWrapper : new ApiWrapper();
Copy link
Contributor

Choose a reason for hiding this comment

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

While you're here please remove the _apiWrapper var and instead just use the one passed in directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved

if (bookPathToTrust) {
let trustChanged = this._bookTrustManager.setBookAsTrusted(bookPathToTrust);

if (this._apiWrapper) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Get rid of this check once you've removed the _apiWrapper var

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved

* @param isTrusted True if the notebook is to be trusted, false otherwise.
*/
async setTrusted(notebookUri: URI, isTrusted: boolean): Promise<boolean> {
if (isTrusted) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather we get rid of all untrusted logic if we're not going to support that. You mentioned that you need it for testing - could you point out where that is? There should be some other way to achieve that functionality (such as clearing the config or something) without needing to use this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved

@joberume
Copy link
Contributor Author

Some issues I'm seeing :

  1. The trust isn't set immediately upon opening and when it is set it doesn't update the toolbar so it still shows untrusted. If you close and reopen the notebook it'll show correctly though
  2. There seems to be a lot of issues around getting the trust to persist correctly. I'm seeing a lot of instances where I've trusted a book but the notebooks under it are still showing as untrusted.

So those are obviously big issues. But at this point I think that aside from a few more clean up items I think we should just get this merged in and then your team can start fully testing it and fixing things one by one. That'll make it a lot easier to track and review the changes. This PR is too overloaded at this point and it's getting hard to review and track all the issues.

@chlafreniere You good with that?

Investigated this. The path for updating the trust notebook state via Mementos only reflected changes after the notebook is opened. Fixed this by updating the live notebook as well.

@joberume joberume requested review from chlafreniere and removed request for chlafreniere March 12, 2020 00:57
@chlafreniere
Copy link
Contributor

Some issues I'm seeing :

  1. The trust isn't set immediately upon opening and when it is set it doesn't update the toolbar so it still shows untrusted. If you close and reopen the notebook it'll show correctly though
  2. There seems to be a lot of issues around getting the trust to persist correctly. I'm seeing a lot of instances where I've trusted a book but the notebooks under it are still showing as untrusted.

So those are obviously big issues. But at this point I think that aside from a few more clean up items I think we should just get this merged in and then your team can start fully testing it and fixing things one by one. That'll make it a lot easier to track and review the changes. This PR is too overloaded at this point and it's getting hard to review and track all the issues.
@chlafreniere You good with that?

Investigated this. The path for updating the trust notebook state via Mementos only reflected changes after the notebook is opened. Fixed this by updating the live notebook as well.

Can you clarify what the remaining known issues are?

@chlafreniere
Copy link
Contributor

Please be sure to merge latest from master; then the component detection issues will go away and builds will succeed.

@joberume
Copy link
Contributor Author

Investigated this. The path for updating the trust notebook state via Mementos only reflected changes after the notebook is opened. Fixed this by updating the live notebook as well.

Some issues I'm seeing :

  1. The trust isn't set immediately upon opening and when it is set it doesn't update the toolbar so it still shows untrusted. If you close and reopen the notebook it'll show correctly though
  2. There seems to be a lot of issues around getting the trust to persist correctly. I'm seeing a lot of instances where I've trusted a book but the notebooks under it are still showing as untrusted.

So those are obviously big issues. But at this point I think that aside from a few more clean up items I think we should just get this merged in and then your team can start fully testing it and fixing things one by one. That'll make it a lot easier to track and review the changes. This PR is too overloaded at this point and it's getting hard to review and track all the issues.
@chlafreniere You good with that?

Investigated this. The path for updating the trust notebook state via Mementos only reflected changes after the notebook is opened. Fixed this by updating the live notebook as well.

Can you clarify what the remaining known issues are?

I believe issue #1 and #2 are similar. Was not able to repro this. Need to talk to get Book.

@joberume joberume merged commit d5fdec5 into master Mar 13, 2020
@joberume joberume deleted the dev/joberume/trust-books branch March 13, 2020 16:11
joberume added a commit that referenced this pull request Mar 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notebook: Trust an entire directory of Notebooks
5 participants