snyk 1.1289.0 → 1.1291.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.
@@ -216365,13 +216365,13 @@ function buildDepGraph(mavenGraph, includeTestScope = false, verboseEnabled = fa
216365
216365
  const builder = new dep_graph_1.DepGraphBuilder({ name: 'maven' }, parsedRoot.pkgInfo);
216366
216366
  const visitedMap = {};
216367
216367
  const queue = [];
216368
- queue.push(...getItems(rootId, nodes[rootId]));
216368
+ queue.push(...getItems(rootId, [], nodes[rootId]));
216369
216369
  // breadth first search
216370
216370
  while (queue.length > 0) {
216371
216371
  const item = queue.shift();
216372
216372
  if (!item)
216373
216373
  continue;
216374
- const { id, parentId } = item;
216374
+ const { id, ancestry, parentId } = item;
216375
216375
  const parsed = parseId(id);
216376
216376
  const node = nodes[id];
216377
216377
  if (!includeTestScope && parsed.scope === 'test' && !node.reachesProdDep) {
@@ -216386,6 +216386,16 @@ function buildDepGraph(mavenGraph, includeTestScope = false, verboseEnabled = fa
216386
216386
  builder.connectDep(parentId, prunedId);
216387
216387
  continue; // don't queue any more children
216388
216388
  }
216389
+ // If verbose is enabled and our ancestry includes ourselves
216390
+ // we are cyclic and should be pruned :)
216391
+ if (verboseEnabled && ancestry.includes(id)) {
216392
+ const prunedId = visited.id + ':pruned-cycle';
216393
+ builder.addPkgNode(visited.pkgInfo, prunedId, {
216394
+ labels: { pruned: 'cyclic' },
216395
+ });
216396
+ builder.connectDep(parentId, prunedId);
216397
+ continue; // don't queue any more children
216398
+ }
216389
216399
  const parentNodeId = parentId === rootId ? builder.rootNodeId : parentId;
216390
216400
  if (verboseEnabled && visited) {
216391
216401
  // use visited node when omited dependencies found (verbose)
@@ -216397,15 +216407,16 @@ function buildDepGraph(mavenGraph, includeTestScope = false, verboseEnabled = fa
216397
216407
  builder.connectDep(parentNodeId, id);
216398
216408
  visitedMap[parsed.key] = parsed;
216399
216409
  }
216400
- queue.push(...getItems(id, node));
216410
+ // Remember to push updated ancestry here
216411
+ queue.push(...getItems(id, [...ancestry, id], node));
216401
216412
  }
216402
216413
  return builder.build();
216403
216414
  }
216404
216415
  exports.buildDepGraph = buildDepGraph;
216405
- function getItems(parentId, node) {
216416
+ function getItems(parentId, ancestry, node) {
216406
216417
  const items = [];
216407
216418
  for (const id of node?.dependsOn || []) {
216408
- items.push({ id, parentId });
216419
+ items.push({ id, ancestry, parentId });
216409
216420
  }
216410
216421
  return items;
216411
216422
  }