Skip to content

Commit

Permalink
feat: base64 default for sast analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
soniqua committed Nov 17, 2022
1 parent e01c853 commit 369fe11
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 54 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@open-policy-agent/opa-wasm": "^1.6.0",
"@snyk/cli-interface": "2.11.0",
"@snyk/cloud-config-parser": "^1.14.3",
"@snyk/code-client": "^4.13.0",
"@snyk/code-client": "^4.14.0",
"@snyk/dep-graph": "^1.27.1",
"@snyk/docker-registry-v2-client": "^2.7.3",
"@snyk/fix": "file:packages/snyk-fix",
Expand Down
12 changes: 1 addition & 11 deletions src/lib/code-config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import config from './config';
import { config as userConfig } from './user-config';

export function getCodeClientProxyUrl() {
export function getCodeClientProxyUrl(): string {
const url = new URL(config.API);
const domain = url.origin;
return (
config.CODE_CLIENT_PROXY_URL ||
domain.replace(/\/\/(ap[pi]\.)?/, '//deeproxy.')
);
}

export function getBase64Encoding(
enabled = userConfig.get('use-base64-encoding'),
): boolean {
if (enabled) {
return enabled.toLowerCase() === 'true';
}
return false;
}
6 changes: 1 addition & 5 deletions src/lib/plugins/sast/analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { ReportingDescriptor, Result } from 'sarif';
import { SEVERITY } from '../../snyk-test/legacy';
import { api } from '../../api-token';
import config from '../../config';
import { getBase64Encoding } from '../../code-config';
import { spinner } from '../../spinner';
import { Options } from '../../types';
import { SastSettings, Log } from './types';
Expand Down Expand Up @@ -58,9 +57,6 @@ async function getCodeAnalysis(
? sastSettings.localCodeEngine.url
: getCodeClientProxyUrl();

const base64Encoding = getBase64Encoding();
debug(`base64 encoding enabled: ${base64Encoding}`);

// TODO(james) This mirrors the implementation in request.ts and we need to use this for deeproxy calls
// This ensures we support lowercase http(s)_proxy values as well
// The weird IF around it ensures we don't create an envvar with
Expand All @@ -86,7 +82,7 @@ async function getCodeAnalysis(
? severityToAnalysisSeverity(options.severityThreshold)
: AnalysisSeverity.info;
const result = await analyzeFolders({
connection: { baseURL, sessionToken, source, requestId, base64Encoding },
connection: { baseURL, sessionToken, source, requestId },
analysisOptions: { severity },
fileOptions: { paths: [root] },
analysisContext: {
Expand Down
13 changes: 0 additions & 13 deletions test/jest/acceptance/snyk-code-config/snyk-code-config.spec.ts

This file was deleted.

15 changes: 0 additions & 15 deletions test/jest/unit/snyk-code/snyk-code-config.spec.ts

This file was deleted.

2 changes: 0 additions & 2 deletions test/jest/unit/snyk-code/snyk-code-test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,6 @@ describe('Test snyk code', () => {
sessionToken,
source,
requestId: 'test-id',
base64Encoding: false,
},
analysisOptions: {
severity,
Expand Down Expand Up @@ -781,7 +780,6 @@ describe('Test snyk code', () => {
sessionToken,
source,
requestId: 'test-id',
base64Encoding: false,
},
analysisOptions: {
severity,
Expand Down

0 comments on commit 369fe11

Please sign in to comment.