Skip to content

Commit

Permalink
Disable kernel auto startup in untrusted workspace (#6088)
Browse files Browse the repository at this point in the history
* Disable kernel auto startup in untrusted workspace

* Fixes

* Misc

* oops

* misc
  • Loading branch information
DonJayamanne authored Jun 2, 2021
1 parent e18c7c6 commit 5c2cf0c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,67 @@ jobs:
- name: Check dependencies
run: npm run checkDependencies

vsc_api_check:
needs: pick_environment
name: VSC Stable & Proposed API
runs-on: ${{ matrix.os }}
if: github.repository == 'microsoft/vscode-jupyter'
strategy:
fail-fast: false
matrix:
os: ${{fromJson(needs.pick_environment.outputs.test_matrix_os)}}
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Use Node ${{env.NODE_VERSION}}
uses: actions/setup-node@v2.1.5
with:
node-version: ${{env.NODE_VERSION}}

# Caching of npm packages (https://github.com/actions/cache/blob/main/examples.md#node---npm)
- name: Cache npm on linux/mac
uses: actions/cache@v2.1.4
if: matrix.os != 'windows-latest'
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Get npm cache directory
if: matrix.os == 'windows-latest'
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: Cache npm on windows
uses: actions/cache@v2.1.4
if: matrix.os == 'windows-latest'
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache compiled TS files
# Use an id for this step so that its cache-hit output can be accessed and checked in the next step.
id: out-cache
uses: actions/cache@v2.1.4
with:
path: ./out
key: ${{runner.os}}-${{env.CACHE_OUT_DIRECTORY}}-${{hashFiles('src/**')}}

- name: Install dependencies (npm ci)
run: npm ci --prefer-offline

- name: Install Stable + Proposed API
run: npm run download-api

- name: Compile if not cached
run: npx gulp prePublishNonBundle
env:
CI_JUPYTER_FAST_COMPILATION: 'true'

ts_tests:
needs: pick_environment
name: Type Script Tests
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,7 @@
"build-ipywidgets-compile": "tsc -p ./src/ipywidgets && rimraf ./out/tsconfig.tsbuildinfo && node ./src/ipywidgets/scripts/copyfiles.js",
"build-ipywidgets-webpack": "cross-env NODE_OPTIONS=--max_old_space_size=9096 webpack --config ./src/ipywidgets/webpack.config.js",
"checkDependencies": "gulp checkDependencies",
"postinstall": "npm run download-api && node ./build/ci/postInstall.js",
"postinstall": "node ./build/ci/postInstall.js",
"test:unittests": "mocha --config ./build/.mocha.unittests.js.json",
"test:functional": "mocha --require source-map-support/register --config ./build/.mocha.functional.json",
"test:functional:perf": "node --inspect-brk ./node_modules/mocha/bin/_mocha --require source-map-support/register --config ./build/.mocha.functional.perf.json",
Expand Down
7 changes: 6 additions & 1 deletion src/client/datascience/jupyter/serverPreload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'use strict';
import { inject, injectable } from 'inversify';
import { IExtensionSingleActivationService } from '../../activation/types';
import { IWorkspaceService } from '../../common/application/types';
import { traceError, traceInfo } from '../../common/logger';
import { IConfigurationService } from '../../common/types';
import {
Expand All @@ -21,7 +22,8 @@ export class ServerPreload implements IExtensionSingleActivationService {
@inject(INotebookEditorProvider) private notebookEditorProvider: INotebookEditorProvider,
@inject(IInteractiveWindowProvider) private interactiveProvider: IInteractiveWindowProvider,
@inject(IConfigurationService) private configService: IConfigurationService,
@inject(INotebookProvider) private notebookProvider: INotebookProvider
@inject(INotebookProvider) private notebookProvider: INotebookProvider,
@inject(IWorkspaceService) private readonly workspace: IWorkspaceService
) {
this.notebookEditorProvider.onDidOpenNotebookEditor(this.onDidOpenNotebook.bind(this));
this.interactiveProvider.onDidChangeActiveInteractiveWindow(this.onDidOpenOrCloseInteractive.bind(this));
Expand Down Expand Up @@ -55,6 +57,9 @@ export class ServerPreload implements IExtensionSingleActivationService {
}

private async createServerIfNecessary() {
if (!this.workspace.isTrusted) {
return;
}
try {
traceInfo(`Attempting to start a server because of preload conditions ...`);

Expand Down

0 comments on commit 5c2cf0c

Please sign in to comment.