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AC,WAAW,EAAE;4BACvB,IAAI;wBACN,CAAC,CAAC,EAAE,CAAC;oBACP,IAAI,CACL,CAAC;YACJ,CAAC,CAAC;iBACD,IAAI,CAAC,EAAE,CAAC;iBACR,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sources":["webpack://snyk/./src/cli/commands/policy.ts","webpack://snyk/./src/lib/display-policy.ts"],"sourcesContent":["import * as policy from 'snyk-policy';\nimport { display } from '../../lib/display-policy';\nimport {\n FailedToLoadPolicyError,\n PolicyNotFoundError,\n CustomError,\n} from '../../lib/errors';\n\nexport default async function displayPolicy(path?: string): Promise<string> {\n try {\n const loadedPolicy = (await policy.load(path || process.cwd())) as Promise<\n string\n >;\n return await display(loadedPolicy);\n } catch (error) {\n let adaptedError: CustomError;\n if (error.code === 'ENOENT') {\n adaptedError = new PolicyNotFoundError();\n } else {\n adaptedError = new FailedToLoadPolicyError();\n adaptedError.innerError = error;\n }\n throw adaptedError;\n }\n}\n","import chalk from 'chalk';\nimport { demunge } from 'snyk-policy';\nimport config from './config';\n\nexport async function display(policy) {\n const p = demunge(policy, config.PUBLIC_VULN_DB_URL);\n const delimiter = '\\n\\n------------------------\\n';\n\n let res =\n chalk.bold(\n 'Current Snyk policy, read from ' + policy.__filename + ' file',\n ) + '\\n';\n res += 'Modified: ' + policy.__modified + '\\n';\n res += 'Created: ' + policy.__created + '\\n';\n\n res += p.patch.map(displayRule('Patch vulnerability')).join('\\n');\n if (p.patch.length && p.ignore.length) {\n res += delimiter;\n }\n\n res += p.ignore.map(displayRule('Ignore')).join('\\n');\n if (p.ignore.length && p.exclude.length) {\n res += delimiter;\n }\n\n res += p.exclude.map(displayRule('Exclude')).join('\\n');\n\n return Promise.resolve(res);\n}\n\nfunction displayRule(title) {\n return (rule, i) => {\n i += 1;\n\n const formattedTitle =\n title === 'Exclude'\n ? chalk.bold(`\\n#${i} ${title}`) +\n ` the following ${chalk.bold(rule.id)} items/paths:\\n`\n : chalk.bold(`\\n#${i} ${title} ${rule.url}`) +\n ' in the following paths:\\n';\n\n return (\n formattedTitle +\n rule.paths\n .map((p) => {\n return (\n p.path +\n (p.reason\n ? '\\nReason: ' +\n p.reason +\n '\\nExpires: ' +\n p.expires.toUTCString() +\n '\\n'\n : '') +\n '\\n'\n );\n })\n .join('')\n .replace(/\\s*$/, '')\n );\n };\n}\n"],"names":[],"sourceRoot":""} |