Skip to content

Commit

Permalink
feat: remove false positives (#378)
Browse files Browse the repository at this point in the history
False positives is just an empty feature flag now with analytics. It’s not used anywhere and confuses customers.
  • Loading branch information
Avishagp authored Sep 28, 2023
1 parent 5f8216c commit aad80bb
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 257 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Snyk Security - Code and Open Source Dependencies Changelog

## [1.23.2]

### Fixed

- Removed false positives feature flag

## [1.23.1]

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions ampli.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"SourceId": "4be0392d-f232-4850-943e-edab84cc8ccd",
"Path": "./src/ampli",
"Branch": "main",
"Version": "249.0.0",
"Version": "322.0.0",
"OrgId": "114775",
"Runtime": "node.js:typescript-v3",
"VersionId": "f20814a9-b2ff-43b0-88ef-0581da87dfbd",
"VersionId": "d8260d9e-1d43-4871-99ca-1e78645b558f",
"Platform": "Node.js",
"Language": "TypeScript",
"SDK": "@itly/sdk@^2.0"
Expand Down
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,6 @@
"description": "Preview features that are currently in development. Setting keys will be removed when features become stable.",
"propertyNames": true,
"properties": {
"reportFalsePositives": {
"type": "boolean",
"title": "Enable \"report false positives\"",
"description": "Allows reporting false positives for Snyk Code suggestions.",
"default": false
},
"advisor": {
"type": "boolean",
"title": "Enable \"Snyk Advisor\"",
Expand Down
239 changes: 47 additions & 192 deletions src/ampli/index.ts

Large diffs are not rendered by default.

24 changes: 0 additions & 24 deletions src/snyk/common/analytics/itly.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import SegmentPlugin from '@itly/plugin-segment-node';
import itly, {
AnalysisIsReadyProperties,
FalsePositiveIsSubmittedProperties,
IssueHoverIsDisplayedProperties,
IssueInTreeIsClickedProperties,
ScanModeIsSelectedProperties,
Expand Down Expand Up @@ -50,8 +49,6 @@ export interface IAnalytics {
logQuickFixIsDisplayed(properties: QuickFixIsDisplayedProperties): void;
logIssueHoverIsDisplayed(properties: IssueHoverIsDisplayedProperties): void;
logScanModeIsSelected(properties: Omit<ScanModeIsSelectedProperties, 'eventSource' | 'ide'>): void;
logFalsePositiveIsDisplayed(): void;
logFalsePositiveIsSubmitted(properties: Omit<FalsePositiveIsSubmittedProperties, 'eventSource' | 'ide'>): void;
}

/**
Expand Down Expand Up @@ -235,27 +232,6 @@ export class Iteratively implements IAnalytics {
});
}

public logFalsePositiveIsDisplayed(): void {
this.enqueueEvent(() => {
itly.falsePositiveIsDisplayed(this.getAuthenticatedUserId(), {
ide: this.ide,
eventSource: 'IDE',
});
});
}

public logFalsePositiveIsSubmitted(
properties: Omit<FalsePositiveIsSubmittedProperties, 'eventSource' | 'ide'>,
): void {
this.enqueueEvent(() => {
itly.falsePositiveIsSubmitted(this.getAuthenticatedUserId(), {
...properties,
ide: this.ide,
eventSource: 'IDE',
});
});
}

private enqueueEvent(eventFunction: () => void, mustBeAuthenticated = true): void {
if (!this.canReportEvents()) {
return;
Expand Down
4 changes: 0 additions & 4 deletions src/snyk/common/commands/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ export type OpenIssueCommandArg = {
issueType: OpenCommandIssueType;
};

export type ReportFalsePositiveCommandArg = {
suggestion: Readonly<completeFileSuggestionType>;
};

export const isCodeIssue = (
_issue: completeFileSuggestionType | Issue<CodeIssueData> | OssIssueCommandArg,
issueType: OpenCommandIssueType,
Expand Down
2 changes: 0 additions & 2 deletions src/snyk/common/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export interface SeverityFilter {
}

export type PreviewFeatures = {
reportFalsePositives: boolean | undefined;
advisor: boolean | undefined;
};

Expand Down Expand Up @@ -434,7 +433,6 @@ export class Configuration implements IConfiguration {

getPreviewFeatures(): PreviewFeatures {
const defaultSetting: PreviewFeatures = {
reportFalsePositives: false,
advisor: false,
};

Expand Down
1 change: 0 additions & 1 deletion src/snyk/common/constants/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const SNYK_VIEW_ANALYSIS_CODE_QUALITY = 'snyk.views.analysis.code.quality
export const SNYK_VIEW_ANALYSIS_OSS = 'snyk.views.analysis.oss';
export const SNYK_VIEW_SUPPORT = 'snyk.views.support';
export const SNYK_VIEW_SUGGESTION_CODE = 'snyk.views.suggestion.code';
export const SNYK_VIEW_FALSE_POSITIVE_CODE = 'snyk.views.suggestion.code.falsePositive';
export const SNYK_VIEW_SUGGESTION_OSS = 'snyk.views.suggestion.oss';
export const SNYK_VIEW_SUGGESTION_IAC = 'snyk.views.suggestion.iac';
export const SNYK_VIEW_ANALYSIS_IAC = 'snyk.views.analysis.configuration';
Expand Down
9 changes: 0 additions & 9 deletions src/snyk/snykCode/codeSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { IOpenerService } from '../common/services/openerService';
import { IVSCodeCommands } from '../common/vscode/commands';

export interface ICodeSettings {
reportFalsePositivesEnabled: boolean;

updateIsCodeEnabled(): Promise<boolean>;

enable(): Promise<boolean>;
Expand All @@ -20,16 +18,9 @@ export type SastSettings = {
localCodeEngine: {
enabled: boolean;
};
reportFalsePositivesEnabled: boolean;
};

export class CodeSettings implements ICodeSettings {
private _reportFalsePositivesEnabled: boolean;

get reportFalsePositivesEnabled(): boolean {
return this._reportFalsePositivesEnabled;
}

constructor(
private readonly contextService: IContextService,
private readonly config: IConfiguration,
Expand Down
2 changes: 0 additions & 2 deletions src/snyk/snykCode/messages/error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export const messages = {
suggestionViewShowFailed: 'Failed to show Snyk Code suggestion view',
reportFalsePositiveViewShowFailed: 'Failed to show Snyk Code report false positive view',
reportFalsePositiveFailed: 'Failed to report false positive.',

suggestionViewMessageHandlingFailed: (msg: string): string =>
`Failed to handle message from Snyk Code suggestion view ${msg}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,6 @@
},
});
}
function openFalsePositiveCode() {
sendMessage({
type: 'openFalsePositive',
args: {
suggestion: suggestion,
},
});
}
function getSuggestionPosition(suggestionParam: Suggestion, position?: { file: string; rows: any; cols: any }) {
return {
uri: position?.file ?? suggestionParam.uri,
Expand Down Expand Up @@ -317,7 +309,6 @@
document.getElementById('ignore-file-issue')!.addEventListener('click', () => {
ignoreIssue(false);
});
document.getElementById('report-fp')?.addEventListener('click', openFalsePositiveCode);

// deepcode ignore InsufficientValidation: Content Security Policy applied in provider
window.addEventListener('message', event => {
Expand Down
2 changes: 0 additions & 2 deletions src/test/unit/common/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,12 @@ suite('Configuration', () => {
const configuration = new Configuration({}, workspace);

deepStrictEqual(configuration.getPreviewFeatures(), {
reportFalsePositives: false,
advisor: false,
} as PreviewFeatures);
});

test('Preview features: some features enabled', () => {
const previewFeatures = {
reportFalsePositives: true,
advisor: false,
} as PreviewFeatures;
const workspace = stubWorkspaceConfiguration(FEATURES_PREVIEW_SETTING, previewFeatures);
Expand Down
1 change: 0 additions & 1 deletion src/test/unit/common/languageServer/languageServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ suite('Language Server', () => {
getPreviewFeatures() {
return {
advisor: false,
reportFalsePositives: false,
};
},
getFeaturesConfiguration() {
Expand Down
1 change: 0 additions & 1 deletion src/test/unit/common/languageServer/middleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ suite('Language Server: Middleware', () => {
getPreviewFeatures: () => {
return {
advisor: false,
reportFalsePositives: false,
};
},
getFeaturesConfiguration() {
Expand Down
2 changes: 0 additions & 2 deletions src/test/unit/snykCode/codeSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ suite('Snyk Code Settings', () => {
localCodeEngine: {
enabled: false,
},
reportFalsePositivesEnabled: true,
});

const codeEnabled = await settings.updateIsCodeEnabled();
Expand All @@ -53,7 +52,6 @@ suite('Snyk Code Settings', () => {
localCodeEngine: {
enabled: false,
},
reportFalsePositivesEnabled: true,
});

const codeEnabled = await settings.updateIsCodeEnabled();
Expand Down

0 comments on commit aad80bb

Please sign in to comment.