Skip to content

Commit

Permalink
fix: only display ai fix treenode if any issues, use "issue(s)" [IDE-…
Browse files Browse the repository at this point in the history
…547] (#505)

* fix: only display ai fix treenode if any issues, use "issue(s)" everywhere

* docs: updated CHANGELOG.md

* fix: tests
  • Loading branch information
bastiandoetsch authored Jul 31, 2024
1 parent f6a758e commit a73d3ee
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 34 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Snyk Security Changelog

## [2.16.1]
## [2.17.0]
- updated the language server protocol version to 13 to support delta findings.
- added setting for choosing authentication method
- renamed vulnerabilities to issues
- only display DeepCode AI fix tree node when issues were found

## [2.16.0]
- Reorganize settings page into categorized sections:
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"//": "Changing display name requires change in general.ts",
"displayName": "Snyk Security",
"version": "0.0.0",
"description": "Easily find and fix vulnerabilities in your code, open source dependencies, infrastructure as code configurations with fast and accurate scans.",
"description": "Easily find and fix issues in your code, open source dependencies, infrastructure as code configurations with fast and accurate scans.",
"icon": "media/images/readme/snyk_extension_icon.png",
"publisher": "snyk-security",
"homepage": "https://snyk.io",
Expand Down Expand Up @@ -113,21 +113,21 @@
"order": 1,
"type": "boolean",
"title": "Snyk Open Source security issues",
"description": "Find and fix open source vulnerabilities.",
"description": "Find and fix open source dependency issues.",
"default": true
},
"snyk.features.codeSecurity": {
"order": 2,
"type": "boolean",
"title": "Snyk Code security issues",
"description": "Find and fix vulnerabilities in your application code in real time.",
"description": "Find and fix security issues in your application code in real time.",
"default": true
},
"snyk.features.codeQuality": {
"order": 3,
"type": "boolean",
"title": "Snyk Code quality issues",
"description": "Find and fix code quality issues in your application code in real time.",
"description": "Find and fix quality issues in your application code in real time.",
"default": true
},
"snyk.features.infrastructureAsCode": {
Expand Down Expand Up @@ -200,15 +200,15 @@
"order": 2,
"type": "boolean",
"default": false,
"description": "Run Snyk Open Source Security vulnerability analysis in automatic mode.",
"description": "Run Snyk Open Source Security analysis in automatic mode.",
"scope": "application"
},
"snyk.yesBackgroundOssNotification": {
"order": 3,
"//": "Name starts with y to put it at the end, as configs are sorted alphabetically",
"type": "boolean",
"default": true,
"markdownDescription": "Show scan notification for critical Open Source Security vulnerabilities when Snyk view is hidden",
"markdownDescription": "Show scan notification for critical Open Source Security issues when Snyk view is hidden",
"scope": "application"
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/snyk/common/languageServer/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class LanguageServerSettings {
deviceId: user.anonymousId,
requiredProtocolVersion: `${PROTOCOL_VERSION}`,
folderConfigs: configuration.getFolderConfigs(),
enableSnykOSSQuickFixCodeActions: `${configuration.getOssQuickFixCodeActionsEnabled()}`,
enableSnykOSSQuickFixCodeActions: `${configuration.getPreviewFeatures().ossQuickfixes}`,
};
}
}
2 changes: 1 addition & 1 deletion src/snyk/common/messages/learn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const messages = {
getLessonError: 'Failed to get Snyk Learn lesson',
lessonButtonTitle: 'Learn about this vulnerability',
lessonButtonTitle: 'Learn about this issue',
};
8 changes: 7 additions & 1 deletion src/snyk/common/views/issueTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ export abstract class ProductIssueTreeProvider<T> extends AnalysisTreeNodeProvid
}

abstract shouldShowTree(): boolean;

abstract filterIssues(issues: Issue<T>[]): Issue<T>[];

abstract getRunTestMessage(): string;

abstract getIssueTitle(issue: Issue<T>): string;

abstract getIssueRange(issue?: Issue<T>): Range | undefined;

abstract getOpenIssueCommand(
issue: Issue<T>,
folderPath: string,
Expand Down Expand Up @@ -94,9 +97,12 @@ export abstract class ProductIssueTreeProvider<T> extends AnalysisTreeNodeProvid
new TreeNode({
text: this.getIssueFoundText(totalIssueCount, ignoredIssueCount),
}),
this.getFixableIssuesNode(this.getFixableCount()),
];

if (totalIssueCount > 0) {
topNodes.push(this.getFixableIssuesNode(this.getFixableCount()));
}

const noSeverityFiltersSelectedWarning = this.getNoSeverityFiltersSelectedTreeNode();
if (noSeverityFiltersSelectedWarning !== null) {
topNodes.push(noSeverityFiltersSelectedWarning);
Expand Down
4 changes: 2 additions & 2 deletions src/snyk/snykCode/views/issueTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class IssueTreeProvider extends ProductIssueTreeProvider<CodeIssueData> {

private getAIFixableIssuesText(issuesCount: number): string {
return issuesCount > 0
? `⚡️ ${issuesCount} ${issuesCount === 1 ? 'vulnerability' : 'vulnerabilities'} can be fixed by Snyk DeepCode AI`
: 'There are no vulnerabilities fixable by Snyk DeepCode AI';
? `⚡️ ${issuesCount} ${issuesCount === 1 ? 'issue' : 'issues'} can be fixed by Snyk DeepCode AI`
: 'There are no issues fixable by Snyk DeepCode AI';
}
}
4 changes: 2 additions & 2 deletions src/snyk/snykCode/views/securityIssueTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class CodeSecurityIssueTreeProvider extends IssueTreeProvider {
onDidChangeTreeData = this.viewManagerService.refreshCodeSecurityViewEmitter.event;

protected getIssueDescriptionText(dir: string | undefined, issueCount: number): string | undefined {
return `${dir} - ${issueCount} ${issueCount === 1 ? 'vulnerability' : 'vulnerabilities'}`;
return `${dir} - ${issueCount} ${issueCount === 1 ? 'issue' : 'issues'}`;
}

protected getIssueFoundText(nIssues: number, ignoredIssueCount: number): string {
Expand All @@ -48,7 +48,7 @@ export default class CodeSecurityIssueTreeProvider extends IssueTreeProvider {
if (nIssues === 1) {
text = `${nIssues} issue found by Snyk`;
} else {
text = `✋ ${nIssues} vulnerabilities found by Snyk`;
text = `✋ ${nIssues} issues found by Snyk`;
}

const isIgnoresEnabled = configuration.getFeatureFlag(FEATURE_FLAGS.consistentIgnores);
Expand Down
10 changes: 5 additions & 5 deletions src/snyk/snykOss/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export const messages = {
},
treeView: {
cookingDependencies: 'Scanning...',
runTest: 'Run scan for Open Source security vulnerabilities.',
runTest: 'Run scan for Open Source security issues.',
noVulnerabilitiesFound: ' ✅ Congrats! No issues found!',
singleVulnerabilityFound: 'Snyk found 1 vulnerability',
vulnerability: 'vulnerability',
vulnerabilities: 'vulnerabilities',
multipleVulnerabilitiesFound: (issueCount: number): string => `Snyk found ${issueCount} vulnerabilities`,
issue: 'issue',
issues: 'issues',
singleVulnerabilityFound: 'Snyk found 1 issue',
multipleVulnerabilitiesFound: (issueCount: number): string => `Snyk found ${issueCount} issues`,
},
};
2 changes: 1 addition & 1 deletion src/snyk/snykOss/editor/editorDecorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class EditorDecorator {
module.line - 1,
this.editorLastCharacterIndex,
),
renderOptions: getRenderOptions('Fetching vulnerabilities...', this.themeColorAdapter),
renderOptions: getRenderOptions('Fetching issues...', this.themeColorAdapter),
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/snyk/snykOss/providers/ossDetailPanelProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class OssDetailPanelProvider
} else {
this.panel = vscode.window.createWebviewPanel(
SNYK_VIEW_SUGGESTION_OSS,
'Snyk OSS Vulnerability',
'Snyk OSS issue',
{
viewColumn: vscode.ViewColumn.Two,
preserveFocus: true,
Expand Down
2 changes: 1 addition & 1 deletion src/snyk/snykOss/providers/ossIssueCommandHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function getOssIssueCommandArg(
// TODO: marked.parse does not sanitize the HTML. See: https://marked.js.org/#usage
overviewHtml = marked.parse(vuln.additionalData.description) as string;
} catch (error) {
overviewHtml = '<p>There was a problem rendering the vulnerability overview</p>';
overviewHtml = '<p>There was a problem rendering the issue overview</p>';
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class OssVulnerabilityCountService implements Disposable {
}

emitter.on(VulnerabilityCountEvents.Error, e => {
this.logger.error(`Error counting module vulnerabilities: ${e}`);
this.logger.error(`Error counting module issues: ${e}`);
this.editorDecorator.resetDecorations(fileName);
});

Expand Down
11 changes: 5 additions & 6 deletions src/test/integration/issueTreeProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ suite('Code Issue Tree Provider', () => {
const rootChildren = issueTreeProvider.getRootChildren();
strictEqual(rootChildren.length, 2);
strictEqual(rootChildren[0].label, 'Snyk found 1 issue');
strictEqual(rootChildren[1].label, 'There are no vulnerabilities fixable by Snyk DeepCode AI');
strictEqual(rootChildren[1].label, 'There are no issues fixable by Snyk DeepCode AI');
});

test('getRootChildren returns a root child for no results', () => {
Expand All @@ -98,9 +98,8 @@ suite('Code Issue Tree Provider', () => {

sinon.stub(issueTreeProvider, 'getResultNodes').returns([]);
const rootChildren = issueTreeProvider.getRootChildren();
strictEqual(rootChildren.length, 2);
strictEqual(rootChildren.length, 1);
strictEqual(rootChildren[0].label, '✅ Congrats! No issues found!');
strictEqual(rootChildren[1].label, 'There are no vulnerabilities fixable by Snyk DeepCode AI');
});

test('getRootChildren returns a root child for only open but not visible issues', async () => {
Expand Down Expand Up @@ -141,7 +140,7 @@ suite('Code Issue Tree Provider', () => {
const rootChildren = issueTreeProvider.getRootChildren();
strictEqual(rootChildren.length, 3);
strictEqual(rootChildren[0].label, 'Snyk found 1 issue');
strictEqual(rootChildren[1].label, 'There are no vulnerabilities fixable by Snyk DeepCode AI');
strictEqual(rootChildren[1].label, 'There are no issues fixable by Snyk DeepCode AI');
strictEqual(rootChildren[2].label, 'Adjust your Issue View Options to see open issues.');
await vscode.workspace.getConfiguration().update(ISSUE_VIEW_OPTIONS_SETTING, {
openIssues: true,
Expand Down Expand Up @@ -186,7 +185,7 @@ suite('Code Issue Tree Provider', () => {
const rootChildren = issueTreeProvider.getRootChildren();
strictEqual(rootChildren.length, 3);
strictEqual(rootChildren[0].label, 'Snyk found 1 issue');
strictEqual(rootChildren[1].label, 'There are no vulnerabilities fixable by Snyk DeepCode AI');
strictEqual(rootChildren[1].label, 'There are no issues fixable by Snyk DeepCode AI');
strictEqual(rootChildren[2].label, 'Adjust your Issue View Options to see ignored issues.');
await vscode.workspace.getConfiguration().update(ISSUE_VIEW_OPTIONS_SETTING, {
openIssues: true,
Expand Down Expand Up @@ -231,7 +230,7 @@ suite('Code Issue Tree Provider', () => {
const rootChildren = issueTreeProvider.getRootChildren();
strictEqual(rootChildren.length, 3);
strictEqual(rootChildren[0].label, 'Snyk found 1 issue');
strictEqual(rootChildren[1].label, 'There are no vulnerabilities fixable by Snyk DeepCode AI');
strictEqual(rootChildren[1].label, 'There are no issues fixable by Snyk DeepCode AI');
strictEqual(rootChildren[2].label, 'Adjust your Issue View Options to see all issues.');
await vscode.workspace.getConfiguration().update(ISSUE_VIEW_OPTIONS_SETTING, {
openIssues: true,
Expand Down
5 changes: 1 addition & 4 deletions src/test/unit/common/languageServer/languageServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ suite('Language Server', () => {
isAutomaticDependencyManagementEnabled() {
return true;
},
getOssQuickFixCodeActionsEnabled() {
return false;
},
getFeaturesConfiguration() {
return defaultFeaturesConfigurationStub;
},
Expand Down Expand Up @@ -256,7 +253,7 @@ suite('Language Server', () => {
const initOptions = await languageServer.getInitializationOptions();

strictEqual(initOptions.activateSnykCodeQuality, `true`);
strictEqual(initOptions.activateSnykCodeQuality, `true`);
strictEqual(initOptions.activateSnykCodeSecurity, `true`);
});

['auto', 'manual'].forEach(expectedScanningMode => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ suite('OSS VulnerabilityCountProvider', () => {
});

test('Gets TS/JS imported module vulnerability results correctly', async () => {
const text = 'Vulnerabilities: 2 | Critical: 1, High 1, Medium: 0, Low: 0 | Most Severe: npm:adm-zip:20180415';
const text = 'issues: 2 | Critical: 1, High 1, Medium: 0, Low: 0 | Most Severe: npm:adm-zip:20180415';
sampleInlineValueText = [
{
text,
Expand Down

0 comments on commit a73d3ee

Please sign in to comment.