Skip to content

Commit b7d768c

Browse files
feat: use gw routing for code (#4857)
* feat: use gw routing for code * fix: update codeowners * fix: formatting * fix: update code-client * fix: add orgId to connection options * fix: unit tests for snyk-code --------- Co-authored-by: jozsef-armin-hamos <[email protected]>
1 parent ee57d08 commit b7d768c

File tree

6 files changed

+19
-10
lines changed

6 files changed

+19
-10
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ test/jest/acceptance/iac/ @snyk/cloud-dev-ex
5555
test/jest/acceptance/iac/describe.spec.ts @snyk/cloud-dev-ex
5656
test/jest/acceptance/iac/capture.spec.ts @snyk/cloud-dev-ex
5757
test/jest/acceptance/snyk-apps @snyk/moose
58-
src/lib/code-config.ts @snyk/nebula
58+
src/lib/code-config.ts @snyk/pulsar
5959
src/lib/errors/describe-required-argument-error.ts @snyk/cloud-dev-ex
6060
src/lib/errors/describe-exclusive-argument-error.ts @snyk/cloud-dev-ex
6161
src/lib/errors/no-supported-sast-files-found.ts @snyk/zenith

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"@sentry/node": "^7.34.0",
6464
"@snyk/cli-interface": "2.12.0",
6565
"@snyk/cloud-config-parser": "^1.14.5",
66-
"@snyk/code-client": "^4.19.1",
66+
"@snyk/code-client": "^4.22.3",
6767
"@snyk/dep-graph": "^2.7.4",
6868
"@snyk/docker-registry-v2-client": "^2.10.0",
6969
"@snyk/fix": "file:packages/snyk-fix",

src/lib/code-config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ import config from './config';
33
export function getCodeClientProxyUrl(): string {
44
const url = new URL(config.API);
55
const domain = url.origin;
6+
const routeToAPI = isFedramp(domain);
67
return (
78
config.CODE_CLIENT_PROXY_URL ||
8-
domain.replace(/\/\/(ap[pi]\.)?/, '//deeproxy.')
9+
domain.replace(/\/\/(ap[pi]\.)?/, routeToAPI ? '//api.' : '//deeproxy.')
910
);
1011
}
12+
13+
function isFedramp(domain: string): boolean {
14+
return domain.includes('snykgov.io');
15+
}

src/lib/plugins/sast/analysis.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type GetCodeAnalysisArgs = {
3939
};
4040
connectionOptions: {
4141
org?: string;
42+
orgId?: string;
4243
source: string;
4344
baseURL: string;
4445
requestId: string;
@@ -102,6 +103,7 @@ export async function getCodeTestResults(
102103
source: 'snyk-cli',
103104
requestId,
104105
org: sastSettings.org,
106+
orgId: config.orgId,
105107
},
106108
analysisOptions: {
107109
severity: options.severityThreshold

test/jest/unit/snyk-code/snyk-code-test.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,7 @@ describe('Test snyk code', () => {
747747
sessionToken,
748748
source,
749749
requestId: 'test-id',
750+
orgId: '',
750751
},
751752
analysisOptions: {
752753
severity,
@@ -850,6 +851,7 @@ describe('Test snyk code', () => {
850851
sessionToken,
851852
source,
852853
requestId: 'test-id',
854+
orgId: '',
853855
},
854856
analysisOptions: {
855857
severity,

0 commit comments

Comments
 (0)