Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
badge = this.logger.emoji.moon_empty;
break;
case 'medium':
badge = this.logger.emoji.moon_half;
break;
case 'low':
badge = this.logger.emoji.moon_full;
break;
}
res += badge;
res += red(` ${ severity } severity ${ issue } found on `);
res += grayBold(`${ name }\n`);
res += ` ${ gray('description:') } ${ vuln.title }\n`;
res += ` ${ gray('info:') } `;
res += blueUnderline(`${ snykConfig.ROOT }/vuln/${ vuln.id }\n`);
if (showVulnPaths) {
res += ` ${ gray('package:') } ${ vuln.from.join(' > ') }\n`;
}
if (vuln.note) {
res += ` ${ gray('note:') } ${ vuln.note }\n`;
}
// none of the output past this point is relevant if we're not displaying
// vulnerable paths
if (!showVulnPaths) {
return res.trim();
}
const upgradeSteps = (vuln.upgradePath || []).filter(Boolean);
new Promise(function(resolve) {
let toTest = `${path}@${value}`;
let cachedState = packageCache[toTest];
if (cachedState !== undefined) {
if (cachedState === true) {
console.log('good:', toTest, '(from cache)');
} else {
delete versions[value];
console.log('bad:', toTest, '(from cache)');
}
resolve();
} else {
Snyk.test(toTest).then(function (data) {
if (data.ok !== true) {
console.log('bad:', toTest);
packageCache[toTest] = false;
delete versions[value];
} else {
packageCache[toTest] = true;
console.log('good:', toTest);
}
resolve();
cacheChanged = true;
}, function (data) {
let sanitized = data || {};
if (sanitized.ok !== true) {
console.log('bad:', toTest);
packageCache[toTest] = false;
teardown(emitter) {
if (!this.isActive) {
return Promise.resolve();
}
const token = this.container.get('token', '');
const dev = this.container.get('dev', false);
const actionable = this.container.get('actionable', true);
const options = {
dev, json: true,
'show-vulnerable-paths': actionable ? 'true' : 'false',
};
snykUserConfig.set('api', token);
return Promise.all(
this._modules.map(args => {
const [ npmModule, emitModule ] = args;
return snykTest(npmModule.rootDir, options)
.then(result => this._createReport(npmModule, emitModule, result, options))
.catch(error => this._createReport(npmModule, emitModule, error, options))
})
);
}