Skip to content

Commit

Permalink
feat: pass gradle util to java call graph builder
Browse files Browse the repository at this point in the history
We want to make sure that the right gradle util is being
used within the java call graph builder to allow gradle
sub projects to use the correct gradlew, which can be
found in the root of the project.

For more context go to
snyk/java-call-graph-builder#42
  • Loading branch information
Dar Malovani committed Dec 10, 2020
1 parent cc4489d commit 61805d6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ export async function inspect(
let callGraph: CallGraph | undefined;
const targetPath = path.join(root, targetFile);
if (options.reachableVulns) {
const command = getCommand(root, targetFile);
debugLog(`getting call graph from path ${targetPath}`);
callGraph = await javaCallGraphBuilder.getCallGraphGradle(
path.dirname(targetPath),
command,
);
debugLog('got call graph successfully');
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"dependencies": {
"@snyk/cli-interface": "2.9.1",
"@snyk/dep-graph": "^1.19.4",
"@snyk/java-call-graph-builder": "1.16.2",
"@snyk/java-call-graph-builder": "1.18.0",
"@types/debug": "^4.1.4",
"chalk": "^3.0.0",
"debug": "^4.1.1",
Expand Down
5 changes: 4 additions & 1 deletion test/system/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ test('run inspect() with reachableVulns', async (t) => {
);
t.ok(javaCallGraphBuilderStub.calledOnce, 'called to the call graph builder');
t.ok(
javaCallGraphBuilderStub.calledWith(path.join('.', rootNoWrapper)),
javaCallGraphBuilderStub.calledWith(
path.join('.', rootNoWrapper),
'gradle',
),
'call graph builder was called with the correct path',
);
t.same(gradleCallGraph, result.callGraph, 'returns expected callgraph');
Expand Down

0 comments on commit 61805d6

Please sign in to comment.