How to use snyk - 3 common examples

To help you get started, we’ve selected a few snyk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MitocGroup / recink / components / snyk / src / reporter / text-reporter.js View on Github external
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);
github derekdorr / snyxy / index.js View on Github external
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;
github MitocGroup / recink / components / snyk / src / snyk-component.js View on Github external
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))
      })
    );
  }

snyk

snyk library and cli utility

Apache-2.0
Latest version published 7 days ago

Package Health Score

83 / 100
Full package analysis