snyk 1.1208.0 → 1.1209.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.
@@ -213370,7 +213370,7 @@ function buildDepGraph(mavenGraph, includeTestScope = false) {
213370
213370
  const { rootId, nodes } = mavenGraph;
213371
213371
  const { pkgInfo: root } = getPkgInfo(rootId);
213372
213372
  const builder = new dep_graph_1.DepGraphBuilder({ name: 'maven' }, root);
213373
- const visited = [];
213373
+ const visited = {};
213374
213374
  const queue = [];
213375
213375
  queue.push(...getItems(rootId, nodes[rootId]));
213376
213376
  // breadth first search
@@ -213380,9 +213380,10 @@ function buildDepGraph(mavenGraph, includeTestScope = false) {
213380
213380
  continue;
213381
213381
  const { id, parentId } = item;
213382
213382
  const { pkgInfo, scope } = getPkgInfo(id);
213383
- if (!includeTestScope && scope === 'test')
213383
+ const node = nodes[id];
213384
+ if (!includeTestScope && scope === 'test' && !node.reachesProdDep)
213384
213385
  continue;
213385
- if (visited.includes(id)) {
213386
+ if (visited[id]) {
213386
213387
  const prunedId = id + ':pruned';
213387
213388
  builder.addPkgNode(pkgInfo, prunedId, { labels: { pruned: 'true' } });
213388
213389
  builder.connectDep(parentId, prunedId);
@@ -213391,8 +213392,8 @@ function buildDepGraph(mavenGraph, includeTestScope = false) {
213391
213392
  const parentNodeId = parentId === rootId ? builder.rootNodeId : parentId;
213392
213393
  builder.addPkgNode(pkgInfo, id);
213393
213394
  builder.connectDep(parentNodeId, id);
213394
- queue.push(...getItems(id, nodes[id]));
213395
- visited.push(id);
213395
+ queue.push(...getItems(id, node));
213396
+ visited[id] = true;
213396
213397
  }
213397
213398
  return builder.build();
213398
213399
  }
@@ -213578,26 +213579,41 @@ class MavenGraphBuilder {
213578
213579
  tslib_1.__classPrivateFieldSet(this, _MavenGraphBuilder_graph, {
213579
213580
  rootId,
213580
213581
  nodes: {
213581
- [rootId]: { dependsOn: [] },
213582
+ [rootId]: { dependsOn: [], parents: [], reachesProdDep: false },
213582
213583
  },
213583
213584
  }, "f");
213584
213585
  }
213585
- add(id) {
213586
- if (!this.node(id)) {
213587
- tslib_1.__classPrivateFieldGet(this, _MavenGraphBuilder_graph, "f").nodes[id] = { dependsOn: [] };
213588
- }
213586
+ findOrCreateNode(id) {
213587
+ return this.findNode(id) || this.createNode(id);
213589
213588
  }
213590
- node(id) {
213589
+ findNode(id) {
213591
213590
  return tslib_1.__classPrivateFieldGet(this, _MavenGraphBuilder_graph, "f").nodes[id];
213592
213591
  }
213592
+ createNode(id) {
213593
+ const node = { dependsOn: [], parents: [], reachesProdDep: false };
213594
+ tslib_1.__classPrivateFieldGet(this, _MavenGraphBuilder_graph, "f").nodes[id] = node;
213595
+ return node;
213596
+ }
213597
+ markNodeProdReachable(id) {
213598
+ const node = this.findNode(id);
213599
+ if (node && !node.reachesProdDep) {
213600
+ node.reachesProdDep = true;
213601
+ for (const parentId of node.parents) {
213602
+ this.markNodeProdReachable(parentId);
213603
+ }
213604
+ }
213605
+ }
213593
213606
  connect(parentId, id) {
213594
- this.add(parentId);
213595
- this.add(id);
213596
- const node = this.node(parentId);
213597
- if (!node)
213598
- return;
213599
- if (!node.dependsOn.includes(id)) {
213600
- node.dependsOn.push(id);
213607
+ const parentNode = this.findOrCreateNode(parentId);
213608
+ const childNode = this.findOrCreateNode(id);
213609
+ if (!childNode.parents.includes(parentId)) {
213610
+ childNode.parents.push(parentId);
213611
+ }
213612
+ if (!parentNode.dependsOn.includes(id)) {
213613
+ parentNode.dependsOn.push(id);
213614
+ }
213615
+ if (!id.endsWith(':test')) {
213616
+ this.markNodeProdReachable(id);
213601
213617
  }
213602
213618
  }
213603
213619
  get graph() {
@@ -213727,13 +213743,24 @@ const childProcess = __webpack_require__(32081);
213727
213743
  const index_1 = __webpack_require__(29615);
213728
213744
  const shescape_1 = __webpack_require__(79114);
213729
213745
  function execute(command, args, options) {
213730
- const spawnOptions = { shell: true };
213746
+ const spawnOptions = { shell: true, env: Object.assign({}, process.env) };
213731
213747
  if (options && options.cwd) {
213732
213748
  spawnOptions.cwd = options.cwd;
213733
213749
  }
213734
213750
  if (args) {
213735
213751
  args = (0, shescape_1.quoteAll)(args, spawnOptions);
213736
213752
  }
213753
+ // Before spawning an external process, we look if we need to restore the system proxy configuration,
213754
+ // which overides the cli internal proxy configuration.
213755
+ if (process.env.SNYK_SYSTEM_HTTP_PROXY !== undefined) {
213756
+ spawnOptions.env.HTTP_PROXY = process.env.SNYK_SYSTEM_HTTP_PROXY;
213757
+ }
213758
+ if (process.env.SNYK_SYSTEM_HTTPS_PROXY !== undefined) {
213759
+ spawnOptions.env.HTTPS_PROXY = process.env.SNYK_SYSTEM_HTTPS_PROXY;
213760
+ }
213761
+ if (process.env.SNYK_SYSTEM_NO_PROXY !== undefined) {
213762
+ spawnOptions.env.NO_PROXY = process.env.SNYK_SYSTEM_NO_PROXY;
213763
+ }
213737
213764
  return new Promise((resolve, reject) => {
213738
213765
  let stdout = '';
213739
213766
  let stderr = '';