Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Snyk reported issues #197

Merged
merged 3 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 77 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,13 @@
"@sentry/tracing": "^6.16.1",
"@snyk/code-client": "^4.9.1",
"analytics-node": "^4.0.1",
"axios": "^0.21.1",
"axios": "^0.26.1",
"glob": "^7.2.0",
"htmlparser2": "^7.2.0",
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.0",
"lodash": "^4.17.21",
"marked": "^3.0.2",
"marked": "^4.0.13",
"open": "^7.4.2",
"rxjs": "^7.3.0",
"string-argv": "^0.3.1",
Expand Down
4 changes: 2 additions & 2 deletions src/snyk/common/error/errorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ export class ErrorHandler {
): Promise<void> {
await contextService.setContext(SNYK_CONTEXT.ERROR, SNYK_ERROR_CODES.BLOCKING);
loadingBadge.setLoadingBadge(true);
this.handle(error, logger);
ErrorHandler.handle(error, logger);
}

/**
* Should be used to log locally and report error event remotely.
*/
static handle(error: Error | unknown, logger: ILog, message?: string, tags?: Tags): void {
const errorStr = this.stringifyError(error);
const errorStr = ErrorHandler.stringifyError(error);
logger.error(message ? `${message}. ${errorStr}` : errorStr);
ErrorReporter.capture(error, tags);
}
Expand Down
1 change: 1 addition & 0 deletions src/snyk/snykCode/analyzer/analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class SnykCodeAnalyzer implements ISnykCodeAnalyzer {
static isIssueVisible(configuration: IConfiguration, isSecurityType: boolean, severity: AnalysisSeverity): boolean {
if (isSecurityType && !configuration.getFeaturesConfiguration()?.codeSecurityEnabled) {
return false;
// deepcode ignore DuplicateIfBody: readability
} else if (!isSecurityType && !configuration.getFeaturesConfiguration()?.codeQualityEnabled) {
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion src/snyk/snykCode/error/snykCodeErrorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export class SnykCodeErrorHandler extends ErrorHandler implements ISnykCodeError
this.logger.error(`Connection error to Snyk Code. Try count: ${this.transientErrors + 1}.`);
if (this.transientErrors > MAX_CONNECTION_RETRIES) {
this._connectionRetryLimitExhausted = true;
return this.generalErrorHandler(error, options, callback);
this.generalErrorHandler(error, options, callback);
return;
}

this.transientErrors += 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
document.getElementById('cancel')?.addEventListener('click', close);
document.getElementById('send')?.addEventListener('click', send);

// deepcode ignore InsufficientValidation: Content Security Policy applied in provider
window.addEventListener('message', event => {
const { type, args } = event.data;
switch (type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
document.getElementById('ignore-file-issue')!.addEventListener('click', ignoreIssue.bind(false));
document.getElementById('report-fp')?.addEventListener('click', openFalsePositiveCode);

// deepcode ignore InsufficientValidation: Content Security Policy applied in provider
window.addEventListener('message', event => {
const { type, args } = event.data;
switch (type) {
Expand Down
4 changes: 2 additions & 2 deletions src/snyk/snykOss/services/ossService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import marked from 'marked';
import * as marked from 'marked';
import { Subject } from 'rxjs';
import { IExtension } from '../../base/modules/interfaces';
import { CliDownloadService } from '../../cli/services/cliDownloadService';
Expand Down Expand Up @@ -175,7 +175,7 @@ export class OssService extends CliService<OssResult> {
): Promise<OssIssueCommandArg> {
return new Promise((resolve, reject) => {
const matchingIdVulnerabilities = allVulnerabilities.filter(v => v.id === vulnerability.id);
marked(vulnerability.description, (err, overviewHtml) => {
marked.parse(vulnerability.description, (err, overviewHtml) => {
if (err) {
return reject(err);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class OssVulnerabilityCountService implements Disposable {
// Subscribe to OSS scan finished updates
this.ossScanFinishedSubscription = this.ossService.scanFinished$.subscribe(() => this.processActiveEditor());

[JAVASCRIPT, TYPESCRIPT, PJSON, HTML].map(language => {
[JAVASCRIPT, TYPESCRIPT, PJSON, HTML].forEach(language => {
const provider = new VulnerabilityCodeActionProvider(
this.ossService,
this.vulnerabilityCountProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
}`;
}

// deepcode ignore InsufficientValidation: Content Security Policy applied in provider
window.addEventListener('message', event => {
const { type, args } = event.data;
switch (type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ suite('HTML Parser', () => {
parser = new HtmlParser();
});

testScenarios.map(scenario => {
testScenarios.forEach(scenario => {
test(`Extracts ${scenario.name} package and version`, () => {
const packages = parser.getModules('foo', `<script src="${scenario.url}"></script>`);

Expand Down