Skip to content

Commit

Permalink
chore: remove dependency to old OSSService
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterSchafer committed Nov 3, 2023
1 parent cc73834 commit 60f5d06
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
27 changes: 24 additions & 3 deletions src/snyk/snykOss/codeActions/vulnerabilityCodeActionProviderLS.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
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';
Expand All @@ -16,9 +17,9 @@ import {
} from '../../common/vscode/types';
import { DIAGNOSTICS_OSS_COLLECTION_NAME } from '../../snykCode/constants/analysis';
import { messages } from '../messages/vulnerabilityCount';
import { isResultCliError } from '../ossResult';
import { OssService } from '../services/ossService';
import { OssVulnerability, isResultCliError } from '../ossResult';
import { ModuleVulnerabilityCountProviderLS } from '../services/vulnerabilityCount/vulnerabilityCountProviderLS';
import { OssIssueCommandArg } from '../views/ossVulnerabilityTreeProvider';

export class VulnerabilityCodeActionProviderLS implements CodeActionProvider {
public codeActionKinds: ReadonlyArray<CodeActionKind> = [this.codeActionKindProvider.getQuickFix()];
Expand Down Expand Up @@ -64,7 +65,7 @@ export class VulnerabilityCodeActionProviderLS implements CodeActionProvider {
arguments: [
{
issueType: OpenCommandIssueType.OssVulnerability,
issue: await OssService.getOssIssueCommandArg(vulnerability, fileResult.vulnerabilities),
issue: await this.getOssIssueCommandArg(vulnerability, fileResult.vulnerabilities),
} as OpenIssueCommandArg,
],
};
Expand All @@ -77,4 +78,24 @@ export class VulnerabilityCodeActionProviderLS implements CodeActionProvider {
return [command];
}
}

getOssIssueCommandArg(
vulnerability: OssVulnerability,
allVulnerabilities: OssVulnerability[],
): Promise<OssIssueCommandArg> {
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,
});
});
});
}
}
7 changes: 0 additions & 7 deletions src/snyk/snykOss/services/ossService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,6 @@ export class OssService extends CliService<OssResult> {
getOssIssueCommandArg(
vulnerability: OssVulnerability,
allVulnerabilities: OssVulnerability[],
): Promise<OssIssueCommandArg> {
return OssService.getOssIssueCommandArg(vulnerability, allVulnerabilities);
}

static getOssIssueCommandArg(
vulnerability: OssVulnerability,
allVulnerabilities: OssVulnerability[],
): Promise<OssIssueCommandArg> {
return new Promise((resolve, reject) => {
const matchingIdVulnerabilities = allVulnerabilities.filter(v => v.id === vulnerability.id);
Expand Down

0 comments on commit 60f5d06

Please sign in to comment.