From fb7988092327dcebdb0df276f708b927f9103578 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 18 May 2023 16:00:48 -0700 Subject: [PATCH 1/5] Check config type in the ChildProcessAttachEvents --- .../debugger/extension/hooks/childProcessAttachHandler.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/debugger/extension/hooks/childProcessAttachHandler.ts b/src/client/debugger/extension/hooks/childProcessAttachHandler.ts index 6851e54a8723..23602ffce086 100644 --- a/src/client/debugger/extension/hooks/childProcessAttachHandler.ts +++ b/src/client/debugger/extension/hooks/childProcessAttachHandler.ts @@ -9,6 +9,7 @@ import { swallowExceptions } from '../../../common/utils/decorators'; import { AttachRequestArguments } from '../../types'; import { DebuggerEvents } from './constants'; import { IChildProcessAttachService, IDebugSessionEventHandlers } from './types'; +import { DebuggerTypeName } from '../../constants'; /** * This class is responsible for automatically attaching the debugger to any @@ -25,7 +26,7 @@ export class ChildProcessAttachEventHandler implements IDebugSessionEventHandler @swallowExceptions('Handle child process launch') public async handleCustomEvent(event: DebugSessionCustomEvent): Promise { - if (!event) { + if (!event || event.session.configuration.type !== DebuggerTypeName) { return; } From 6087cb25d8ebc8c9b7cd1ba0188de0d61f1ab3dd Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 18 May 2023 17:28:50 -0700 Subject: [PATCH 2/5] Fix tests --- .../childProcessAttachHandler.unit.test.ts | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/test/debugger/extension/hooks/childProcessAttachHandler.unit.test.ts b/src/test/debugger/extension/hooks/childProcessAttachHandler.unit.test.ts index ee9a59c8e6aa..dea2bc7ccabd 100644 --- a/src/test/debugger/extension/hooks/childProcessAttachHandler.unit.test.ts +++ b/src/test/debugger/extension/hooks/childProcessAttachHandler.unit.test.ts @@ -9,6 +9,7 @@ import { ChildProcessAttachEventHandler } from '../../../../client/debugger/exte import { ChildProcessAttachService } from '../../../../client/debugger/extension/hooks/childProcessAttachService'; import { DebuggerEvents } from '../../../../client/debugger/extension/hooks/constants'; import { AttachRequestArguments } from '../../../../client/debugger/types'; +import { DebuggerTypeName } from '../../../../client/debugger/constants'; suite('Debug - Child Process', () => { test('Do not attach if the event is undefined', async () => { @@ -21,7 +22,15 @@ suite('Debug - Child Process', () => { const attachService = mock(ChildProcessAttachService); const handler = new ChildProcessAttachEventHandler(instance(attachService)); const body: any = {}; - const session: any = {}; + const session: any = {configuration: { type: DebuggerTypeName }}; + await handler.handleCustomEvent({ event: 'abc', body, session }); + verify(attachService.attach(body, session)).never(); + }); + test('Do not attach to child process if debugger type is different', async () => { + const attachService = mock(ChildProcessAttachService); + const handler = new ChildProcessAttachEventHandler(instance(attachService)); + const body: any = {}; + const session: any = {configuration: { type: 'other-type' }}; await handler.handleCustomEvent({ event: 'abc', body, session }); verify(attachService.attach(body, session)).never(); }); @@ -29,7 +38,7 @@ suite('Debug - Child Process', () => { const attachService = mock(ChildProcessAttachService); const handler = new ChildProcessAttachEventHandler(instance(attachService)); const body: any = {}; - const session: any = {}; + const session: any = {configuration: { type: DebuggerTypeName }}; await handler.handleCustomEvent({ event: DebuggerEvents.PtvsdAttachToSubprocess, body, session }); verify(attachService.attach(body, session)).never(); }); @@ -37,7 +46,7 @@ suite('Debug - Child Process', () => { const attachService = mock(ChildProcessAttachService); const handler = new ChildProcessAttachEventHandler(instance(attachService)); const body: any = {}; - const session: any = {}; + const session: any = {configuration: { type: DebuggerTypeName }}; await handler.handleCustomEvent({ event: DebuggerEvents.DebugpyAttachToSubprocess, body, session }); verify(attachService.attach(body, session)).never(); }); @@ -51,9 +60,11 @@ suite('Debug - Child Process', () => { port: 1234, subProcessId: 2, }; - const session: any = {}; + const session: any = { + configuration: { type: DebuggerTypeName } + }; when(attachService.attach(body, session)).thenThrow(new Error('Kaboom')); - await handler.handleCustomEvent({ event: DebuggerEvents.DebugpyAttachToSubprocess, body, session: {} as any }); + await handler.handleCustomEvent({ event: DebuggerEvents.DebugpyAttachToSubprocess, body, session }); verify(attachService.attach(body, anything())).once(); const [, secondArg] = capture(attachService.attach).last(); expect(secondArg).to.deep.equal(session); From 084b6eeaabdd6d242000f6d22430cf46111c8bc5 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Thu, 18 May 2023 17:34:16 -0700 Subject: [PATCH 3/5] Fix format --- .../hooks/childProcessAttachHandler.unit.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/debugger/extension/hooks/childProcessAttachHandler.unit.test.ts b/src/test/debugger/extension/hooks/childProcessAttachHandler.unit.test.ts index dea2bc7ccabd..b1053def2eba 100644 --- a/src/test/debugger/extension/hooks/childProcessAttachHandler.unit.test.ts +++ b/src/test/debugger/extension/hooks/childProcessAttachHandler.unit.test.ts @@ -22,7 +22,7 @@ suite('Debug - Child Process', () => { const attachService = mock(ChildProcessAttachService); const handler = new ChildProcessAttachEventHandler(instance(attachService)); const body: any = {}; - const session: any = {configuration: { type: DebuggerTypeName }}; + const session: any = { configuration: { type: DebuggerTypeName } }; await handler.handleCustomEvent({ event: 'abc', body, session }); verify(attachService.attach(body, session)).never(); }); @@ -30,7 +30,7 @@ suite('Debug - Child Process', () => { const attachService = mock(ChildProcessAttachService); const handler = new ChildProcessAttachEventHandler(instance(attachService)); const body: any = {}; - const session: any = {configuration: { type: 'other-type' }}; + const session: any = { configuration: { type: 'other-type' } }; await handler.handleCustomEvent({ event: 'abc', body, session }); verify(attachService.attach(body, session)).never(); }); @@ -38,7 +38,7 @@ suite('Debug - Child Process', () => { const attachService = mock(ChildProcessAttachService); const handler = new ChildProcessAttachEventHandler(instance(attachService)); const body: any = {}; - const session: any = {configuration: { type: DebuggerTypeName }}; + const session: any = { configuration: { type: DebuggerTypeName } }; await handler.handleCustomEvent({ event: DebuggerEvents.PtvsdAttachToSubprocess, body, session }); verify(attachService.attach(body, session)).never(); }); @@ -46,7 +46,7 @@ suite('Debug - Child Process', () => { const attachService = mock(ChildProcessAttachService); const handler = new ChildProcessAttachEventHandler(instance(attachService)); const body: any = {}; - const session: any = {configuration: { type: DebuggerTypeName }}; + const session: any = { configuration: { type: DebuggerTypeName } }; await handler.handleCustomEvent({ event: DebuggerEvents.DebugpyAttachToSubprocess, body, session }); verify(attachService.attach(body, session)).never(); }); @@ -61,7 +61,7 @@ suite('Debug - Child Process', () => { subProcessId: 2, }; const session: any = { - configuration: { type: DebuggerTypeName } + configuration: { type: DebuggerTypeName }, }; when(attachService.attach(body, session)).thenThrow(new Error('Kaboom')); await handler.handleCustomEvent({ event: DebuggerEvents.DebugpyAttachToSubprocess, body, session }); From fcc39e8a51397f2752086de113c11f16bcb02599 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Tue, 23 May 2023 11:04:42 -0700 Subject: [PATCH 4/5] rollback pyright --- .github/workflows/build.yml | 1 + .github/workflows/pr-check.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 805077ffdb46..395c920b64f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -101,6 +101,7 @@ jobs: python -m pip install --upgrade -r build/test-requirements.txt - name: Run Pyright + version: 1.1.308 uses: jakebailey/pyright-action@v1 with: working-directory: 'pythonFiles' diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 2ac560af995d..c4dd71f2b4dc 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -75,6 +75,7 @@ jobs: python -m pip install --upgrade -r build/test-requirements.txt - name: Run Pyright + version: 1.1.308 uses: jakebailey/pyright-action@v1 with: working-directory: 'pythonFiles' From 17b999eacdfa927e6ec78af669d919b3c8dd9ad4 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 24 May 2023 08:55:50 -0700 Subject: [PATCH 5/5] Fix-workflow --- .github/workflows/build.yml | 2 +- .github/workflows/pr-check.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 395c920b64f3..f418a802ff8e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -101,9 +101,9 @@ jobs: python -m pip install --upgrade -r build/test-requirements.txt - name: Run Pyright - version: 1.1.308 uses: jakebailey/pyright-action@v1 with: + version: 1.1.308 working-directory: 'pythonFiles' ### Non-smoke tests diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index c4dd71f2b4dc..84903463e204 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -75,9 +75,9 @@ jobs: python -m pip install --upgrade -r build/test-requirements.txt - name: Run Pyright - version: 1.1.308 uses: jakebailey/pyright-action@v1 with: + version: 1.1.308 working-directory: 'pythonFiles' ### Non-smoke tests