diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 16faa4f5f..9d32814bc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Run extension and debug -Clone the repository, then run `npm install` in the directory. +Clone the repository, then run `npm install && npm run build` in the directory. - Open repository directory in VS Code and press `F5` to run extension in a new VS Code window. - This allows extension debugging within VS Code. diff --git a/src/snyk/common/commands/commandController.ts b/src/snyk/common/commands/commandController.ts index cb2f31a28..f3c2642c1 100644 --- a/src/snyk/common/commands/commandController.ts +++ b/src/snyk/common/commands/commandController.ts @@ -1,14 +1,13 @@ /* eslint-disable @typescript-eslint/no-unsafe-argument */ import _ from 'lodash'; +import path from 'path'; import { IAuthenticationService } from '../../base/services/authenticationService'; import { ScanModeService } from '../../base/services/scanModeService'; import { createDCIgnore } from '../../snykCode/utils/ignoreFileUtils'; import { IssueUtils } from '../../snykCode/utils/issueUtils'; import { CodeIssueCommandArg } from '../../snykCode/views/interfaces'; import { IacIssueCommandArg } from '../../snykIac/views/interfaces'; -import { capitalizeOssSeverity } from '../../snykOss/ossResult'; -import { OssService } from '../../snykOss/services/ossService'; -import { OssIssueCommandArg } from '../../snykOss/views/ossVulnerabilityTreeProvider'; +import { OssServiceLanguageServer } from '../../snykOss/ossServiceLanguageServer'; import { IAnalytics } from '../analytics/itly'; import { SNYK_INITIATE_LOGIN_COMMAND, @@ -40,7 +39,7 @@ export class CommandController { private authService: IAuthenticationService, private snykCode: IProductService, private iacService: IProductService, - private ossService: OssService, + private ossService: OssServiceLanguageServer, private scanModeService: ScanModeService, private workspace: IVSCodeWorkspace, private commands: IVSCodeCommands, @@ -122,14 +121,28 @@ export class CommandController { severity: IssueUtils.issueSeverityAsText(issue.severity), }); } else if (arg.issueType == OpenCommandIssueType.OssVulnerability) { - const issue = arg.issue as OssIssueCommandArg; - void this.ossService.showSuggestionProvider(issue); + const issueArgs = arg.issue as CodeIssueCommandArg; + const folderPath = path.dirname(issueArgs.filePath); + const issue = this.ossService.getIssue(folderPath, issueArgs.id); + + if (!issue) { + this.logger.warn(`Failed to find the issue ${issueArgs.id}.`); + return; + } + + await this.openLocalFile(issue.filePath, issueArgs.range); + + try { + await this.ossService.showSuggestionProvider(folderPath, issueArgs.id); + } catch (e) { + ErrorHandler.handle(e, this.logger); + } this.analytics.logIssueInTreeIsClicked({ ide: IDE_NAME, issueId: issue.id, issueType: 'Open Source Vulnerability', - severity: capitalizeOssSeverity(issue.severity), + severity: IssueUtils.issueSeverityAsText(issue.severity), }); } else if (arg.issueType == OpenCommandIssueType.IacIssue) { const issueArgs = arg.issue as IacIssueCommandArg; diff --git a/src/snyk/common/languageServer/types.ts b/src/snyk/common/languageServer/types.ts index 9dbe9a125..1a7d150d7 100644 --- a/src/snyk/common/languageServer/types.ts +++ b/src/snyk/common/languageServer/types.ts @@ -95,6 +95,8 @@ export type OssIssueData = { projectName: string; displayTargetFile: string; + + details: string; }; export type Identifiers = { CWE: string[]; diff --git a/src/snyk/extension.ts b/src/snyk/extension.ts index 8085d6d9d..8bc849a01 100644 --- a/src/snyk/extension.ts +++ b/src/snyk/extension.ts @@ -50,7 +50,7 @@ import { DownloadService } from './common/services/downloadService'; import { LearnService } from './common/services/learnService'; import { NotificationService } from './common/services/notificationService'; import { User } from './common/user'; -import { CodeActionAdapter, CodeActionKindAdapter } from './common/vscode/codeAction'; +import { CodeActionAdapter } from './common/vscode/codeAction'; import { vsCodeCommands } from './common/vscode/commands'; import { vsCodeEnv } from './common/vscode/env'; import { extensionContext } from './common/vscode/extensionContext'; @@ -239,8 +239,6 @@ class SnykExtension extends SnykLib implements IExtension { extensionContext, configuration, ossSuggestionProvider, - new CodeActionAdapter(), - this.codeActionKindAdapter, this.viewManagerService, vsCodeWorkspace, this.workspaceTrust, @@ -278,7 +276,7 @@ class SnykExtension extends SnykLib implements IExtension { this.authService, this.snykCode, this.iacService, - this.ossService, + this.ossServiceLanguageServer, this.scanModeService, vsCodeWorkspace, vsCodeCommands, @@ -427,7 +425,6 @@ class SnykExtension extends SnykLib implements IExtension { this.ossServiceLanguageServer, Logger, new EditorDecorator(vsCodeWindow, vsCodeLanguages, new ThemeColorAdapter()), - new CodeActionKindAdapter(), this.analytics, configuration, ); diff --git a/src/snyk/snykOss/codeActions/vulnerabilityCodeActionProviderLS.ts b/src/snyk/snykOss/codeActions/vulnerabilityCodeActionProviderLS.ts deleted file mode 100644 index 1d398a5f5..000000000 --- a/src/snyk/snykOss/codeActions/vulnerabilityCodeActionProviderLS.ts +++ /dev/null @@ -1,101 +0,0 @@ -import marked from 'marked'; -import { IAnalytics } from '../../common/analytics/itly'; -import { OpenCommandIssueType, OpenIssueCommandArg } from '../../common/commands/types'; -import { SNYK_OPEN_ISSUE_COMMAND } from '../../common/constants/commands'; -import { IDE_NAME } from '../../common/constants/general'; -import { ICodeActionKindAdapter } from '../../common/vscode/codeAction'; -import { - CodeAction, - CodeActionContext, - CodeActionKind, - CodeActionProvider, - Command, - ProviderResult, - Range, - Selection, - TextDocument, -} from '../../common/vscode/types'; -import { DIAGNOSTICS_OSS_COLLECTION_NAME } from '../../snykCode/constants/analysis'; -import { messages } from '../messages/vulnerabilityCount'; -import { OssVulnerability, isResultCliError } from '../ossResult'; -import { ModuleVulnerabilityCountProviderLS } from '../services/vulnerabilityCount/vulnerabilityCountProviderLS'; -import { OssIssueCommandArg } from '../views/ossVulnerabilityTreeProvider'; - -export class VulnerabilityCodeActionProviderLS implements CodeActionProvider { - public codeActionKinds: ReadonlyArray = [this.codeActionKindProvider.getQuickFix()]; - - constructor( - private readonly vulnerabilityCountProvider: ModuleVulnerabilityCountProviderLS, - private readonly codeActionKindProvider: ICodeActionKindAdapter, - private readonly analytics: IAnalytics, - ) {} - - async provideCodeActions( - document: TextDocument, - _: Range | Selection, - context: CodeActionContext, - ): Promise> { - const ossDiagnostics = context.diagnostics.filter(d => d.source === DIAGNOSTICS_OSS_COLLECTION_NAME); - if (!ossDiagnostics.length) { - return; - } - - const ossResult = this.vulnerabilityCountProvider.getResultArray(); - if (!ossResult) { - return; - } - - const fileResult = ossResult.find( - res => !isResultCliError(res) && this.vulnerabilityCountProvider.isFilePartOfOssTest(document.fileName, res), - ); - - if (!fileResult || isResultCliError(fileResult)) { - return; - } - - for (const diagnostic of ossDiagnostics) { - const vulnerability = fileResult.vulnerabilities.find(vuln => vuln.id === diagnostic.code); - if (!vulnerability) { - continue; - } - - const command: Command = { - command: SNYK_OPEN_ISSUE_COMMAND, - title: messages.showMostSevereVulnerability, - arguments: [ - { - issueType: OpenCommandIssueType.OssVulnerability, - issue: await this.getOssIssueCommandArg(vulnerability, fileResult.vulnerabilities), - } as OpenIssueCommandArg, - ], - }; - - this.analytics.logQuickFixIsDisplayed({ - quickFixType: ['Show Most Severe Vulnerability'], - ide: IDE_NAME, - }); - - return [command]; - } - } - - getOssIssueCommandArg( - vulnerability: OssVulnerability, - allVulnerabilities: OssVulnerability[], - ): Promise { - return new Promise((resolve, reject) => { - const matchingIdVulnerabilities = allVulnerabilities.filter(v => v.id === vulnerability.id); - marked.parse(vulnerability.description, (err, overviewHtml) => { - if (err) { - return reject(err); - } - - return resolve({ - ...vulnerability, - matchingIdVulnerabilities: matchingIdVulnerabilities, - overviewHtml, - }); - }); - }); - } -} diff --git a/src/snyk/snykOss/hoverProvider/vulnerabilityCountHoverProvider.ts b/src/snyk/snykOss/hoverProvider/vulnerabilityCountHoverProvider.ts deleted file mode 100644 index 8fc56f11d..000000000 --- a/src/snyk/snykOss/hoverProvider/vulnerabilityCountHoverProvider.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { IAnalytics } from '../../common/analytics/itly'; -import { IDE_NAME } from '../../common/constants/general'; -import { SupportedLanguageIds } from '../../common/constants/languageConsts'; -import { IVSCodeLanguages } from '../../common/vscode/languages'; -import { DiagnosticCollection, Disposable, Hover, Position, TextDocument } from '../../common/vscode/types'; -import { IssueUtils } from '../../snykCode/utils/issueUtils'; - -export class VulnerabilityCountHoverProvider implements Disposable { - private hoverProvider: Disposable | undefined; - - constructor(private readonly vscodeLanguages: IVSCodeLanguages, private readonly analytics: IAnalytics) {} - - register(diagnostics: DiagnosticCollection | undefined): Disposable { - const documentFilter = SupportedLanguageIds.map(id => ({ scheme: 'file', language: id })); - - this.hoverProvider = this.vscodeLanguages.registerHoverProvider(documentFilter, { - provideHover: this.getHover(diagnostics), - }); - - return this; - } - - getHover(diagnostics: DiagnosticCollection | undefined) { - return (document: TextDocument, position: Position): Hover | undefined => { - if (!diagnostics || !diagnostics.has(document.uri)) { - return undefined; - } - - const currentFileReviewIssues = diagnostics.get(document.uri); - const issue = IssueUtils.findIssueWithRange(position, currentFileReviewIssues); - if (issue) { - this.logIssueHoverIsDisplayed(); - } - }; - } - - private logIssueHoverIsDisplayed(): void { - this.analytics.logIssueHoverIsDisplayed({ - issueType: 'Open Source Vulnerability', - ide: IDE_NAME, - }); - } - - dispose(): void { - if (this.hoverProvider) { - this.hoverProvider.dispose(); - } - } -} diff --git a/src/snyk/snykOss/ossResult.ts b/src/snyk/snykOss/ossResult.ts index b469695d8..aabe8b873 100644 --- a/src/snyk/snykOss/ossResult.ts +++ b/src/snyk/snykOss/ossResult.ts @@ -1,6 +1,6 @@ import _ from 'lodash'; import { CliError } from '../cli/services/cliService'; -import { IssueSeverity } from '../common/languageServer/types'; +import { Issue, IssueSeverity, OssIssueData } from '../common/languageServer/types'; export type OssResult = OssFileResult[] | OssFileResult; @@ -70,3 +70,34 @@ export function convertSeverity(severity: IssueSeverity): OssSeverity { return OssSeverity.Critical; } } + +export function convertIssue(issue: Issue): OssVulnerability { + const tempVuln: OssVulnerability = { + id: issue.id, + identifiers: issue.additionalData.identifiers, + title: issue.title, + description: issue.additionalData.description, + language: issue.additionalData.language, + packageManager: issue.additionalData.packageManager, + packageName: issue.additionalData.packageName, + severity: convertSeverity(issue.severity), + name: issue.additionalData.name, + version: issue.additionalData.version, + exploit: issue.additionalData.exploit, + + CVSSv3: issue.additionalData.CVSSv3, + cvssScore: issue.additionalData.cvssScore, + + fixedIn: issue.additionalData.fixedIn === undefined ? [] : issue.additionalData.fixedIn, + from: issue.additionalData.from, + upgradePath: issue.additionalData.upgradePath, + isPatchable: issue.additionalData.isPatchable, + isUpgradable: issue.additionalData.isUpgradable, + }; + + if (issue.additionalData.license !== undefined) { + tempVuln.license = issue.additionalData.license; + } + + return tempVuln; +} diff --git a/src/snyk/snykOss/ossServiceLanguageServer.ts b/src/snyk/snykOss/ossServiceLanguageServer.ts index eef3e7a95..e1d5f0610 100644 --- a/src/snyk/snykOss/ossServiceLanguageServer.ts +++ b/src/snyk/snykOss/ossServiceLanguageServer.ts @@ -7,7 +7,6 @@ import { OssIssueData, Scan, ScanProduct } from '../common/languageServer/types' import { ILog } from '../common/logger/interfaces'; import { ProductService } from '../common/services/productService'; import { IViewManagerService } from '../common/services/viewManagerService'; -import { ICodeActionAdapter, ICodeActionKindAdapter } from '../common/vscode/codeAction'; import { ExtensionContext } from '../common/vscode/extensionContext'; import { IVSCodeLanguages } from '../common/vscode/languages'; import { IVSCodeWorkspace } from '../common/vscode/workspace'; @@ -18,8 +17,6 @@ export class OssServiceLanguageServer extends ProductService { extensionContext: ExtensionContext, config: IConfiguration, suggestionProvider: IOssSuggestionWebviewProvider, - readonly codeActionAdapter: ICodeActionAdapter, - readonly codeActionKindAdapter: ICodeActionKindAdapter, viewManagerService: IViewManagerService, workspace: IVSCodeWorkspace, workspaceTrust: IWorkspaceTrust, @@ -39,10 +36,6 @@ export class OssServiceLanguageServer extends ProductService { languages, logger, ); - - // this.registerCodeActionsProvider( - // new OssCodeActionsProvider(this.result, codeActionAdapter, codeActionKindAdapter, languages, analytics), - // ); } subscribeToLsScanMessages(): Subscription { diff --git a/src/snyk/snykOss/providers/ossDetailPanelProvider.ts b/src/snyk/snykOss/providers/ossDetailPanelProvider.ts index c16081cec..75661b088 100644 --- a/src/snyk/snykOss/providers/ossDetailPanelProvider.ts +++ b/src/snyk/snykOss/providers/ossDetailPanelProvider.ts @@ -1,5 +1,4 @@ import * as vscode from 'vscode'; -import { SNYK_OPEN_BROWSER_COMMAND } from '../../common/constants/commands'; import { SNYK_VIEW_SUGGESTION_OSS_LANGUAGE_SERVER } from '../../common/constants/views'; import { ErrorHandler } from '../../common/error/errorHandler'; import { Issue, OssIssueData } from '../../common/languageServer/types'; @@ -17,6 +16,10 @@ export class OssDetailPanelProvider extends WebviewProvider> implements IWebViewProvider> { + protected getHtmlForWebview(_webview: vscode.Webview): string { + throw new Error('Method not implemented.'); + } + // For consistency reasons, the single source of truth for the current suggestion is the // panel state. The following field is only used in private issue: Issue | undefined; @@ -63,16 +66,41 @@ export class OssDetailPanelProvider this.registerListeners(); } - this.panel.webview.html = this.getHtmlForWebview(this.panel.webview); + const images: Record = [ + ['icon-code', 'svg'], + ['dark-critical-severity', 'svg'], + ['dark-high-severity', 'svg'], + ['dark-medium-severity', 'svg'], + ['dark-low-severity', 'svg'], + ['learn-icon', 'svg'], + ].reduce((accumulator: Record, [name, ext]) => { + const uri = this.getWebViewUri('media', 'images', `${name}.${ext}`); + if (!uri) throw new Error('Image missing.'); + accumulator[name] = uri.toString(); + return accumulator; + }, {}); + + const displayMode = 'dark'; + const styleUri = this.getWebViewUri('media', 'views', 'oss', 'suggestion', 'suggestion.css'); + const headerEndValue = ``; + const serverityIconName = `${displayMode}-${issue.severity}-severity`; + const nonce = getNonce(); + + let html = issue.additionalData.details; + html = html.replace('${headerEnd}', headerEndValue); + html = html.replaceAll('${cspSource}', this.panel.webview.cspSource); + html = html.replaceAll('${nonce}', nonce); + html = html.replace('${severityIcon}', images[serverityIconName]); + html = html.replace('${learnIcon}', images['learn-icon']); + html = html.replaceAll(/\$\{\w+\}/g, ''); + this.panel.webview.html = html; this.panel.iconPath = vscode.Uri.joinPath( vscode.Uri.file(this.context.extensionPath), 'media', 'images', - 'snyk-iac.svg', // TODO: USE OSS ICON + 'snyk-oss.svg', ); - await this.panel.webview.postMessage({ type: 'set', args: issue }); - this.issue = issue; } catch (e) { ErrorHandler.handle(e, this.logger, errorMessages.suggestionViewShowFailed); @@ -84,8 +112,6 @@ export class OssDetailPanelProvider this.panel.onDidDispose(() => this.onPanelDispose(), null, this.disposables); this.panel.onDidChangeViewState(() => this.checkVisibility(), undefined, this.disposables); - // Handle messages from the webview - this.panel.webview.onDidReceiveMessage(msg => this.handleMessage(msg), undefined, this.disposables); } disposePanel(): void { @@ -95,108 +121,4 @@ export class OssDetailPanelProvider protected onPanelDispose(): void { super.onPanelDispose(); } - - private async handleMessage(message: any) { - try { - const { type, value } = message; - switch (type) { - case 'openBrowser': { - await vscode.commands.executeCommand(SNYK_OPEN_BROWSER_COMMAND, value); - break; - } - default: { - throw new Error('Unknown message type'); - } - } - } catch (e) { - ErrorHandler.handle(e, this.logger, errorMessages.suggestionViewShowFailed); - } - } - - protected getHtmlForWebview(webview: vscode.Webview): string { - const images: Record = [ - ['dark-critical-severity', 'svg'], - ['dark-high-severity', 'svg'], - ['dark-medium-severity', 'svg'], - ['dark-low-severity', 'svg'], - ].reduce((accumulator: Record, [name, ext]) => { - const uri = this.getWebViewUri('media', 'images', `${name}.${ext}`); - if (!uri) throw new Error('Image missing.'); - accumulator[name] = uri.toString(); - return accumulator; - }, {}); - - const scriptUri = this.getWebViewUri( - 'out', - 'snyk', - 'snykIac', - 'views', - 'suggestion', - 'iacSuggestionWebviewScript.js', - ); - const styleUri = this.getWebViewUri('media', 'views', 'oss', 'suggestion', 'suggestion.css'); // make it common - - const nonce = getNonce(); - - return ` - - - - - - - - - - - -
-
-
- - - - - - - - - -
-
-
-
-
-
-
Description
-
-
-
-
Impact
-
-
-
-
Path
-
- -
-
-
-
-
-

Remediation

-
-
- - - - - `; - } } diff --git a/src/snyk/snykOss/services/vulnerabilityCount/ossVulnerabilityCountServiceLS.ts b/src/snyk/snykOss/services/vulnerabilityCount/ossVulnerabilityCountServiceLS.ts index dfb8652ef..090021f9a 100644 --- a/src/snyk/snykOss/services/vulnerabilityCount/ossVulnerabilityCountServiceLS.ts +++ b/src/snyk/snykOss/services/vulnerabilityCount/ossVulnerabilityCountServiceLS.ts @@ -1,20 +1,16 @@ import { Subscription } from 'rxjs'; import { IAnalytics } from '../../../common/analytics/itly'; import { IConfiguration } from '../../../common/configuration/configuration'; -import { HTML, JAVASCRIPT, PJSON, TYPESCRIPT } from '../../../common/constants/languageConsts'; import { ILog } from '../../../common/logger/interfaces'; import { getSupportedLanguage, isValidModuleName } from '../../../common/parsing'; import { ModuleParserProvider } from '../../../common/services/moduleParserProvider'; import { Language } from '../../../common/types'; -import { ICodeActionKindAdapter } from '../../../common/vscode/codeAction'; import { IVSCodeLanguages } from '../../../common/vscode/languages'; import { Diagnostic, DiagnosticCollection, Disposable, TextDocument } from '../../../common/vscode/types'; import { IVSCodeWindow } from '../../../common/vscode/window'; import { IVSCodeWorkspace } from '../../../common/vscode/workspace'; import { DIAGNOSTICS_OSS_COLLECTION_NAME } from '../../../snykCode/constants/analysis'; -import { VulnerabilityCodeActionProviderLS } from '../../codeActions/vulnerabilityCodeActionProviderLS'; import { EditorDecorator } from '../../editor/editorDecorator'; -import { VulnerabilityCountHoverProvider } from '../../hoverProvider/vulnerabilityCountHoverProvider'; import { messages } from '../../messages/vulnerabilityCount'; import { OssServiceLanguageServer } from '../../ossServiceLanguageServer'; import { VulnerabilityCountEmitter, VulnerabilityCountEvents } from '../../vulnerabilityCountEmitter'; @@ -43,7 +39,6 @@ export class OssVulnerabilityCountServiceLS implements Disposable { private readonly ossService: OssServiceLanguageServer, private readonly logger: ILog, private readonly editorDecorator: EditorDecorator, - private readonly codeActionKindProvider: ICodeActionKindAdapter, private readonly analytics: IAnalytics, private readonly configuration: IConfiguration, ) {} @@ -61,27 +56,11 @@ export class OssVulnerabilityCountServiceLS implements Disposable { this.processFile(ev.document); } }), - - // register hover provider - new VulnerabilityCountHoverProvider(this.languages, this.analytics).register(this.diagnostics), ); // Subscribe to OSS scan finished updates this.ossScanFinishedSubscription = this.ossService.newResultAvailable$.subscribe(() => this.processActiveEditor()); - [JAVASCRIPT, TYPESCRIPT, PJSON, HTML].forEach(language => { - const provider = new VulnerabilityCodeActionProviderLS( - this.vulnerabilityCountProvider, - this.codeActionKindProvider, - this.analytics, - ); - this.disposables.push( - this.languages.registerCodeActionsProvider(language, provider, { - providedCodeActionKinds: provider.codeActionKinds, - }), - ); - }); - this.processActiveEditor(); return true; diff --git a/src/snyk/snykOss/services/vulnerabilityCount/vulnerabilityCountProviderLS.ts b/src/snyk/snykOss/services/vulnerabilityCount/vulnerabilityCountProviderLS.ts index 0f24e8304..01729c876 100644 --- a/src/snyk/snykOss/services/vulnerabilityCount/vulnerabilityCountProviderLS.ts +++ b/src/snyk/snykOss/services/vulnerabilityCount/vulnerabilityCountProviderLS.ts @@ -4,7 +4,7 @@ import { ILanguageClientAdapter } from '../../../common/vscode/languageClient'; import { ITextDocumentAdapter } from '../../../common/vscode/textdocument'; import { InlineValueText, LSPTextDocument } from '../../../common/vscode/types'; import { IUriAdapter } from '../../../common/vscode/uri'; -import { OssFileResult, OssResultBody, OssVulnerability, convertSeverity, isResultCliError } from '../../ossResult'; +import { OssFileResult, OssResultBody, OssVulnerability, convertIssue, isResultCliError } from '../../ossResult'; import { OssServiceLanguageServer } from '../../ossServiceLanguageServer'; import { ImportedModule, ModuleVulnerabilityCount, SeverityCounts } from './importedModule'; @@ -190,29 +190,7 @@ export class ModuleVulnerabilityCountProviderLS { resultCache.set(issue.filePath, res); } - const tempVuln: OssVulnerability = { - id: issue.id, - license: issue.additionalData.license, - identifiers: issue.additionalData.identifiers, - title: issue.title, - description: issue.additionalData.description, - language: issue.additionalData.language, - packageManager: issue.additionalData.packageManager, - packageName: issue.additionalData.packageName, - severity: convertSeverity(issue.severity), - name: issue.additionalData.name, - version: issue.additionalData.version, - exploit: issue.additionalData.exploit, - - CVSSv3: issue.additionalData.CVSSv3, - cvssScore: issue.additionalData.cvssScore, - - fixedIn: issue.additionalData.fixedIn, - from: issue.additionalData.from, - upgradePath: issue.additionalData.upgradePath, - isPatchable: issue.additionalData.isPatchable, - isUpgradable: issue.additionalData.isUpgradable, - }; + const tempVuln = convertIssue(issue); res.vulnerabilities.push(tempVuln); } } diff --git a/src/test/unit/common/commands/commandController.test.ts b/src/test/unit/common/commands/commandController.test.ts index f0b8ef8c6..c77e022d0 100644 --- a/src/test/unit/common/commands/commandController.test.ts +++ b/src/test/unit/common/commands/commandController.test.ts @@ -5,15 +5,15 @@ import { ScanModeService } from '../../../../snyk/base/services/scanModeService' import { IAnalytics } from '../../../../snyk/common/analytics/itly'; import { CommandController } from '../../../../snyk/common/commands/commandController'; import { COMMAND_DEBOUNCE_INTERVAL } from '../../../../snyk/common/constants/general'; +import { CodeIssueData, IacIssueData } from '../../../../snyk/common/languageServer/types'; import { IOpenerService } from '../../../../snyk/common/services/openerService'; +import { IProductService } from '../../../../snyk/common/services/productService'; import { IVSCodeCommands } from '../../../../snyk/common/vscode/commands'; import { IVSCodeWorkspace } from '../../../../snyk/common/vscode/workspace'; -import { OssService } from '../../../../snyk/snykOss/services/ossService'; +import { OssServiceLanguageServer } from '../../../../snyk/snykOss/ossServiceLanguageServer'; import { LanguageServerMock } from '../../mocks/languageServer.mock'; import { LoggerMock } from '../../mocks/logger.mock'; import { windowMock } from '../../mocks/window.mock'; -import { IProductService } from '../../../../snyk/common/services/productService'; -import { CodeIssueData, IacIssueData } from '../../../../snyk/common/languageServer/types'; suite('CommandController', () => { const sleep = util.promisify(setTimeout); @@ -26,7 +26,7 @@ suite('CommandController', () => { {} as IAuthenticationService, {} as IProductService, {} as IProductService, - {} as OssService, + {} as OssServiceLanguageServer, {} as ScanModeService, {} as IVSCodeWorkspace, {} as IVSCodeCommands, diff --git a/src/test/unit/snykOss/ossServiceLanguageServer.test.ts b/src/test/unit/snykOss/ossServiceLanguageServer.test.ts index 5634f242a..b1e997c6d 100644 --- a/src/test/unit/snykOss/ossServiceLanguageServer.test.ts +++ b/src/test/unit/snykOss/ossServiceLanguageServer.test.ts @@ -33,10 +33,6 @@ suite('OSS Service', () => { {} as ExtensionContext, {} as IConfiguration, {} as OssDetailPanelProvider, - {} as ICodeActionAdapter, - { - getQuickFix: sinon.fake(), - } as ICodeActionKindAdapter, viewManagerService, { getWorkspaceFolders: () => [''], diff --git a/src/test/unit/snykOss/services/vulnerabilityCount/ossVulnerabilityCountService.test.ts b/src/test/unit/snykOss/services/vulnerabilityCount/ossVulnerabilityCountService.test.ts index 5a444dceb..b5d547667 100644 --- a/src/test/unit/snykOss/services/vulnerabilityCount/ossVulnerabilityCountService.test.ts +++ b/src/test/unit/snykOss/services/vulnerabilityCount/ossVulnerabilityCountService.test.ts @@ -3,7 +3,6 @@ import { EMPTY } from 'rxjs'; import sinon from 'sinon'; import { IAnalytics } from '../../../../../snyk/common/analytics/itly'; import { IConfiguration } from '../../../../../snyk/common/configuration/configuration'; -import { ICodeActionKindAdapter } from '../../../../../snyk/common/vscode/codeAction'; import { ILanguageClientAdapter } from '../../../../../snyk/common/vscode/languageClient'; import { IVSCodeLanguages } from '../../../../../snyk/common/vscode/languages'; import { ITextDocumentAdapter } from '../../../../../snyk/common/vscode/textdocument'; @@ -50,9 +49,6 @@ suite('OSS VulnerabilityCountService', () => { ); const editorDecorator = new EditorDecorator(window, languages, {} as IThemeColorAdapter); - const codeActionProvider = { - getQuickFix: sinon.fake(), - } as ICodeActionKindAdapter; const analytics = {} as IAnalytics; const configuration = {} as IConfiguration; @@ -64,7 +60,6 @@ suite('OSS VulnerabilityCountService', () => { ossService, logger, editorDecorator, - codeActionProvider, analytics, configuration, );