diff --git a/src/lib/prune.ts b/src/lib/prune.ts index 74c7825bfa4..694a7481287 100644 --- a/src/lib/prune.ts +++ b/src/lib/prune.ts @@ -23,17 +23,19 @@ export async function pruneGraph( debug('rootPkg', depGraph.rootPkg); debug('prePrunePathsCount: ' + prePrunePathsCount); debug('isDenseGraph', isDenseGraph); - analytics.add('prePrunePathsCount', prePrunePathsCount); + analytics.add('prePrunedPathsCount', prePrunePathsCount); if (isDenseGraph || pruneIsRequired) { + debug('Trying to prune the graph'); const prunedTree = (await graphToDepTree(depGraph, packageManager, { deduplicateWithinTopLevelDeps: true, })) as DepTree; const prunedGraph = await depTreeToGraph(prunedTree, packageManager); const postPrunePathsCount = countPathsToGraphRoot(prunedGraph); - analytics.add('postPrunePathsCount', postPrunePathsCount); + analytics.add('postPrunedPathsCount', postPrunePathsCount); debug('postPrunePathsCount' + postPrunePathsCount); if (postPrunePathsCount > config.MAX_PATH_COUNT) { - debug('Too many vulnerable paths to process the project'); + debug('Too many paths to process the project'); + //TODO replace the throw below with TooManyPaths we do not calculate vuln paths there throw new TooManyVulnPaths(); } return prunedGraph; diff --git a/src/lib/snyk-test/run-test.ts b/src/lib/snyk-test/run-test.ts index 05214264361..04978cd7b77 100644 --- a/src/lib/snyk-test/run-test.ts +++ b/src/lib/snyk-test/run-test.ts @@ -48,7 +48,6 @@ import { extractPackageManager } from '../plugins/extract-package-manager'; import { getSubProjectCount } from '../plugins/get-sub-project-count'; import { serializeCallGraphWithMetrics } from '../reachable-vulns'; import { validateOptions } from '../options-validator'; -import { countPathsToGraphRoot } from '../utils'; import { findAndLoadPolicy } from '../policy'; const debug = debugModule('snyk'); @@ -487,20 +486,12 @@ async function assembleLocalPayloads( const pruneIsRequired = options['prune-repeated-subdependencies']; - if (pruneIsRequired && packageManager) { - debug('Trying to prune the graph'); - const prePruneDepCount = countPathsToGraphRoot(depGraph); - debug('pre prunedPathsCount: ' + prePruneDepCount); - + if (packageManager) { depGraph = await pruneGraph( depGraph, packageManager, pruneIsRequired, ); - analytics.add('prePrunedPathsCount', prePruneDepCount); - const postPruneDepCount = countPathsToGraphRoot(depGraph); - debug('post prunedPathsCount: ' + postPruneDepCount); - analytics.add('postPrunedPathsCount', postPruneDepCount); } body.depGraph = depGraph; }