Skip to content

Commit

Permalink
Merge pull request #490 from snyk/refactor/snyk-api-url
Browse files Browse the repository at this point in the history
refactor: default SNYK_API to  api.snyk.io/v1
  • Loading branch information
Noa-Savransky authored Sep 24, 2024
2 parents b31ad0a + af14395 commit 62c1470
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/import.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ If you have any tests ot fixtures that should be ignored, please set the `exclus
- `SNYK_TOKEN` - your [Snyk api token](https://app.snyk.io/account)
- `SNYK_LOG_PATH` - the path to folder where all logs should be saved,it is recommended creating a dedicated logs folder per import you have running. (Note: all logs will append)
- `CONCURRENT_IMPORTS` (optional) defaults to 15 repos at a time, which is the recommended amount to import at once as a max. Just 1 repo may have many projects inside which can trigger a many files at once to be requested from the user's SCM instance and some may have rate limiting in place. This script aims to help reduce the risk of hitting a rate limit.
- `SNYK_API` (optional) defaults to `https://snyk.io/api/v1`
- `SNYK_API` (optional) defaults to `https://api.snyk.io/v1`

## 3. Download & run

Expand Down
2 changes: 1 addition & 1 deletion docs/sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ The command will produce detailed logs for projects that were `updated` and thos

- `SNYK_TOKEN` - your [Snyk api token](https://app.snyk.io/account)
- `SNYK_LOG_PATH` - the path to folder where all logs should be saved,it is recommended creating a dedicated logs folder per import you have running. (Note: all logs will append)
- `SNYK_API` (optional) defaults to `https://snyk.io/api/v1`
- `SNYK_API` (optional) defaults to `https://api.snyk.io/v1`
- `GITHUB_TOKEN` - SCM token that has read level or similar permissions to see information about repos like default branch & can list files in a repo

## 2. Download & run
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"bunyan": "1.8.15",
"debug": "4.3.4",
"lodash": "4.17.21",
"micromatch": "4.0.6",
"micromatch": "4.0.8",
"needle": "2.9.1",
"p-map": "4.0.0",
"parse-link-header": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/get-snyk-host.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function getSnykHost(): string {
return process.env.SNYK_API || 'https://snyk.io/api/v1';
return process.env.SNYK_API || 'https://api.snyk.io/v1';
}
2 changes: 1 addition & 1 deletion test/lib/fixtures/non-empty.logx
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{"name":"snyk:import-projects-script","hostname":"MacBook-Pro-2.local","pid":46657,"level":30,"target":{"name":"composer-with-vulns","owner":"api-import-circle-test","branch":"master"},"locationUrl":"https://dev.snyk.io/api/v1/org/ORG_ID/integrations/INTEGRATION_ID/import/IMPORT_ID","orgId":"ORG_ID","integrationId":"INTEGRATION_ID","targetId":"ORG_ID:INTEGRATION_ID:composer-with-vulns:api-import-circle-test:master","msg":"Target requested for import","time":"2020-10-26T14:53:20.234Z","v":0}
{"name":"snyk:import-projects-script","hostname":"MacBook-Pro-2.local","pid":46657,"level":30,"target":{"name":"composer-with-vulns","owner":"api-import-circle-test","branch":"master"},"locationUrl":"https://api.dev.snyk.io/v1/org/ORG_ID/integrations/INTEGRATION_ID/import/IMPORT_ID","orgId":"ORG_ID","integrationId":"INTEGRATION_ID","targetId":"ORG_ID:INTEGRATION_ID:composer-with-vulns:api-import-circle-test:master","msg":"Target requested for import","time":"2020-10-26T14:53:20.234Z","v":0}
{"name":"snyk:import-projects-script","hostname":"MacBook-Pro-2.local","pid":46657,"level":30,"target":{"name":"composer-with-vulns","owner":"api-import-circle-test","branch":"master"},"locationUrl":null,"orgId":"ORG_ID","integrationId":"INTEGRATION_ID","targetId":"ORG_ID:INTEGRATION_ID:composer-with-vulns:api-import-circle-test:master","msg":"Target exists in Snyk","time":"2020-10-26T14:53:20.234Z","v":0}
2 changes: 1 addition & 1 deletion test/scripts/__mocks__/snyk-request-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class requestsManager {
statusCode: 201,
headers: {
location:
'https://app.snyk.io/api/v1/org/ORG-ID/integrations/INTEGRATION-ID/import/IMPORT-ID',
'https://api.snyk.io/v1/org/ORG-ID/integrations/INTEGRATION-ID/import/IMPORT-ID',
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion test/scripts/polling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Logs failed polls', () => {
await new Promise((r) => setTimeout(r, 300));
const failedLog = fs.readFileSync(failedPollsLogName, 'utf8');
expect(failedLog).toMatch(
`"level":50,"orgId":"ORG-ID","locationUrl":"https://app.snyk.io/api/v1/org/ORG-ID/integrations/INTEGRATION-ID/import/IMPORT-ID","errorMessage":{"statusCode":500,"error":{"message":"Error calling Snyk api"}},"msg":"Failed to poll url"`,
`"level":50,"orgId":"ORG-ID","locationUrl":"https://api.snyk.io/v1/org/ORG-ID/integrations/INTEGRATION-ID/import/IMPORT-ID","errorMessage":{"statusCode":500,"error":{"message":"Error calling Snyk api"}},"msg":"Failed to poll url"`,
);
}, 240000);
});
2 changes: 1 addition & 1 deletion test/system/orgs:data/gitlab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('General `snyk-api-import orgs:data <...>`', () => {
expect(stderr).toEqual('');
expect(err).toBeNull();
expect(stdout).toMatch(
'Found 6 group(s). Written the data to file: group-hello-gitlab-orgs.json',
'Found 7 group(s). Written the data to file: group-hello-gitlab-orgs.json',
);
deleteFiles([
path.resolve(__dirname, `group-${groupId}-gitlab-orgs.json`),
Expand Down

0 comments on commit 62c1470

Please sign in to comment.