snyk 1.838.0 → 1.842.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "API": "https://snyk.io/api/v1",
3
+ "API_V3_URL": "https://api.snyk.io/v3",
3
4
  "devDeps": false,
4
5
  "PRUNE_DEPS_THRESHOLD": 40000,
5
6
  "MAX_PATH_COUNT": 1500000,
@@ -4230,11 +4230,9 @@ exports.getExtraProjectCount = getExtraProjectCount;
4230
4230
  "use strict";
4231
4231
 
4232
4232
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4233
- exports.getMultiPluginResult = void 0;
4233
+ exports.filterOutProcessedWorkspaces = exports.getMultiPluginResult = void 0;
4234
4234
  const cloneDeep = __webpack_require__(83465);
4235
4235
  const pathLib = __webpack_require__(85622);
4236
- const sortBy = __webpack_require__(58254);
4237
- const groupBy = __webpack_require__(20276);
4238
4236
  const cliInterface = __webpack_require__(65266);
4239
4237
  const chalk_1 = __webpack_require__(32589);
4240
4238
  const theme_1 = __webpack_require__(86988);
@@ -4254,6 +4252,7 @@ async function getMultiPluginResult(root, options, targetFiles) {
4254
4252
  // the files need to be proceeded together as they provide context to each other
4255
4253
  const { scannedProjects, unprocessedFiles, } = await processYarnWorkspacesProjects(root, options, targetFiles);
4256
4254
  allResults.push(...scannedProjects);
4255
+ debug(`Not part of a workspace: ${unprocessedFiles.join(', ')}}`);
4257
4256
  // process the rest 1 by 1 sent to relevant plugins
4258
4257
  for (const targetFile of unprocessedFiles) {
4259
4258
  const optionsClone = cloneDeep(options);
@@ -4304,7 +4303,7 @@ async function processYarnWorkspacesProjects(root, options, targetFiles) {
4304
4303
  strictOutOfSync: options.strictOutOfSync,
4305
4304
  dev: options.dev,
4306
4305
  }, targetFiles);
4307
- const unprocessedFiles = filterOutProcessedWorkspaces(scannedProjects, targetFiles);
4306
+ const unprocessedFiles = filterOutProcessedWorkspaces(root, scannedProjects, targetFiles);
4308
4307
  return { scannedProjects, unprocessedFiles };
4309
4308
  }
4310
4309
  catch (e) {
@@ -4312,30 +4311,32 @@ async function processYarnWorkspacesProjects(root, options, targetFiles) {
4312
4311
  return { scannedProjects: [], unprocessedFiles: targetFiles };
4313
4312
  }
4314
4313
  }
4315
- function filterOutProcessedWorkspaces(scannedProjects, allTargetFiles) {
4316
- const mapped = allTargetFiles.map((p) => ({ path: p, ...pathLib.parse(p) }));
4317
- const sorted = sortBy(mapped, 'dir');
4318
- const targetFilesByDirectory = groupBy(sorted, 'dir');
4319
- const scanned = scannedProjects.map((p) => p.targetFile);
4314
+ function filterOutProcessedWorkspaces(root, scannedProjects, allTargetFiles) {
4320
4315
  const targetFiles = [];
4321
- for (const directory of Object.keys(targetFilesByDirectory)) {
4322
- for (const targetFile of targetFilesByDirectory[directory]) {
4323
- const { base, path } = targetFile;
4324
- // any non yarn workspace files should be scanned
4325
- if (!['package.json', 'yarn.lock'].includes(base)) {
4326
- targetFiles.push(path);
4327
- continue;
4328
- }
4329
- // check if Node manifest has already been processed a part or a workspace
4330
- const packageJsonFileName = pathLib.join(directory, 'package.json');
4331
- const alreadyScanned = scanned.some((f) => packageJsonFileName.endsWith(f));
4332
- if (!alreadyScanned) {
4333
- targetFiles.push(path);
4334
- }
4316
+ const scanned = scannedProjects
4317
+ .map((p) => p.targetFile)
4318
+ .map((p) => pathLib.resolve(process.cwd(), root, p));
4319
+ const all = allTargetFiles.map((p) => ({
4320
+ path: pathLib.resolve(process.cwd(), root, p),
4321
+ original: p,
4322
+ }));
4323
+ for (const entry of all) {
4324
+ const { path, original } = entry;
4325
+ const { base } = pathLib.parse(path);
4326
+ if (!['package.json', 'yarn.lock'].includes(base)) {
4327
+ targetFiles.push(original);
4328
+ continue;
4329
+ }
4330
+ // standardise to package.json
4331
+ // we discover the lockfiles but targetFile is package.json
4332
+ if (!scanned.includes(path.replace('yarn.lock', 'package.json'))) {
4333
+ targetFiles.push(original);
4334
+ continue;
4335
4335
  }
4336
4336
  }
4337
4337
  return targetFiles;
4338
4338
  }
4339
+ exports.filterOutProcessedWorkspaces = filterOutProcessedWorkspaces;
4339
4340
 
4340
4341
 
4341
4342
  /***/ }),
@@ -5290,7 +5291,7 @@ exports.codePlugin = {
5290
5291
  return '';
5291
5292
  },
5292
5293
  async test(paths, options) {
5293
- var _a, _b;
5294
+ var _a, _b, _c, _d;
5294
5295
  try {
5295
5296
  analytics.add('sast-scan', true);
5296
5297
  const sastSettings = await settings_1.getSastSettings(options);
@@ -5304,6 +5305,11 @@ exports.codePlugin = {
5304
5305
  analytics.add('sast-issues-found', numOfIssues);
5305
5306
  if (options.sarif || options.json) {
5306
5307
  if (numOfIssues > 0) {
5308
+ if (options['no-markdown']) {
5309
+ (_d = (_c = sarifTypedResult.runs) === null || _c === void 0 ? void 0 : _c[0].results) === null || _d === void 0 ? void 0 : _d.forEach(({ message }) => {
5310
+ delete message.markdown;
5311
+ });
5312
+ }
5307
5313
  hasIssues(json_1.jsonStringifyLargeObject(sarifTypedResult));
5308
5314
  }
5309
5315
  return { readableResult: json_1.jsonStringifyLargeObject(sarifTypedResult) };
@@ -5986,7 +5992,8 @@ exports.validatePayload = validatePayload;
5986
5992
  "use strict";
5987
5993
 
5988
5994
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5989
- exports.makeRequest = void 0;
5995
+ exports.makeRequestV3 = exports.makeRequest = void 0;
5996
+ const api_token_1 = __webpack_require__(95181);
5990
5997
  const request = __webpack_require__(52050);
5991
5998
  async function makeRequest(payload) {
5992
5999
  return new Promise((resolve, reject) => {
@@ -6005,6 +6012,35 @@ async function makeRequest(payload) {
6005
6012
  });
6006
6013
  }
6007
6014
  exports.makeRequest = makeRequest;
6015
+ /**
6016
+ * All v3 request will essentially be the same and are JSON by default
6017
+ * Thus if no headers provided default headers are used
6018
+ * @param {any} payload for the request
6019
+ * @returns
6020
+ */
6021
+ async function makeRequestV3(payload) {
6022
+ return new Promise((resolve, reject) => {
6023
+ var _a;
6024
+ payload.headers = (_a = payload.headers) !== null && _a !== void 0 ? _a : {
6025
+ 'Content-Type': 'application/vnd.api+json',
6026
+ authorization: api_token_1.getAuthHeader(),
6027
+ };
6028
+ payload.json = true;
6029
+ request.makeRequest(payload, (error, res, body) => {
6030
+ if (error) {
6031
+ return reject(error);
6032
+ }
6033
+ if (res.statusCode >= 400) {
6034
+ return reject({
6035
+ code: res.statusCode,
6036
+ body: JSON.parse(body),
6037
+ });
6038
+ }
6039
+ resolve(JSON.parse(body));
6040
+ });
6041
+ });
6042
+ }
6043
+ exports.makeRequestV3 = makeRequestV3;
6008
6044
 
6009
6045
 
6010
6046
  /***/ }),