-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from snyk-tech-services/develop
Releasing changes
- Loading branch information
Showing
2 changed files
with
78 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,14 @@ beforeAll(() => { | |
}); | ||
}); | ||
|
||
const responseWithOneOtherComment = [ | ||
{ | ||
id: 1, | ||
body: '### Anything but a vulnerability summary *******', | ||
url: 'https://api.github.com/repos/124/124/issues/124/comments/1', | ||
}, | ||
]; | ||
|
||
const responseAfterComment = [ | ||
{ | ||
id: 1, | ||
|
@@ -37,6 +45,7 @@ const responseAfterComment = [ | |
]; | ||
const responseBeforeComment: unknown[] = []; | ||
let responseForComment = responseBeforeComment; | ||
let firstPost = true; | ||
|
||
beforeAll(() => { | ||
return nock('https://api.github.com') | ||
|
@@ -46,6 +55,8 @@ beforeAll(() => { | |
switch (uri) { | ||
case '/repos/123/123/issues/123/comments': | ||
return responseForComment; | ||
case '/repos/124/124/issues/124/comments': | ||
return responseWithOneOtherComment; | ||
default: | ||
throw new Error('unexpected status GETing to Github'); | ||
} | ||
|
@@ -55,11 +66,21 @@ beforeAll(() => { | |
switch (uri) { | ||
case '/repos/123/123/statuses/123': | ||
return requestBody; | ||
case '/repos/124/124/statuses/124': | ||
return requestBody; | ||
case '/repos/123/123/issues/123/comments': | ||
responseForComment = responseAfterComment; | ||
return requestBody; | ||
case '/repos/123/123/issues/123/comments/1': | ||
return requestBody; | ||
case '/repos/124/124/issues/124/comments': | ||
return requestBody; | ||
case '/repos/124/124/issues/124/comments/1': | ||
if (firstPost) { | ||
responseForComment = responseWithOneOtherComment; | ||
firstPost = false; | ||
} | ||
return requestBody; | ||
default: | ||
throw new Error('unexpected status POSTing to Github'); | ||
} | ||
|
@@ -69,6 +90,8 @@ beforeAll(() => { | |
switch (uri) { | ||
case '/repos/123/123/issues/123/comments/1': | ||
return requestBody; | ||
case '/repos/124/124/issues/124/comments/1': | ||
return requestBody; | ||
default: | ||
throw new Error('unexpected status PATCHing to Github'); | ||
} | ||
|
@@ -491,6 +514,53 @@ New Issues Introduced! | |
Artistic-2.0 license | ||
[Medium Severity] | ||
\t+ Via: [email protected] => [email protected] | ||
`, | ||
}, | ||
/* eslint-enable no-useless-escape */ | ||
}, | ||
]); | ||
}); | ||
|
||
test('[snyk-delta module] Is it working with 1 issue and 1 previous non vulnerability summary comment', async () => { | ||
process.argv = [ | ||
'', | ||
'', | ||
path.resolve(__dirname, '..') + | ||
'/fixtures/snyktest-goof-with-one-more-vuln-and-one-more-license.json', | ||
'124', | ||
'124', | ||
'124', | ||
'124', | ||
'124', | ||
]; | ||
const response = await main(); | ||
|
||
expect(response).toEqual([ | ||
{ | ||
status: { | ||
context: 'Snyk Prevent (playground - package-lock.json)', | ||
description: 'New issue(s) found', | ||
state: 'failure', | ||
// eslint-disable-next-line | ||
target_url: | ||
'https://app.snyk.io/org/playground/project/09235fa4-c241-42c6-8c63-c053bd272789', | ||
}, | ||
/* eslint-disable no-useless-escape */ | ||
prComment: { | ||
body: `### ******* Vulnerabilities report for commit number 124 ******* | ||
New Issues Introduced! | ||
## Security | ||
1 issue found | ||
* 1/1: Regular Expression Denial of Service (ReDoS) [High Severity] | ||
\t+ Via: [email protected] => [email protected] => @snyk/[email protected] => [email protected] | ||
\t+ Fixed in: acorn, 5.7.4, 6.4.1, 7.1.1 | ||
\t+ Fixable by upgrade: @snyk/[email protected]=>[email protected] | ||
## License | ||
1 issue found | ||
1/1: | ||
Artistic-2.0 license | ||
[Medium Severity] | ||
\t+ Via: [email protected] => [email protected] | ||
`, | ||
}, | ||
/* eslint-enable no-useless-escape */ | ||
|