Skip to content

Commit 032ebce

Browse files
authored
Remove control tower code for trusted notebooks (microsoft#13394)
1 parent da06067 commit 032ebce

19 files changed

Lines changed: 30 additions & 105 deletions

File tree

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,7 +2069,6 @@
20692069
"CollectNodeLSRequestTiming - experiment",
20702070
"DeprecatePythonPath - experiment",
20712071
"RunByLine - experiment",
2072-
"EnableTrustedNotebooks",
20732072
"tryPylance",
20742073
"All"
20752074
]
@@ -2094,7 +2093,6 @@
20942093
"CollectNodeLSRequestTiming - experiment",
20952094
"DeprecatePythonPath - experiment",
20962095
"RunByLine - experiment",
2097-
"EnableTrustedNotebooks",
20982096
"tryPylance",
20992097
"All"
21002098
]
@@ -3759,4 +3757,4 @@
37593757
"publisherDisplayName": "Microsoft",
37603758
"publisherId": "998b010b-e2af-44a5-a6cd-0b5fd3b9b6f8"
37613759
}
3762-
}
3760+
}

src/client/common/experiments/groups.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ export enum RemoveKernelToolbarInInteractiveWindow {
8787
experiment = 'RemoveKernelToolbarInInteractiveWindow'
8888
}
8989

90-
// Experiment to turn on trusted notebooks checks
91-
export enum EnableTrustedNotebooks {
92-
experiment = 'EnableTrustedNotebooks'
93-
}
94-
9590
// Experiment to offer switch to Pylance language server
9691
export enum TryPylance {
9792
experiment = 'tryPylance'

src/client/datascience/interactive-common/interactiveWindowTypes.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ export interface IRefreshVariablesRequest {
343343
export interface ILoadAllCells {
344344
cells: ICell[];
345345
isNotebookTrusted?: boolean;
346-
shouldShowTrustMessage?: boolean;
347346
}
348347

349348
export interface IScrollToCell {

src/client/datascience/interactive-ipynb/nativeEditor.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ import cloneDeep = require('lodash/cloneDeep');
8484
import { concatMultilineString, splitMultilineString } from '../../../datascience-ui/common';
8585
import { ServerStatus } from '../../../datascience-ui/interactive-common/mainState';
8686
import { isTestExecution, PYTHON_LANGUAGE } from '../../common/constants';
87-
import { EnableTrustedNotebooks } from '../../common/experiments/groups';
8887
import { translateKernelLanguageToMonaco } from '../common';
8988
import { IDataViewerFactory } from '../data-viewing/types';
9089
import { getCellHashProvider } from '../editor-integration/cellhashprovider';
@@ -181,7 +180,7 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
181180
notebookProvider: INotebookProvider,
182181
useCustomEditorApi: boolean,
183182
private trustService: ITrustService,
184-
private expService: IExperimentService,
183+
expService: IExperimentService,
185184
private _model: INotebookModel,
186185
webviewPanel: WebviewPanel | undefined,
187186
selector: KernelSelector
@@ -225,7 +224,6 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
225224
selector
226225
);
227226
asyncRegistry.push(this);
228-
229227
asyncRegistry.push(this.trustService.onDidSetNotebookTrust(this.monitorChangesToTrust, this));
230228
this.synchronizer.subscribeToUserActions(this, this.postMessage.bind(this));
231229

@@ -699,11 +697,9 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
699697
private async sendInitialCellsToWebView(cells: ICell[], isNotebookTrusted: boolean): Promise<void> {
700698
sendTelemetryEvent(Telemetry.CellCount, undefined, { count: cells.length });
701699

702-
const shouldShowTrustMessage = await this.expService.inExperiment(EnableTrustedNotebooks.experiment);
703700
return this.postMessage(InteractiveWindowMessages.LoadAllCells, {
704701
cells,
705-
isNotebookTrusted,
706-
shouldShowTrustMessage
702+
isNotebookTrusted
707703
});
708704
}
709705

src/client/datascience/interactive-ipynb/trustCommandHandler.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ import { commands, Uri } from 'vscode';
88
import { IExtensionSingleActivationService } from '../../activation/types';
99
import { IApplicationShell, ICommandManager } from '../../common/application/types';
1010
import { ContextKey } from '../../common/contextKey';
11-
import { EnableTrustedNotebooks } from '../../common/experiments/groups';
1211
import '../../common/extensions';
13-
import { IDisposableRegistry, IExperimentService } from '../../common/types';
12+
import { IDisposableRegistry } from '../../common/types';
1413
import { swallowExceptions } from '../../common/utils/decorators';
1514
import { DataScience } from '../../common/utils/localize';
1615
import { sendTelemetryEvent } from '../../telemetry';
@@ -26,16 +25,12 @@ export class TrustCommandHandler implements IExtensionSingleActivationService {
2625
@inject(INotebookStorageProvider) private readonly storageProvider: INotebookStorageProvider,
2726
@inject(ICommandManager) private readonly commandManager: ICommandManager,
2827
@inject(IApplicationShell) private readonly applicationShell: IApplicationShell,
29-
@inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry,
30-
@inject(IExperimentService) private readonly experiments: IExperimentService
28+
@inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry
3129
) {}
3230
public async activate(): Promise<void> {
3331
this.activateInBackground().ignoreErrors();
3432
}
3533
public async activateInBackground(): Promise<void> {
36-
if (!(await this.experiments.inExperiment(EnableTrustedNotebooks.experiment))) {
37-
return;
38-
}
3934
const context = new ContextKey('python.datascience.trustfeatureenabled', this.commandManager);
4035
context.set(true).ignoreErrors();
4136
this.disposables.push(this.commandManager.registerCommand(Commands.TrustNotebook, this.onTrustNotebook, this));

src/client/datascience/interactive-ipynb/trustService.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { createHmac } from 'crypto';
22
import { inject, injectable } from 'inversify';
33
import { EventEmitter, Uri } from 'vscode';
4-
import { EnableTrustedNotebooks } from '../../common/experiments/groups';
5-
import { IConfigurationService, IExperimentService } from '../../common/types';
4+
import { IConfigurationService } from '../../common/types';
65
import { IDigestStorage, ITrustService } from '../types';
76

87
@injectable()
@@ -14,14 +13,10 @@ export class TrustService implements ITrustService {
1413
return this.configService.getSettings().datascience.alwaysTrustNotebooks;
1514
}
1615
protected readonly _onDidSetNotebookTrust = new EventEmitter<void>();
17-
private enabled: Promise<boolean>;
1816
constructor(
19-
@inject(IExperimentService) private readonly experimentService: IExperimentService,
2017
@inject(IDigestStorage) private readonly digestStorage: IDigestStorage,
2118
@inject(IConfigurationService) private configService: IConfigurationService
22-
) {
23-
this.enabled = this.isInExperiment();
24-
}
19+
) {}
2520

2621
/**
2722
* When a notebook is opened, we check the database to see if a trusted checkpoint
@@ -31,8 +26,8 @@ export class TrustService implements ITrustService {
3126
* markdown will be rendered until notebook as a whole is marked trusted
3227
*/
3328
public async isNotebookTrusted(uri: Uri, notebookContents: string) {
34-
if (this.alwaysTrustNotebooks || !(await this.enabled)) {
35-
return true; // Skip check if user manually overrode our trust checking, or if user is not in experiment
29+
if (this.alwaysTrustNotebooks) {
30+
return true; // Skip check if user manually overrode our trust checking
3631
}
3732
// Compute digest and see if notebook is trusted
3833
const digest = await this.computeDigest(notebookContents);
@@ -45,7 +40,7 @@ export class TrustService implements ITrustService {
4540
* I.e. if the notebook has already been trusted by the user
4641
*/
4742
public async trustNotebook(uri: Uri, notebookContents: string) {
48-
if (!this.alwaysTrustNotebooks && (await this.enabled)) {
43+
if (!this.alwaysTrustNotebooks) {
4944
// Only update digest store if the user wants us to check trust
5045
const digest = await this.computeDigest(notebookContents);
5146
await this.digestStorage.saveDigest(uri, digest);
@@ -58,8 +53,4 @@ export class TrustService implements ITrustService {
5853
hmac.update(notebookContents);
5954
return hmac.digest('hex');
6055
}
61-
62-
private async isInExperiment() {
63-
return this.experimentService.inExperiment(EnableTrustedNotebooks.experiment);
64-
}
6556
}

src/datascience-ui/interactive-common/jupyterInfo.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,13 @@ export class JupyterInfo extends React.Component<IJupyterInfoProps> {
9494
}
9595

9696
private renderTrustMessage() {
97-
if (this.props.shouldShowTrustMessage) {
98-
return (
99-
<TrustMessage
100-
shouldShowTrustMessage={this.props.shouldShowTrustMessage}
101-
isNotebookTrusted={this.props.isNotebookTrusted}
102-
launchNotebookTrustPrompt={this.props.launchNotebookTrustPrompt}
103-
/>
104-
);
105-
}
97+
return (
98+
<TrustMessage
99+
shouldShowTrustMessage={this.props.shouldShowTrustMessage}
100+
isNotebookTrusted={this.props.isNotebookTrusted}
101+
launchNotebookTrustPrompt={this.props.launchNotebookTrustPrompt}
102+
/>
103+
);
106104
}
107105

108106
private selectKernel() {

src/datascience-ui/interactive-common/mainState.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ export type IMainState = {
9090
loaded: boolean;
9191
kernel: IServerState;
9292
isNotebookTrusted: boolean;
93-
shouldShowTrustMessage: boolean;
9493
};
9594

9695
export type SelectionAndFocusedInfo = {
@@ -198,8 +197,7 @@ export function generateTestState(filePath: string = '', editable: boolean = fal
198197
jupyterServerStatus: ServerStatus.NotStarted,
199198
language: PYTHON_LANGUAGE
200199
},
201-
isNotebookTrusted: true,
202-
shouldShowTrustMessage: true
200+
isNotebookTrusted: true
203201
};
204202
}
205203

src/datascience-ui/interactive-common/redux/store.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ function generateDefaultState(
7474
},
7575
settings: testMode ? getDefaultSettings() : undefined, // When testing, we don't send (or wait) for the real settings.
7676
editorOptions: testMode ? computeEditorOptions(getDefaultSettings()) : undefined,
77-
isNotebookTrusted: true,
78-
shouldShowTrustMessage: false
77+
isNotebookTrusted: true
7978
};
8079
}
8180
}

src/datascience-ui/native-editor/nativeEditor.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,7 @@ ${buildSettingsCss(this.props.settings)}`}</style>
126126
setTimeout(() => this.props.insertAboveFirst(), 1);
127127
}
128128
private renderToolbarPanel() {
129-
return (
130-
<ToolbarComponent
131-
shouldShowTrustMessage={this.props.shouldShowTrustMessage}
132-
isNotebookTrusted={this.props.isNotebookTrusted}
133-
></ToolbarComponent>
134-
);
129+
return <ToolbarComponent isNotebookTrusted={this.props.isNotebookTrusted}></ToolbarComponent>;
135130
}
136131

137132
private renderVariablePanel(baseTheme: string) {

0 commit comments

Comments
 (0)