-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d78693d
commit e5fb843
Showing
8 changed files
with
140 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module.exports = ignore; | ||
|
||
var debug = require('debug')('snyk'); | ||
var policy = require('snyk-policy'); | ||
var Promise = require('es6-promise').Promise; // jshint ignore:line | ||
|
||
function ignore(options) { | ||
debug('snyk ignore called with options: %O', options); | ||
if (!options.id) { | ||
return Promise.reject(Error('idRequired')); | ||
} | ||
options.expiry = new Date(options.expiry); | ||
if (options.expiry.getTime() !== options.expiry.getTime()) { | ||
debug('No/invalid expiry given, using the default 30 days'); | ||
options.expiry = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000); | ||
} | ||
if (!options.reason) { | ||
options.reason = 'None Given'; | ||
} | ||
if (!options.path) { | ||
debug('using cwd() as path'); | ||
options.path = process.cwd(); | ||
} | ||
|
||
debug('changing policy: ignore "%s", for all paths, reason: "%s", until: %o', | ||
options.id, options.reason, options.expiry); | ||
return policy.load(options.path) | ||
.catch(function (error) { | ||
if (error.code === 'ENOENT') { // file does not exist - create it | ||
return policy.create(); | ||
} | ||
throw Error('policyFile'); | ||
}) | ||
.then(function ignoreIssue(pol) { | ||
pol.ignore[options.id] = [ | ||
{ | ||
'*': | ||
{ | ||
reason: options.reason, | ||
expires: options.expiry, | ||
}, | ||
}, | ||
]; | ||
policy.save(pol, options.path); | ||
}); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
Ignore: | ||
|
||
$ snyk ignore --id=IssueID [--expiry=expiry] [--reason='reason for ignoring'] | ||
|
||
Ignore a certain issue, according to its snyk ID for all occurrences. | ||
|
||
Options: | ||
|
||
id ................. snyk ID for the issue to ignore. Required. | ||
expiry ............. expiry date string, according to RFC2822 (https://tools.ietf.org/html/rfc2822#page-14) | ||
reason ............. the reason to ignore this issue | ||
|
||
Examples: | ||
|
||
$ snyk ignore --id='npm:qs:20170213' --expiry='2017-03-30' --reason='testing' |
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