Skip to content

Commit 28f2baf

Browse files
authored
Merge pull request #875 from puppetlabs/cat-1707-address_vulnerabilities
(CAT-1707) - Bump vscode-languageclient ^9.0.0, axios ^1.0.0 & typescript ^5.0.0
2 parents 3c7a240 + f8c9829 commit 28f2baf

File tree

9 files changed

+1154
-4032
lines changed

9 files changed

+1154
-4032
lines changed

package-lock.json

Lines changed: 1107 additions & 3981 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -653,16 +653,16 @@
653653
"glob": "^7.1.4",
654654
"mocha": "^9.2.2",
655655
"prettier": "^2.0.5",
656-
"typescript": "^3.5.2",
657-
"vsce": "^2.15.0",
658-
"@vscode/test-electron": "2.x"
656+
"typescript": "^5.0",
657+
"@vscode/vsce": "^2.15.0",
658+
"@vscode/test-electron": "^2.0"
659659
},
660660
"dependencies": {
661-
"axios": "0.21.2",
661+
"axios": "^1.0.0",
662662
"jsonc-parser": "~2.1.0",
663663
"vscode-debugadapter": "^1.19.0",
664664
"vscode-debugprotocol": "^1.19.0",
665665
"vscode-extension-telemetry": "0.1.2",
666-
"vscode-languageclient": "^5.2.1"
666+
"vscode-languageclient": "^9.0.0"
667667
}
668668
}

src/handler.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import * as vscode from 'vscode';
2-
import { LanguageClient, ServerOptions, LanguageClientOptions, RevealOutputChannelOn } from 'vscode-languageclient';
2+
import {
3+
LanguageClient,
4+
LanguageClientOptions,
5+
RevealOutputChannelOn,
6+
ServerOptions,
7+
} from 'vscode-languageclient/node';
38

4-
import { ConnectionStatus } from './interfaces';
5-
import { ConnectionType, ProtocolType } from './settings';
9+
import { IAggregateConfiguration } from './configuration';
10+
import { puppetFileLangID, puppetLangID } from './extension';
611
import { IPuppetStatusBar } from './feature/PuppetStatusBarFeature';
12+
import { ConnectionStatus } from './interfaces';
713
import { OutputChannelLogger } from './logging/outputchannel';
8-
import { PuppetVersionDetails, PuppetVersionRequest, PuppetCommandStrings } from './messages';
14+
import { PuppetCommandStrings, PuppetVersionDetails, PuppetVersionRequest } from './messages';
15+
import { ConnectionType, ProtocolType } from './settings';
916
import { reporter } from './telemetry';
10-
import { puppetFileLangID, puppetLangID } from './extension';
11-
import { IAggregateConfiguration } from './configuration';
1217

1318
export abstract class ConnectionHandler {
1419
private timeSpent: number;
@@ -56,7 +61,7 @@ export abstract class ConnectionHandler {
5661
this.logger.debug('Creating language client');
5762
this._languageClient = new LanguageClient('PuppetVSCode', serverOptions, clientOptions);
5863
this._languageClient
59-
.onReady()
64+
.start()
6065
.then(
6166
() => {
6267
this.languageClient.onTelemetry((event) => {
@@ -90,7 +95,11 @@ export abstract class ConnectionHandler {
9095

9196
start(): void {
9297
this.setConnectionStatus('Starting languageserver', ConnectionStatus.Starting, '');
93-
this.context.subscriptions.push(this.languageClient.start());
98+
this.languageClient.start().then(() => {
99+
this.context.subscriptions.push({
100+
dispose: () => this.languageClient.stop(),
101+
});
102+
});
94103
}
95104

96105
stop(): void {
@@ -129,7 +138,7 @@ export abstract class ConnectionHandler {
129138
if (count >= 30 || this._languageClient === undefined) {
130139
clearInterval(handle);
131140
this.setConnectionStatus(lastVersionResponse.puppetVersion, ConnectionStatus.RunningLoaded, '');
132-
resolve();
141+
resolve(undefined);
133142
return;
134143
}
135144

@@ -143,7 +152,7 @@ export abstract class ConnectionHandler {
143152
) {
144153
clearInterval(handle);
145154
this.setConnectionStatus(lastVersionResponse.puppetVersion, ConnectionStatus.RunningLoaded, '');
146-
resolve();
155+
resolve(undefined);
147156
} else {
148157
let toolTip = '';
149158

src/handlers/stdio.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import { Executable, ServerOptions } from 'vscode-languageclient';
2+
import { Executable, ServerOptions } from 'vscode-languageclient/node';
33
import { IAggregateConfiguration } from '../configuration';
44
import { IPuppetStatusBar } from '../feature/PuppetStatusBarFeature';
55
import { ConnectionHandler } from '../handler';

src/handlers/tcp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as cp from 'child_process';
22
import * as net from 'net';
33
import * as vscode from 'vscode';
4-
import { Executable, ServerOptions, StreamInfo } from 'vscode-languageclient';
4+
import { Executable, ServerOptions, StreamInfo } from 'vscode-languageclient/node';
55
import { IAggregateConfiguration } from '../configuration';
66
import { IPuppetStatusBar } from '../feature/PuppetStatusBarFeature';
77
import { ConnectionHandler } from '../handler';

src/helpers/commandHelper.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from 'path';
22
import * as vscode from 'vscode';
3-
import { Executable } from 'vscode-languageclient';
3+
import { Executable } from 'vscode-languageclient/node';
44
import { IAggregateConfiguration } from '../configuration';
55
import { PathResolver } from '../configuration/pathResolver';
66
import { ProtocolType, PuppetInstallType } from '../settings';
@@ -35,7 +35,6 @@ export class CommandEnvironmentHelper {
3535
private static applyRubyEnvFromConfiguration(exe: Executable, config: IAggregateConfiguration): Executable {
3636
// setup defaults
3737
exe.options.env = this.shallowCloneObject(process.env);
38-
exe.options.stdio = 'pipe';
3938

4039
switch (process.platform) {
4140
case 'win32':

src/messages.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-disable @typescript-eslint/no-namespace */
2-
import { RequestType, RequestType0 } from 'vscode-languageclient';
2+
import { RequestType, RequestType0 } from 'vscode-languageclient/node';
33

44
export namespace PuppetVersionRequest {
5-
export const type = new RequestType0<PuppetVersionDetails, void, void>('puppet/getVersion');
5+
export const type = new RequestType0<PuppetVersionDetails, void>('puppet/getVersion');
66
}
77

88
export interface PuppetVersionDetails {
@@ -21,7 +21,7 @@ export interface PuppetResourceRequestParams {
2121
}
2222

2323
export namespace PuppetResourceRequest {
24-
export const type = new RequestType<PuppetResourceRequestParams, PuppetResourceResponse, void, void>(
24+
export const type = new RequestType<PuppetResourceRequestParams, PuppetResourceResponse, void>(
2525
'puppet/getResource',
2626
);
2727
}
@@ -37,7 +37,7 @@ export interface PuppetFixDiagnosticErrorsRequestParams {
3737
}
3838

3939
export namespace PuppetFixDiagnosticErrorsRequest {
40-
export const type = new RequestType<PuppetFixDiagnosticErrorsRequestParams, any, void, void>(
40+
export const type = new RequestType<PuppetFixDiagnosticErrorsRequestParams, any, void>(
4141
'puppet/fixDiagnosticErrors',
4242
);
4343
}
@@ -49,7 +49,7 @@ export interface PuppetFixDiagnosticErrorsResponse {
4949
}
5050

5151
export namespace PuppetNodeGraphRequest {
52-
export const type = new RequestType<any, PuppetNodeGraphResponse, void, void>('puppet/compileNodeGraph');
52+
export const type = new RequestType<any, PuppetNodeGraphResponse, void>('puppet/compileNodeGraph');
5353
}
5454

5555
export interface PuppetNodeGraphResponse {
@@ -59,7 +59,7 @@ export interface PuppetNodeGraphResponse {
5959
}
6060

6161
export namespace CompileNodeGraphRequest {
62-
export const type = new RequestType<any, any, void, void>('puppet/compileNodeGraph');
62+
export const type = new RequestType<any, any, void>('puppet/compileNodeGraph');
6363
}
6464

6565
export interface CompileNodeGraphResponse {

src/views/facts.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
TreeItem,
99
TreeItemCollapsibleState,
1010
} from 'vscode';
11-
import { RequestType0 } from 'vscode-languageclient';
11+
import { RequestType0 } from 'vscode-languageclient/node';
1212
import { ConnectionHandler } from '../handler';
1313
import { PuppetVersionDetails } from '../messages';
1414
import { reporter } from '../telemetry';
@@ -21,20 +21,14 @@ class PuppetFact extends TreeItem {
2121
public readonly children?: Array<[string, PuppetFact]>,
2222
) {
2323
super(label, collapsibleState);
24+
this.tooltip = `${this.label}-${this.value}`;
25+
this.description = this.value;
2426
if (children) {
2527
this.iconPath = ThemeIcon.Folder;
2628
} else {
2729
this.iconPath = ThemeIcon.File;
2830
}
2931
}
30-
31-
get tooltip(): string {
32-
return `${this.label}-${this.value}`;
33-
}
34-
35-
get description(): string {
36-
return this.value;
37-
}
3832
}
3933

4034
interface PuppetFactResponse {
@@ -53,7 +47,7 @@ export class PuppetFactsProvider implements TreeDataProvider<PuppetFact> {
5347
}
5448

5549
refresh(): void {
56-
this._onDidChangeTreeData.fire();
50+
this._onDidChangeTreeData.fire(undefined);
5751
}
5852

5953
getTreeItem(element: PuppetFact): TreeItem | Thenable<PuppetFact> {
@@ -75,10 +69,10 @@ export class PuppetFactsProvider implements TreeDataProvider<PuppetFact> {
7569
if we didn't cache, we would have to call out for each expand and getting
7670
facts is slow.
7771
*/
78-
await this.handler.languageClient.onReady();
72+
await this.handler.languageClient.start();
7973

8074
const details = await this.handler.languageClient.sendRequest(
81-
new RequestType0<PuppetVersionDetails, void, void>('puppet/getVersion'),
75+
new RequestType0<PuppetVersionDetails, void>('puppet/getVersion'),
8276
);
8377
if (!details.factsLoaded) {
8478
// language server is ready, but hasn't loaded facts yet
@@ -90,7 +84,7 @@ export class PuppetFactsProvider implements TreeDataProvider<PuppetFact> {
9084
clearInterval(handle);
9185

9286
const results = await this.handler.languageClient.sendRequest(
93-
new RequestType0<PuppetFactResponse, void, void>('puppet/getFacts'),
87+
new RequestType0<PuppetFactResponse, void>('puppet/getFacts'),
9488
);
9589
this.elements = this.toList(results.facts);
9690

@@ -102,13 +96,13 @@ export class PuppetFactsProvider implements TreeDataProvider<PuppetFact> {
10296
}
10397

10498
const details = await this.handler.languageClient.sendRequest(
105-
new RequestType0<PuppetVersionDetails, void, void>('puppet/getVersion'),
99+
new RequestType0<PuppetVersionDetails, void>('puppet/getVersion'),
106100
);
107101
if (details.factsLoaded) {
108102
clearInterval(handle);
109103

110104
const results = await this.handler.languageClient.sendRequest(
111-
new RequestType0<PuppetFactResponse, void, void>('puppet/getFacts'),
105+
new RequestType0<PuppetFactResponse, void>('puppet/getFacts'),
112106
);
113107
this.elements = this.toList(results.facts);
114108

@@ -125,7 +119,7 @@ export class PuppetFactsProvider implements TreeDataProvider<PuppetFact> {
125119
}
126120

127121
const results = await this.handler.languageClient.sendRequest(
128-
new RequestType0<PuppetFactResponse, void, void>('puppet/getFacts'),
122+
new RequestType0<PuppetFactResponse, void>('puppet/getFacts'),
129123
);
130124
this.elements = this.toList(results.facts);
131125

src/views/puppetfile.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,14 @@ class PuppetfileDependencyItem extends TreeItem {
2727
public readonly children?: Array<[string, PuppetfileDependencyItem]>,
2828
) {
2929
super(name, collapsibleState);
30+
this.tooltip = `${name}-${version}`;
31+
this.description = version;
3032
if (children) {
3133
this.iconPath = ThemeIcon.Folder;
3234
} else {
3335
this.iconPath = new ThemeIcon('package');
3436
}
3537
}
36-
37-
get tooltip(): string {
38-
return `${this.name}-${this.version}`;
39-
}
40-
41-
get description(): string {
42-
return this.version;
43-
}
4438
}
4539

4640
class PuppetfileDependency {
@@ -105,7 +99,7 @@ export class PuppetfileProvider implements TreeDataProvider<PuppetfileDependency
10599
}
106100

107101
private async getPuppetfileDependenciesFromLanguageServer(): Promise<PuppetfileDependencyItem[]> {
108-
await this.handler.languageClient.onReady();
102+
await this.handler.languageClient.start();
109103

110104
const fileUri = Uri.file(path.join(workspace.workspaceFolders[0].uri.fsPath, 'Puppetfile'));
111105
/*
@@ -115,7 +109,7 @@ export class PuppetfileProvider implements TreeDataProvider<PuppetfileDependency
115109
*/
116110
return workspace.openTextDocument(fileUri).then(async () => {
117111
const results = await this.handler.languageClient.sendRequest(
118-
new RequestType<never, PuppetfileDependencyResponse, void, void>('puppetfile/getDependencies'),
112+
new RequestType<never, PuppetfileDependencyResponse, void>('puppetfile/getDependencies'),
119113
{
120114
uri: fileUri.toString(),
121115
},

0 commit comments

Comments
 (0)