Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
spinner.clear(postingMonitorSpinnerLabel),
);
await spinner.clear(postingMonitorSpinnerLabel)(res);
res.path = path;
const endpoint = url.parse(config.API);
let leader = '';
if (res.org) {
leader = '/org/' + res.org;
}
endpoint.pathname = leader + '/manage';
const manageUrl = url.format(endpoint);
endpoint.pathname = leader + '/monitor/' + res.id;
const projectName = pluginApi.isMultiResult(inspectResult)
? projectDeps.package.name
: undefined;
const monOutput = formatMonitorOutput(
packageManager,
res,
manageUrl,
options,
projectName,
foundProjectCount,
);
results.push({ ok: true, data: monOutput, path, projectName });
}
// push a good result
} catch (err) {
// push this error, the loop continues
results.push({ ok: false, data: err, path });
spinner.clear(postingMonitorSpinnerLabel),
);
await spinner.clear(postingMonitorSpinnerLabel)(res);
res.path = path;
const endpoint = url.parse(config.API);
let leader = '';
if (res.org) {
leader = '/org/' + res.org;
}
endpoint.pathname = leader + '/manage';
const manageUrl = url.format(endpoint);
endpoint.pathname = leader + '/monitor/' + res.id;
const projectName = pluginApi.isMultiResult(inspectResult)
? projectDeps.package.name
: undefined;
const monOutput = formatMonitorOutput(
packageManager,
res,
manageUrl,
options,
projectName,
advertiseSubprojectsCount,
);
results.push({ ok: true, data: monOutput, path, projectName });
}
// push a good result
} catch (err) {
// push this error, the loop continues
results.push({ ok: false, data: err, path });
'policy-path': options['policy-path'],
'project-name': options['project-name'] || config.PROJECT_NAME,
isDocker: !!options.docker,
prune: !!options['prune-repeated-subdependencies'],
'experimental-dep-graph': !!options['experimental-dep-graph'],
'remote-repo-url': options['remote-repo-url'],
};
// We send results from "all-sub-projects" scanning as different Monitor objects
// SinglePackageResult is a legacy format understood by Registry, so we have to convert
// a MultiProjectResult to an array of these.
let perProjectResult: pluginApi.SinglePackageResult[] = [];
let foundProjectCount;
if (pluginApi.isMultiResult(inspectResult)) {
perProjectResult = convertMultiPluginResultToSingle(inspectResult);
} else {
foundProjectCount = getSubProjectCount(inspectResult);
perProjectResult = [inspectResult];
}
// Post the project dependencies to the Registry
for (const projectDeps of perProjectResult) {
maybePrintDeps(options, projectDeps.package);
const res = await promiseOrCleanup(
snykMonitor(path, meta, projectDeps, targetFile),
spinner.clear(postingMonitorSpinnerLabel),
);
await spinner.clear(postingMonitorSpinnerLabel)(res);
}
inspectRes = await getMultiPluginResult(root, options, targetFiles);
return inspectRes;
} else {
// TODO: is this needed for the auto detect handling above?
// don't override options.file if scanning multiple files at once
if (!options.scanAllUnmanaged) {
options.file = options.file || detectPackageFile(root);
}
if (!options.docker && !(options.file || options.packageManager)) {
throw NoSupportedManifestsFoundError([...root]);
}
inspectRes = await getSinglePluginResult(root, options);
}
if (!pluginApi.isMultiResult(inspectRes)) {
if (!inspectRes.package) {
// something went wrong if both are not present...
throw Error(
`error getting dependencies from ${options.packageManager} ` +
"plugin: neither 'package' nor 'scannedProjects' were found",
);
}
if (!inspectRes.package.targetFile && inspectRes.plugin) {
inspectRes.package.targetFile = inspectRes.plugin.targetFile;
}
// We are using "options" to store some information returned from plugin that we need to use later,
// but don't want to send to Registry in the Payload.
// TODO(kyegupov): decouple inspect and payload so that we don't need this hack
if (
inspectRes.plugin.meta &&
inspectRes.plugin.meta.allSubProjectNames &&
spinner.clear(postingMonitorSpinnerLabel),
);
await spinner.clear(postingMonitorSpinnerLabel)(res);
res.path = path;
const endpoint = url.parse(config.API);
let leader = '';
if (res.org) {
leader = '/org/' + res.org;
}
endpoint.pathname = leader + '/manage';
const manageUrl = url.format(endpoint);
endpoint.pathname = leader + '/monitor/' + res.id;
const projectName = pluginApi.isMultiResult(inspectResult)
? projectDeps.package.name
: undefined;
const monOutput = formatMonitorOutput(
packageManager,
res,
manageUrl,
options,
projectName,
foundProjectCount,
);
return { ok: true, data: monOutput, path, projectName };
}
} catch (err) {
return { ok: false, data: err, path };
}
return {