Skip to content

Commit

Permalink
feat: use gw routing for code (#4857)
Browse files Browse the repository at this point in the history
* 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 <jozsefarmin.hamos@snyk.io>
  • Loading branch information
Noa-Savransky and jozsef-armin-hamos committed Oct 16, 2023
1 parent ee57d08 commit b7d768c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test/jest/acceptance/iac/ @snyk/cloud-dev-ex
test/jest/acceptance/iac/describe.spec.ts @snyk/cloud-dev-ex
test/jest/acceptance/iac/capture.spec.ts @snyk/cloud-dev-ex
test/jest/acceptance/snyk-apps @snyk/moose
src/lib/code-config.ts @snyk/nebula
src/lib/code-config.ts @snyk/pulsar
src/lib/errors/describe-required-argument-error.ts @snyk/cloud-dev-ex
src/lib/errors/describe-exclusive-argument-error.ts @snyk/cloud-dev-ex
src/lib/errors/no-supported-sast-files-found.ts @snyk/zenith
Expand Down
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 @@ -63,7 +63,7 @@
"@sentry/node": "^7.34.0",
"@snyk/cli-interface": "2.12.0",
"@snyk/cloud-config-parser": "^1.14.5",
"@snyk/code-client": "^4.19.1",
"@snyk/code-client": "^4.22.3",
"@snyk/dep-graph": "^2.7.4",
"@snyk/docker-registry-v2-client": "^2.10.0",
"@snyk/fix": "file:packages/snyk-fix",
Expand Down
7 changes: 6 additions & 1 deletion src/lib/code-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ import config from './config';
export function getCodeClientProxyUrl(): string {
const url = new URL(config.API);
const domain = url.origin;
const routeToAPI = isFedramp(domain);
return (
config.CODE_CLIENT_PROXY_URL ||
domain.replace(/\/\/(ap[pi]\.)?/, '//deeproxy.')
domain.replace(/\/\/(ap[pi]\.)?/, routeToAPI ? '//api.' : '//deeproxy.')
);
}

function isFedramp(domain: string): boolean {
return domain.includes('snykgov.io');
}
2 changes: 2 additions & 0 deletions src/lib/plugins/sast/analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type GetCodeAnalysisArgs = {
};
connectionOptions: {
org?: string;
orgId?: string;
source: string;
baseURL: string;
requestId: string;
Expand Down Expand Up @@ -102,6 +103,7 @@ export async function getCodeTestResults(
source: 'snyk-cli',
requestId,
org: sastSettings.org,
orgId: config.orgId,
},
analysisOptions: {
severity: options.severityThreshold
Expand Down
2 changes: 2 additions & 0 deletions test/jest/unit/snyk-code/snyk-code-test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ describe('Test snyk code', () => {
sessionToken,
source,
requestId: 'test-id',
orgId: '',
},
analysisOptions: {
severity,
Expand Down Expand Up @@ -850,6 +851,7 @@ describe('Test snyk code', () => {
sessionToken,
source,
requestId: 'test-id',
orgId: '',
},
analysisOptions: {
severity,
Expand Down

0 comments on commit b7d768c

Please sign in to comment.