From 387d325d8a97ad5e5e492d7b5f84ded9f47ad7e7 Mon Sep 17 00:00:00 2001 From: Or Geva Date: Thu, 30 Nov 2023 15:49:14 +0200 Subject: [PATCH] Update webview version to 0.2.12 --- package-lock.json | 8 +++---- package.json | 2 +- .../dependenciesRoot/rootTree.ts | 20 ++++++++++++----- .../utils/dependencyUtils.ts | 3 +-- .../utils/yarnImpactGraph.ts | 3 +-- src/test/tests/dependencyUtils.test.ts | 22 +++++-------------- src/test/tests/utils/treeNodeUtils.test.ts | 2 +- src/test/tests/yarnImpactGraph.test.ts | 2 -- 8 files changed, 28 insertions(+), 34 deletions(-) diff --git a/package-lock.json b/package-lock.json index 35197fd8..469efb5b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "adm-zip": "~0.5.9", "fs-extra": "~10.1.0", "jfrog-client-js": "^2.7.1", - "jfrog-ide-webview": "https://releases.jfrog.io/artifactory/ide-webview-npm/jfrog-ide-webview/-/jfrog-ide-webview-0.2.11.tgz", + "jfrog-ide-webview": "https://releases.jfrog.io/artifactory/ide-webview-npm/jfrog-ide-webview/-/jfrog-ide-webview-0.2.12.tgz", "js-yaml": "^4.1.0", "json2csv": "~5.0.7", "nuget-deps-tree": "^0.3.1", @@ -4692,9 +4692,9 @@ } }, "node_modules/jfrog-ide-webview": { - "version": "0.2.11", - "resolved": "https://releases.jfrog.io/artifactory/ide-webview-npm/jfrog-ide-webview/-/jfrog-ide-webview-0.2.11.tgz", - "integrity": "sha512-htZATG8ANOpVaFVomcoXT2g+Wai5tgm8DNzPpHXrmclN3wid9B2F/Jyif0NJ0BKjg19K3w30WpLlUjOIqPWGxg==", + "version": "0.2.12", + "resolved": "https://releases.jfrog.io/artifactory/ide-webview-npm/jfrog-ide-webview/-/jfrog-ide-webview-0.2.12.tgz", + "integrity": "sha512-+yn3Tozzzi78HMQ63cPCsywF2sKVFdIfbVA38O8/wbEaKYHvv/bA2Wv+1VNBzKRFeOfMy+Aeso7ejcFGYyxAyQ==", "dependencies": { "@mui/lab": "^5.0.0-alpha.142", "@mui/material": "^5.14.7", diff --git a/package.json b/package.json index d5f4fe3c..521ab9b1 100644 --- a/package.json +++ b/package.json @@ -305,7 +305,7 @@ "adm-zip": "~0.5.9", "fs-extra": "~10.1.0", "jfrog-client-js": "^2.7.1", - "jfrog-ide-webview": "https://releases.jfrog.io/artifactory/ide-webview-npm/jfrog-ide-webview/-/jfrog-ide-webview-0.2.11.tgz", + "jfrog-ide-webview": "https://releases.jfrog.io/artifactory/ide-webview-npm/jfrog-ide-webview/-/jfrog-ide-webview-0.2.12.tgz", "js-yaml": "^4.1.0", "json2csv": "~5.0.7", "nuget-deps-tree": "^0.3.1", diff --git a/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/rootTree.ts b/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/rootTree.ts index 35e4e1e9..1fe30397 100644 --- a/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/rootTree.ts +++ b/src/main/treeDataProviders/dependenciesTree/dependenciesRoot/rootTree.ts @@ -14,7 +14,7 @@ export enum BuildTreeErrorType { } export class RootNode extends DependenciesTreeNode { - public static IMPACT_PATHS_LIMIT: number = 50; + public static IMPACT_PATHS_LIMIT: number = 20; private _projectDetails: ProjectDetails; private _workspaceFolder: string; @@ -89,23 +89,31 @@ export class RootNode extends DependenciesTreeNode { private static collectPaths(vulnerableDependencyId: string, children: DependenciesTreeNode[], size: number): IImpactGraph { let impactPaths: IImpactGraphNode[] = []; for (let child of children) { + if (size === RootNode.IMPACT_PATHS_LIMIT) { + break; + } if (impactPaths.find(node => node.name === child.componentId)) { // Loop encountered continue; } if (child.componentId === vulnerableDependencyId) { - if (size < RootNode.IMPACT_PATHS_LIMIT) { - RootNode.appendDirectImpact(impactPaths, child.componentId); - } + RootNode.appendDirectImpact(impactPaths, child.componentId); size++; } let indirectImpact: IImpactGraph = RootNode.collectPaths(vulnerableDependencyId, child.children, size); RootNode.appendIndirectImpact(impactPaths, child.componentId, indirectImpact); - size = indirectImpact.pathsCount ?? size; + size = indirectImpact.pathsLimit || size; + } + return { root: { children: impactPaths }, pathsLimit: size } as IImpactGraph; + } + + public static createImpactPathLimit(totalPath: number | undefined) { + if (totalPath === RootNode.IMPACT_PATHS_LIMIT) { + return totalPath; } - return { root: { children: impactPaths }, pathsCount: size } as IImpactGraph; + return undefined; } private static appendDirectImpact(impactPaths: IImpactGraphNode[], componentId: string): void { diff --git a/src/main/treeDataProviders/utils/dependencyUtils.ts b/src/main/treeDataProviders/utils/dependencyUtils.ts index ebc5ba00..c1152b5a 100644 --- a/src/main/treeDataProviders/utils/dependencyUtils.ts +++ b/src/main/treeDataProviders/utils/dependencyUtils.ts @@ -335,8 +335,7 @@ export class DependencyUtils { name: this.getGraphName(descriptorGraph), children: impactedPaths.root?.children }, - pathsCount: impactedPaths.pathsCount, - pathsLimit: RootNode.IMPACT_PATHS_LIMIT + pathsLimit: RootNode.createImpactPathLimit(impactedPaths.pathsLimit) } as IImpactGraph); } } diff --git a/src/main/treeDataProviders/utils/yarnImpactGraph.ts b/src/main/treeDataProviders/utils/yarnImpactGraph.ts index 58e69a48..426d841b 100644 --- a/src/main/treeDataProviders/utils/yarnImpactGraph.ts +++ b/src/main/treeDataProviders/utils/yarnImpactGraph.ts @@ -161,8 +161,7 @@ export class YarnImpactGraphCreator { } return { root: this.mergeAllTrees(trees), - pathsCount: Math.min(RootNode.IMPACT_PATHS_LIMIT, chains.length), - pathsLimit: RootNode.IMPACT_PATHS_LIMIT + pathsLimit: RootNode.createImpactPathLimit(chains.length) } as IImpactGraph; } diff --git a/src/test/tests/dependencyUtils.test.ts b/src/test/tests/dependencyUtils.test.ts index ff52c73e..6267471a 100644 --- a/src/test/tests/dependencyUtils.test.ts +++ b/src/test/tests/dependencyUtils.test.ts @@ -81,43 +81,33 @@ describe('Dependency Utils Tests', () => { { name: 'A:1.0.0' } as IImpactGraphNode, { name: 'C:2.0.0', children: [{ name: 'A:1.0.0' } as IImpactGraphNode] } as IImpactGraphNode ] - } as IImpactGraphNode, - pathsCount: 2, - pathsLimit: RootNode.IMPACT_PATHS_LIMIT + } as IImpactGraphNode } as IImpactGraph); map.set('XRAY-191882' + 'C:2.0.0', { root: { name: root.componentId, children: [{ name: 'C:2.0.0' } as IImpactGraphNode] - }, - pathsCount: 1, - pathsLimit: RootNode.IMPACT_PATHS_LIMIT + } } as IImpactGraph); // issue XRAY-94201, for components B:1.0.0 map.set('XRAY-94201' + 'B:1.0.0', { root: { name: root.componentId, children: [{ name: 'B:1.0.0' } as IImpactGraphNode] - }, - pathsCount: 1, - pathsLimit: RootNode.IMPACT_PATHS_LIMIT + } } as IImpactGraph); // issue XRAY-142007, for components [A:1.0.1, C:2.0.0] map.set('XRAY-142007' + 'A:1.0.1', { root: { name: root.componentId, children: [{ name: 'B:1.0.0', children: [{ name: 'A:1.0.1' } as IImpactGraphNode] } as IImpactGraphNode] - }, - pathsCount: 1, - pathsLimit: RootNode.IMPACT_PATHS_LIMIT + } } as IImpactGraph); map.set('XRAY-142007' + 'C:2.0.0', { root: { name: root.componentId, children: [{ name: 'C:2.0.0' } as IImpactGraphNode] - }, - pathsCount: 1, - pathsLimit: RootNode.IMPACT_PATHS_LIMIT + } } as IImpactGraph); return map; } @@ -144,7 +134,7 @@ describe('Dependency Utils Tests', () => { let impactedTree: Map = DependencyUtils.createImpactedGraph(root, getGraphResponse('scanGraphVulnerabilities')); - assert.equal(impactedTree.get('XRAY-191882A:1.0.0')?.pathsCount, 2); + assert.equal(impactedTree.get('XRAY-191882A:1.0.0')?.pathsLimit, 1); assert.equal(impactedTree.get('XRAY-191882A:1.0.0')?.root.children?.length, 1); RootNode.IMPACT_PATHS_LIMIT = ORIGIN_IMPACT_PATHS_LIMIT; diff --git a/src/test/tests/utils/treeNodeUtils.test.ts b/src/test/tests/utils/treeNodeUtils.test.ts index e6421006..764f6e4b 100644 --- a/src/test/tests/utils/treeNodeUtils.test.ts +++ b/src/test/tests/utils/treeNodeUtils.test.ts @@ -54,7 +54,7 @@ export function createRootTestNode(pathOfWorkspace: string): IssuesRootTreeNode uri: { fsPath: pathOfWorkspace, // The usage of 'path' is avoided due to its lack of cross-platform compatibility. This placeholder is used to nullify any tests reliant on 'path'. - path: "incorrect path" + path: 'incorrect path' } as vscode.Uri } as vscode.WorkspaceFolder); } diff --git a/src/test/tests/yarnImpactGraph.test.ts b/src/test/tests/yarnImpactGraph.test.ts index aab0fc51..fce2240b 100644 --- a/src/test/tests/yarnImpactGraph.test.ts +++ b/src/test/tests/yarnImpactGraph.test.ts @@ -85,7 +85,6 @@ function generateExpectedSingleImpactGraph(): IImpactGraph { } ] }, - pathsCount: 1, pathsLimit: RootNode.IMPACT_PATHS_LIMIT }; } @@ -139,7 +138,6 @@ function generateExpectedMultipleImpactGraphs(): IImpactGraph { } ] }, - pathsCount: 4, pathsLimit: RootNode.IMPACT_PATHS_LIMIT }; }