Skip to content

Commit

Permalink
Remaining kernel webview layer protection (#10458)
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix authored Jun 14, 2022
1 parent 1fc2003 commit 1e35a09
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ module.exports = {
},
{
target: './src/kernels/**/*.ts',
from: './src/notebooks/**/*.ts',
message: 'Importing modules from ./src/notebooks into ./src/kernels code is not allowed.'
from: './src/**[!platform,telemetry,kernels]**/**/*.ts',
message: 'Only modules from ./src/platform and ./src/telemetry can be imported into ./src/kernels.'
},
{
target: './src/telemetry/**/**[!types]**.ts',
Expand Down
4 changes: 0 additions & 4 deletions src/kernels/jupyter/import-export/helpers.node.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/kernels/jupyter/serviceRegistry.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { IRemoteKernelFinder } from '../raw/types';
import { INotebookProvider } from '../types';
import { JupyterCommandLineSelectorCommand } from './commands/commandLineSelector';
import { CommandRegistry } from './commands/commandRegistry';
import { JupyterExporter } from './import-export/jupyterExporter.node';
import { JupyterImporter } from './import-export/jupyterImporter.node';
import { JupyterCommandFactory } from './interpreter/jupyterCommand.node';
import { JupyterInterpreterDependencyService } from './interpreter/jupyterInterpreterDependencyService.node';
import { JupyterInterpreterOldCacheStateStore } from './interpreter/jupyterInterpreterOldCacheStateStore.node';
Expand Down Expand Up @@ -36,7 +34,6 @@ import { NotebookProvider } from './launcher/notebookProvider';
import { NotebookServerProvider } from './launcher/notebookServerProvider';
import { NotebookStarter } from './launcher/notebookStarter.node';
import { ServerConnectionType } from './launcher/serverConnectionType';
import { ServerPreload } from './launcher/serverPreload.node';
import { JupyterServerUriStorage } from './launcher/serverUriStorage';
import { LiveRemoteKernelConnectionUsageTracker } from './liveRemoteKernelConnectionTracker';
import { RemoteKernelFinder } from './remoteKernelFinder';
Expand All @@ -46,8 +43,6 @@ import { JupyterRequestCreator } from './session/jupyterRequestCreator.node';
import { JupyterSessionManagerFactory } from './session/jupyterSessionManagerFactory';
import { RequestAgentCreator } from './session/requestAgentCreator.node';
import {
INotebookExporter,
INotebookImporter,
IJupyterNotebookProvider,
IJupyterExecution,
IJupyterPasswordConnect,
Expand All @@ -71,8 +66,6 @@ import { IJupyterCommandFactory, IJupyterSubCommandExecutionService } from './ty

export function registerTypes(serviceManager: IServiceManager, _isDevMode: boolean) {
serviceManager.add<IJupyterCommandFactory>(IJupyterCommandFactory, JupyterCommandFactory);
serviceManager.add<INotebookExporter>(INotebookExporter, JupyterExporter);
serviceManager.add<INotebookImporter>(INotebookImporter, JupyterImporter);
serviceManager.add<INotebookServerFactory>(INotebookServerFactory, HostJupyterServerFactory);
serviceManager.addSingleton<IJupyterNotebookProvider>(IJupyterNotebookProvider, JupyterNotebookProvider);
serviceManager.addSingleton<IRemoteKernelFinder>(IRemoteKernelFinder, RemoteKernelFinder);
Expand Down Expand Up @@ -135,7 +128,6 @@ export function registerTypes(serviceManager: IServiceManager, _isDevMode: boole
serviceManager.addSingleton<IJupyterServerUriStorage>(IJupyterServerUriStorage, JupyterServerUriStorage);
serviceManager.addSingleton<INotebookStarter>(INotebookStarter, NotebookStarter);
serviceManager.addSingleton<INotebookProvider>(INotebookProvider, NotebookProvider);
serviceManager.addSingleton<IExtensionSingleActivationService>(IExtensionSingleActivationService, ServerPreload);
serviceManager.addSingleton<IJupyterBackingFileCreator>(IJupyterBackingFileCreator, BackingFileCreator);
serviceManager.addSingleton<IExtensionSingleActivationService>(IExtensionSingleActivationService, CommandRegistry);
serviceManager.addSingleton<JupyterCommandLineSelectorCommand>(
Expand Down
2 changes: 1 addition & 1 deletion src/test/datascience/notebook/exportFull.vscode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { Product } from '../../../kernels/installer/types';
import { ProcessService } from '../../../platform/common/process/proc.node';
import { BufferDecoder } from '../../../platform/common/process/decoder.node';
import { INbConvertInterpreterDependencyChecker, INotebookImporter } from '../../../kernels/jupyter/types';
import { JupyterImporter } from '../../../kernels/jupyter/import-export/jupyterImporter.node';
import { JupyterImporter } from '../../../webviews/extension-side/import-export/jupyterImporter.node';
import { IInterpreterService } from '../../../platform/interpreter/contracts';
import { PythonEnvironment } from '../../../platform/api/extension';
import { CodeSnippets, Identifiers } from '../../../platform/common/constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { concatMultilineString, pruneCell } from '../../../platform/common/utils
import { DataScience } from '../../../platform/common/utils/localize';
import { IDataScienceErrorHandler } from '../../../platform/errors/types';
import { defaultNotebookFormat } from '../../../platform/common/constants';
import { INotebookExporter, IJupyterExecution } from '../types';
import { INotebookExporter, IJupyterExecution } from '../../../kernels/jupyter/types';
import { openAndShowNotebook } from '../../../platform/common/utils/notebooks';
import { noop } from '../../../platform/common/utils/misc';
import { CodeSnippets } from '../../../platform/common/constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import { IDisposableRegistry, IConfigurationService } from '../../../platform/co
import { DataScience } from '../../../platform/common/utils/localize';
import { PythonEnvironment } from '../../../platform/pythonEnvironments/info';
import { noop } from '../../../platform/common/utils/misc';
import { INotebookImporter, INbConvertInterpreterDependencyChecker, INbConvertExportToPythonService } from '../types';
import {
INotebookImporter,
INbConvertInterpreterDependencyChecker,
INbConvertExportToPythonService
} from '../../../kernels/jupyter/types';
import { IFileSystemNode } from '../../../platform/common/platform/types.node';

@injectable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import {
IMemento,
WORKSPACE_MEMENTO
} from '../../../platform/common/types';
import { getKernelConnectionLanguage } from '../../helpers';
import { IKernel, IKernelProvider, INotebookProvider } from '../../types';
import { getKernelConnectionLanguage } from '../../../kernels/helpers';
import { IKernel, IKernelProvider, INotebookProvider } from '../../../kernels/types';
import { IInteractiveWindowProvider, IInteractiveWindow } from '../../../interactive-window/types';
import { DisplayOptions } from '../../displayOptions';
import { IRawNotebookProvider } from '../../raw/types';
import { DisplayOptions } from '../../../kernels/displayOptions';
import { IRawNotebookProvider } from '../../../kernels/raw/types';
import { isJupyterNotebook } from '../../../platform/common/utils';
import { noop } from '../../../platform/common/utils/misc';

Expand Down
7 changes: 7 additions & 0 deletions src/webviews/extension-side/serviceRegistry.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ import { WebviewViewProvider } from './webviewViews/webviewViewProvider';
import { JupyterVariableDataProvider } from './dataviewer/jupyterVariableDataProvider';
import { JupyterVariableDataProviderFactory } from './dataviewer/jupyterVariableDataProviderFactory';
import { IJupyterVariableDataProvider, IJupyterVariableDataProviderFactory } from './dataviewer/types';
import { INotebookExporter, INotebookImporter } from '../../kernels/jupyter/types';
import { JupyterExporter } from './import-export/jupyterExporter.node';
import { JupyterImporter } from './import-export/jupyterImporter.node';
import { ServerPreload } from './serverPreload/serverPreload.node';

export function registerTypes(serviceManager: IServiceManager, _isDevMode: boolean) {
serviceManager.addSingleton<IExtensionSingleActivationService>(IExtensionSingleActivationService, ServerPreload);
serviceManager.add<IWebviewViewProvider>(IWebviewViewProvider, WebviewViewProvider);
serviceManager.add<IWebviewPanelProvider>(IWebviewPanelProvider, WebviewPanelProvider);
serviceManager.addSingleton<IExtensionSingleActivationService>(
Expand All @@ -27,4 +32,6 @@ export function registerTypes(serviceManager: IServiceManager, _isDevMode: boole
IJupyterVariableDataProviderFactory,
JupyterVariableDataProviderFactory
);
serviceManager.add<INotebookExporter>(INotebookExporter, JupyterExporter);
serviceManager.add<INotebookImporter>(INotebookImporter, JupyterImporter);
}

0 comments on commit 1e35a09

Please sign in to comment.