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C","sources":["webpack://snyk/./src/cli/commands/auth/is-authed.ts","webpack://snyk/./src/cli/commands/ignore.ts","webpack://snyk/./src/lib/authorization.ts","webpack://snyk/./src/lib/errors/misconfigured-auth-in-ci-error.ts"],"sourcesContent":["import * as snyk from '../../../lib';\nimport config from '../../../lib/config';\nimport { makeRequest } from '../../../lib/request';\n\nexport function isAuthed() {\n const token = snyk.config.get('api');\n return verifyAPI(token).then((res: any) => {\n return res.body.ok;\n });\n}\n\nexport function verifyAPI(api) {\n const payload = {\n body: {\n api,\n },\n method: 'POST',\n url: config.API + '/verify/token',\n json: true,\n };\n\n return new Promise((resolve, reject) => {\n makeRequest(payload, (error, res, body) => {\n if (error) {\n return reject(error);\n }\n\n resolve({\n res,\n body,\n });\n });\n });\n}\n","import * as policy from 'snyk-policy';\nimport chalk from 'chalk';\nimport * as authorization from '../../lib/authorization';\nimport * as auth from './auth/is-authed';\nimport { apiTokenExists } from '../../lib/api-token';\nimport { isCI } from '../../lib/is-ci';\nimport { IgnoreRules, MethodResult } from './types';\n\nimport * as Debug from 'debug';\nconst debug = Debug('snyk');\n\nimport { MisconfiguredAuthInCI } from '../../lib/errors/misconfigured-auth-in-ci-error';\n\nexport default function ignore(options): Promise<MethodResult> {\n debug('snyk ignore called with options: %O', options);\n\n return auth\n .isAuthed()\n .then((authed) => {\n if (!authed) {\n if (isCI()) {\n throw MisconfiguredAuthInCI();\n }\n }\n apiTokenExists();\n })\n .then(() => {\n return authorization.actionAllowed('cliIgnore', options);\n })\n .then((cliIgnoreAuthorization) => {\n if (!cliIgnoreAuthorization.allowed) {\n debug('snyk ignore called when disallowed');\n console.log(chalk.bold.red(cliIgnoreAuthorization.reason));\n return;\n }\n\n const isFilePathProvided = !!options['file-path'];\n\n if (isFilePathProvided) {\n return excludeFilePathPattern(options);\n }\n\n return ignoreIssue(options);\n });\n}\n\nexport function ignoreIssue(options): Promise<MethodResult> {\n if (!options.id) {\n throw Error('idRequired');\n }\n\n options.expiry = new Date(options.expiry);\n if (options.expiry.getTime() !== options.expiry.getTime()) {\n debug('No/invalid expiry given, using the default 30 days');\n options.expiry = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000);\n }\n\n if (!options.reason) {\n options.reason = 'None Given';\n }\n\n const isPathProvided = !!options.path;\n if (!isPathProvided) {\n options.path = '*';\n }\n\n debug(\n `changing policy: ignore \"%s\", for %s, reason: \"%s\", until: %o`,\n options.id,\n isPathProvided ? 'all paths' : `path: '${options.path}'`,\n options.reason,\n options.expiry,\n );\n\n return load(options['policy-path']).then(async (pol) => {\n let ignoreRulePathDataIdx = -1;\n const ignoreParams = {\n reason: options.reason,\n expires: options.expiry,\n created: new Date(),\n };\n\n const ignoreRules: IgnoreRules = pol.ignore;\n\n const issueIgnorePaths = ignoreRules[options.id] ?? [];\n\n // Checking if the ignore-rule for this issue exists for the provided path.\n ignoreRulePathDataIdx = issueIgnorePaths.findIndex(\n (ignoreMetadata) => !!ignoreMetadata[options.path],\n );\n\n // If an ignore-rule for this path doesn't exist, create one.\n if (ignoreRulePathDataIdx === -1) {\n issueIgnorePaths.push({\n [options.path]: ignoreParams,\n });\n }\n // Otherwise, update the existing rule's metadata.\n else {\n issueIgnorePaths[ignoreRulePathDataIdx][options.path] = ignoreParams;\n }\n\n ignoreRules[options.id] = issueIgnorePaths;\n\n pol.ignore = ignoreRules;\n\n return await policy.save(pol, options['policy-path']);\n });\n}\n\nexport async function excludeFilePathPattern(options): Promise<MethodResult> {\n const pattern = options['file-path'];\n const group = options['file-path-group'] || 'global';\n const policyPath = options['policy-path'];\n\n const excludeOptions = {};\n\n if (options.reason !== undefined) {\n excludeOptions['reason'] = options.reason;\n }\n\n if (options.expiry !== undefined) {\n excludeOptions['expires'] = new Date(options.expiry);\n }\n\n debug(`changing policy: ignore \"%s\" added to \"%s\"`, pattern, policyPath);\n\n const pol = await load(policyPath);\n pol.addExclude(pattern, group, excludeOptions);\n\n return policy.save(pol, policyPath);\n}\n\nasync function load(path: string) {\n return policy.load(path).catch((error) => {\n if (error.code === 'ENOENT') {\n // file does not exist - create it\n return policy.create();\n }\n\n throw Error('policyFile');\n });\n}\n","import { getAuthHeader } from './api-token';\nimport config from './config';\nimport { makeRequest } from './request';\n\nexport async function actionAllowed(\n action: string,\n options: { org?: string },\n): Promise<{ allowed: boolean; reason: string }> {\n const org = options.org || config.org || null;\n\n try {\n const res = await makeRequest({\n method: 'GET',\n url: config.API + '/authorization/' + action,\n json: true,\n headers: {\n authorization: getAuthHeader(),\n },\n qs: org && { org },\n });\n\n return (res as any).body.result;\n } catch (err) {\n return {\n allowed: false,\n reason: 'There was an error while checking authorization',\n };\n }\n}\n","import { CustomError } from './custom-error';\n\nexport function MisconfiguredAuthInCI() {\n const errorMsg =\n 'Snyk is missing auth token in order to run inside CI. You must include ' +\n 'your API token as an environment value: `SNYK_TOKEN=12345678`';\n\n const error = new CustomError(errorMsg);\n error.code = 401;\n error.strCode = 'noAuthInCI';\n error.userMessage = errorMsg;\n return error;\n}\n"],"names":[],"sourceRoot":""} |