-
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 #55 from snyk-tech-services/develop
Release changes
- Loading branch information
Showing
5 changed files
with
110 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -489,6 +489,87 @@ New Issues Introduced! | |
|
||
test('[snyk-delta module] Is it working with --all-projects with PR number and mixed results', async () => { | ||
// 2 projects, 1 without new issue and 1 with a new issue so we can verify that one commit status fails while the other one passes | ||
|
||
process.env.SNYK_DEBUG = 'true'; | ||
const logConsoleStream = fs.createWriteStream('./logConsoleFile.log', { | ||
flags: 'a', | ||
}); | ||
process.stderr._write = function(chunk, encoding, callback) { | ||
logConsoleStream.write(chunk, encoding, callback); | ||
}; | ||
|
||
process.argv = [ | ||
'', | ||
'', | ||
path.resolve(__dirname, '..') + | ||
'/fixtures/snyktest-all-projects-with-one-more-vuln-for-one-project-only.json', | ||
'123', | ||
'123', | ||
'123', | ||
'123', | ||
'123', | ||
]; | ||
const response = await main(); | ||
|
||
delete process.env.SNYK_DEBUG; | ||
process.stderr.unpipe; | ||
|
||
try { | ||
const data = fs.readFileSync('./logConsoleFile.log', 'utf8'); | ||
expect(data.includes('Deleting comments on PR')).toEqual(false); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
|
||
expect(response).toEqual([ | ||
{ | ||
status: { | ||
context: 'Snyk Prevent (playground - package-lock.json)', | ||
description: 'No new issue found', | ||
state: 'success', | ||
// eslint-disable-next-line | ||
target_url: | ||
'https://app.snyk.io/org/playground/project/09235fa4-c241-42c6-8c63-c053bd272789', | ||
}, | ||
prComment: {}, | ||
}, | ||
{ | ||
status: { | ||
context: 'Snyk Prevent (playground - subfolder/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-c053bd272790', | ||
}, | ||
/* eslint-disable no-useless-escape */ | ||
prComment: { | ||
body: `### ******* Vulnerabilities report for commit number 123 ******* | ||
New Issue 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] | ||
`, | ||
}, | ||
/* eslint-enable no-useless-escape */ | ||
}, | ||
]); | ||
}); | ||
|
||
test('[snyk-delta module] Is it working with --all-projects with PR number and mixed results and keepHistory', async () => { | ||
// 2 projects, 1 without new issue and 1 with a new issue so we can verify that one commit status fails while the other one passes | ||
|
||
process.env.SNYK_DEBUG = 'true'; | ||
const logConsoleStream = fs.createWriteStream('./logConsoleFile.log', { | ||
flags: 'a', | ||
}); | ||
process.stderr._write = function(chunk, encoding, callback) { | ||
logConsoleStream.write(chunk, encoding, callback); | ||
}; | ||
|
||
process.argv = [ | ||
'', | ||
'', | ||
|
@@ -499,8 +580,20 @@ New Issues Introduced! | |
'123', | ||
'123', | ||
'123', | ||
'keepHistory', | ||
]; | ||
const response = await main(); | ||
|
||
delete process.env.SNYK_DEBUG; | ||
process.stderr.unpipe; | ||
|
||
try { | ||
const data = fs.readFileSync('./logConsoleFile.log', 'utf8'); | ||
expect(data.includes('Deleting comments on PR')).toEqual(false); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
|
||
expect(response).toEqual([ | ||
{ | ||
status: { | ||
|