Skip to content

Commit

Permalink
Update webview version to 0.2.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Or-Geva committed Nov 30, 2023
1 parent 692032a commit 387d325
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 34 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions src/main/treeDataProviders/utils/dependencyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/treeDataProviders/utils/yarnImpactGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
22 changes: 6 additions & 16 deletions src/test/tests/dependencyUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -144,7 +134,7 @@ describe('Dependency Utils Tests', () => {

let impactedTree: Map<string, IImpactGraph> = 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;
Expand Down
2 changes: 1 addition & 1 deletion src/test/tests/utils/treeNodeUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 0 additions & 2 deletions src/test/tests/yarnImpactGraph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ function generateExpectedSingleImpactGraph(): IImpactGraph {
}
]
},
pathsCount: 1,
pathsLimit: RootNode.IMPACT_PATHS_LIMIT
};
}
Expand Down Expand Up @@ -139,7 +138,6 @@ function generateExpectedMultipleImpactGraphs(): IImpactGraph {
}
]
},
pathsCount: 4,
pathsLimit: RootNode.IMPACT_PATHS_LIMIT
};
}

0 comments on commit 387d325

Please sign in to comment.