How to use the snyk-policy.getByVuln function in snyk-policy

To help you get started, we’ve selected a few snyk-policy 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 snyk / snyk / src / cli / commands / protect / prompts.ts View on Github external
prompts = prompts.reduce((acc: Prompt[], curr) => {
    acc.push(curr);
    const rule = snykPolicy.getByVuln(policy, curr.choices![0].value.vuln);
    let defaultAnswer = 'None given';
    if (rule && rule.type === 'ignore') {
      defaultAnswer = rule.reason;
    }
    const issue =
      curr.choices![0].value.vuln &&
      curr.choices![0].value.vuln.type === 'license'
        ? 'issue'
        : 'vulnerability';
    acc.push({
      name: curr.name + '-reason',
      message: '[audit] Reason for ignoring ' + issue + '?',
      default: defaultAnswer,
      when(answers) {
        if (!answers[curr.name]) {
          return false;

snyk-policy

Snyk's policy parser and matching logic

Apache-2.0
Latest version published 11 hours ago

Package Health Score

78 / 100
Full package analysis