Skip to content

Commit

Permalink
Upgrade notebook trust to VS Codes workspace trust feature (#6023)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored Jun 1, 2021
1 parent 197977f commit 5f8c5c0
Show file tree
Hide file tree
Showing 107 changed files with 539 additions and 2,193 deletions.
18 changes: 0 additions & 18 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module.exports = {
ignorePatterns: [
'build/constants.js',
'build/util.js',
'build/ci/postInstall.js',
'build/ci/scripts/runFunctionalTests.js',
'build/ci/performance/checkPerformanceResults.js',
'build/ci/performance/createNewPerformanceBenchmark.js',
Expand Down Expand Up @@ -136,7 +135,6 @@ module.exports = {
'src/test/common/socketCallbackHandler.test.ts',
'src/test/common/installer.test.ts',
'src/test/common/process/decoder.test.ts',
'src/test/common/process/processFactory.unit.test.ts',
'src/test/common/process/pythonToolService.unit.test.ts',
'src/test/common/process/proc.observable.test.ts',
'src/test/common/process/currentProcess.test.ts',
Expand Down Expand Up @@ -192,7 +190,6 @@ module.exports = {
'src/test/datascience/mockTextEditor.ts',
'src/test/datascience/mockLanguageServerAnalysisOptions.ts',
'src/test/datascience/mockLanguageServerProxy.ts',
'src/test/datascience/trustedNotebooks.functional.test.tsx',
'src/test/datascience/mockPythonSettings.ts',
'src/test/datascience/progress/progressReporter.unit.test.ts',
'src/test/datascience/progress/decorators.unit.test.ts',
Expand All @@ -203,7 +200,6 @@ module.exports = {
'src/test/datascience/ipywidgets/incompatibleWidgetHandler.unit.test.ts',
'src/test/datascience/datascienceSurveyBanner.unit.test.ts',
'src/test/datascience/intellisense.functional.test.tsx',
'src/test/datascience/nativeEditor.toolbar.functional.test.tsx',
'src/test/datascience/raw-kernel/rawKernelTestHelpers.ts',
'src/test/datascience/color.test.ts',
'src/test/datascience/nativeEditorViewTracker.unit.test.ts',
Expand All @@ -219,7 +215,6 @@ module.exports = {
'src/test/datascience/testexecutionLogger.ts',
'src/test/datascience/mockLanguageServer.ts',
'src/test/datascience/debugger.functional.test.tsx',
'src/test/datascience/testInteractiveWindowProvider.ts',
'src/test/datascience/jupyterUtils.unit.test.ts',
'src/test/datascience/remoteTestHelpers.ts',
'src/test/datascience/mockWorkspaceFolder.ts',
Expand All @@ -236,7 +231,6 @@ module.exports = {
'src/test/datascience/plotViewer.functional.test.tsx',
'src/test/datascience/editor-integration/helpers.ts',
'src/test/datascience/editor-integration/cellhashprovider.unit.test.ts',
'src/test/datascience/editor-integration/codelensprovider.unit.test.ts',
'src/test/datascience/jupyterPasswordConnect.unit.test.ts',
'src/test/datascience/mockLanguageClient.ts',
'src/test/datascience/errorHandler.functional.test.tsx',
Expand Down Expand Up @@ -294,7 +288,6 @@ module.exports = {
'src/datascience-ui/native-editor/addCellLine.tsx',
'src/datascience-ui/native-editor/redux/mapping.ts',
'src/datascience-ui/native-editor/redux/reducers/movement.ts',
'src/datascience-ui/native-editor/redux/reducers/index.ts',
'src/datascience-ui/native-editor/redux/reducers/creation.ts',
'src/datascience-ui/native-editor/redux/reducers/execution.ts',
'src/datascience-ui/native-editor/redux/reducers/effects.ts',
Expand All @@ -314,7 +307,6 @@ module.exports = {
'src/datascience-ui/ipywidgets/requirejsRegistry.ts',
'src/datascience-ui/ipywidgets/incompatibleWidgetHandler.ts',
'src/datascience-ui/interactive-common/trimmedOutputLink.tsx',
'src/datascience-ui/interactive-common/trustMessage.tsx',
'src/datascience-ui/interactive-common/variableExplorerRowRenderer.tsx',
'src/datascience-ui/interactive-common/variableExplorerHeaderCellFormatter.tsx',
'src/datascience-ui/interactive-common/code.tsx',
Expand All @@ -328,7 +320,6 @@ module.exports = {
'src/datascience-ui/interactive-common/tokenizer.ts',
'src/datascience-ui/interactive-common/cellInput.tsx',
'src/datascience-ui/interactive-common/variableExplorerEmptyRows.tsx',
'src/datascience-ui/interactive-common/jupyterInfo.tsx',
'src/datascience-ui/interactive-common/executionCount.tsx',
'src/datascience-ui/interactive-common/handlers.ts',
'src/datascience-ui/interactive-common/intellisenseProvider.ts',
Expand All @@ -340,7 +331,6 @@ module.exports = {
'src/datascience-ui/interactive-common/redux/helpers.ts',
'src/datascience-ui/interactive-common/redux/reducers/helpers.ts',
'src/datascience-ui/interactive-common/redux/reducers/monaco.ts',
'src/datascience-ui/interactive-common/redux/reducers/transfer.ts',
'src/datascience-ui/interactive-common/redux/reducers/kernel.ts',
'src/datascience-ui/interactive-common/redux/postOffice.ts',
'src/datascience-ui/interactive-common/contentPanel.tsx',
Expand Down Expand Up @@ -678,7 +668,6 @@ module.exports = {
'src/client/common/application/languageService.ts',
'src/client/common/application/',
'src/client/common/application/clipboard.ts',
'src/client/common/application/workspace.ts',
'src/client/common/application/debugSessionTelemetry.ts',
'src/client/common/application/activeResource.ts',
'src/client/common/application/documentManager.ts',
Expand All @@ -697,7 +686,6 @@ module.exports = {
'src/client/common/installer/pipInstaller.ts',
'src/client/common/installer/productPath.ts',
'src/client/common/process/currentProcess.ts',
'src/client/common/process/processFactory.ts',
'src/client/common/process/serviceRegistry.ts',
'src/client/common/process/pythonToolService.ts',
'src/client/common/process/internal/scripts/testing_tools.ts',
Expand All @@ -707,7 +695,6 @@ module.exports = {
'src/client/common/process/pythonProcess.ts',
'src/client/common/process/pythonEnvironment.ts',
'src/client/common/process/decoder.ts',
'src/client/common/process/pythonExecutionFactory.ts',
'src/client/debugger/extension/configuration/providers/moduleLaunch.ts',
'src/client/debugger/extension/configuration/providers/flaskLaunch.ts',
'src/client/debugger/extension/configuration/providers/fileLaunch.ts',
Expand Down Expand Up @@ -818,7 +805,6 @@ module.exports = {
'src/client/datascience/multiplexingDebugService.ts',
'src/client/datascience/interactive-window/identity.ts',
'src/client/datascience/interactive-window/interactiveWindow.ts',
'src/client/datascience/interactive-window/interactiveWindowProvider.ts',
'src/client/datascience/datascience.ts',
'src/client/datascience/liveshare/liveshare.ts',
'src/client/datascience/liveshare/serviceProxy.ts',
Expand All @@ -842,7 +828,6 @@ module.exports = {
'src/client/datascience/interactive-common/intellisense/intellisenseLine.ts',
'src/client/datascience/jupyterUriProviderWrapper.ts',
'src/client/datascience/cellMatcher.ts',
'src/client/datascience/notebookStorage/notebookModel.ts',
'src/client/datascience/notebookStorage/notebookModelEditEvent.ts',
'src/client/datascience/debugLocationTracker.ts',
'src/client/datascience/plotting/plotViewerMessageListener.ts',
Expand All @@ -852,12 +837,9 @@ module.exports = {
'src/client/datascience/monacoMessages.ts',
'src/client/datascience/interactive-ipynb/nativeEditorRunByLineListener.ts',
'src/client/datascience/interactive-ipynb/nativeEditorViewTracker.ts',
'src/client/datascience/interactive-ipynb/nativeEditorOldWebView.ts',
'src/client/datascience/interactive-ipynb/nativeEditorSynchronizer.ts',
'src/client/datascience/interactive-ipynb/autoSaveService.ts',
'src/client/datascience/editor-integration/codeLensFactory.ts',
'src/client/datascience/editor-integration/decorator.ts',
'src/client/datascience/editor-integration/codelensprovider.ts',
'src/client/datascience/editor-integration/cellhashprovider.ts',
'src/client/datascience/commands/commandLineSelector.ts',
'src/client/datascience/cellFactory.ts',
Expand Down
1 change: 0 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
**/*.map
**/*.analyzer.html
!out/datascience-ui/common/node_modules/**/*
!out/BCryptGenRandom/BCryptGenRandom.exe
images/**
docs/**
*.vsix
Expand Down
33 changes: 0 additions & 33 deletions build/ci/postInstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
const colors = require('colors/safe');
const fs = require('fs-extra');
const path = require('path');
const tmp = require('tmp');
const constants = require('../constants');
const download = require('download');
const { downloadRendererExtension } = require('./downloadRenderer');

/**
Expand Down Expand Up @@ -80,39 +78,8 @@ function createJupyterKernelWithoutSerialization() {
console.log(colors.green(destPath + ' file generated (by Jupyter VSC)'));
}

/**
* In order to generate random bytes on Windows without taking a dependency on native node modules
* which we then need to build xplat and bundle with the extension, download a prebuilt executable
* which directly consumes BCryptGenRandom in bcrypt.dll and outputs random bytes as hex. This
* executable is required for trusted notebooks key generation and is included with the built extension.
*/
async function downloadBCryptGenRandomExecutable() {
console.log('Downloading BCryptGenRandom.exe...');
const executableName = 'BCryptGenRandom.exe';
const uri = `https://pvsc.blob.core.windows.net/jupyter-dev-builds/${executableName}`;
const srcDestination = path.resolve(path.dirname(__dirname), '..', 'src', 'BCryptGenRandom');
const srcDestinationFilename = path.join(srcDestination, executableName);
if (fs.existsSync(srcDestinationFilename)) {
console.log('BCryptGenRandom.exe is already downloaded.');
} else {
fs.ensureDirSync(srcDestination);
await download(uri, srcDestination, { filename: executableName });
console.log('Downloaded BCryptGenRandom.exe.');
}
const outDestination = path.resolve(path.dirname(__dirname), '..', 'out', 'BCryptGenRandom');
const outDestinationFilename = path.join(outDestination, executableName);
if (fs.existsSync(outDestinationFilename)) {
console.log('BCryptGenRandom.exe is already copied to outdir.');
} else {
fs.ensureDirSync(outDestination);
fs.copyFileSync(srcDestinationFilename, outDestinationFilename);
console.log('Copied BCryptGenRandom.exe to outdir.');
}
}

(async () => {
fixJupyterLabDTSFiles();
createJupyterKernelWithoutSerialization();
await downloadBCryptGenRandomExecutable();
await downloadRendererExtension();
})().catch((ex) => console.error('Encountered error while running postInstall step', ex));
29 changes: 5 additions & 24 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ gulp.task('output:clean', () => del(['coverage']));

gulp.task('clean:cleanExceptTests', () => del(['clean:vsix', 'out/client', 'out/datascience-ui', 'out/server']));
gulp.task('clean:vsix', () => del(['*.vsix']));
gulp.task('clean:out', () => del(['out/**', '!out', '!out/BCryptGenRandom/**', '!out/client_renderer/**']));
gulp.task('clean:out', () => del(['out/**', '!out', '!out/client_renderer/**']));
gulp.task('clean:ipywidgets', () => spawnAsync('npm', ['run', 'build-ipywidgets-clean'], webpackEnv));

gulp.task('clean', gulp.parallel('output:clean', 'clean:vsix', 'clean:out'));
Expand Down Expand Up @@ -70,7 +70,7 @@ gulp.task('checkNpmDependencies', (done) => {
return;
}
const version = packages[expectedVersion.name].version || packages[expectedVersion.name];
if (!version){
if (!version) {
return;
}
if (!version.includes(expectedVersion.version)) {
Expand Down Expand Up @@ -278,39 +278,20 @@ function getAllowedWarningsForWebPack(buildConfig) {
}
}

gulp.task('includeBCryptGenRandomExe', async () => {
const src = path.join(ExtensionRootDir, 'src', 'BCryptGenRandom', 'BCryptGenRandom.exe');
const dest = path.join(ExtensionRootDir, 'out', 'BCryptGenRandom', 'BCryptGenRandom.exe');
if (fs.existsSync(dest)) {
return;
}
await fs.stat(src);
await fs.ensureDir(path.dirname(dest));
await fs.copyFile(src, dest);
});

gulp.task('downloadRendererExtension', async () => {
await downloadRendererExtension();
});

gulp.task('prePublishBundle', gulp.series('includeBCryptGenRandomExe', 'downloadRendererExtension', 'webpack'));
gulp.task('prePublishBundle', gulp.series('downloadRendererExtension', 'webpack'));
gulp.task('checkDependencies', gulp.series('checkNativeDependencies', 'checkNpmDependencies'));
// On CI, when running Notebook tests, we don't need old webviews.
// Simple & temporary optimization for the Notebook Test Job.
if (isCI && process.env.VSC_JUPYTER_SKIP_WEBVIEW_BUILD === 'true') {
gulp.task(
'prePublishNonBundle',
gulp.parallel('compile', 'includeBCryptGenRandomExe', 'downloadRendererExtension')
);
gulp.task('prePublishNonBundle', gulp.parallel('compile', 'downloadRendererExtension'));
} else {
gulp.task(
'prePublishNonBundle',
gulp.parallel(
'compile',
'includeBCryptGenRandomExe',
'downloadRendererExtension',
gulp.series('compile-webviews')
)
gulp.parallel('compile', 'downloadRendererExtension', gulp.series('compile-webviews'))
);
}

Expand Down
Loading

0 comments on commit 5f8c5c0

Please sign in to comment.