Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove reachability #138

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { legacyPlugin } from '@snyk/cli-interface';
import * as javaCallGraphBuilder from '@snyk/java-call-graph-builder';
import * as os from 'os';
import * as fs from 'fs';
import * as path from 'path';
Expand All @@ -13,7 +12,6 @@ import {
isArchive,
} from './archive';
import { formatGenericPluginError } from './error-format';
import { CallGraph, CallGraphResult } from '@snyk/cli-interface/legacy/common';
import debugModule = require('debug');
import { parse } from './parse';

Expand All @@ -35,8 +33,6 @@ export function debug(...messages: string[]) {

export interface MavenOptions extends legacyPlugin.BaseInspectOptions {
scanAllUnmanaged?: boolean;
reachableVulns?: boolean;
callGraphBuilderTimeout?: number;
allProjects?: boolean;
mavenAggregateProject?: boolean;
}
Expand Down Expand Up @@ -183,25 +179,6 @@ export async function inspect(
parseResult = parseTree(result, options.dev);
}
const { javaVersion, mavenVersion } = parseVersions(versionResult);
let callGraph: CallGraphResult | undefined;
let maybeCallGraphMetrics = {};
if (options.reachableVulns) {
// NOTE[muscar] We get the timeout in seconds, and the call graph builder
// wants it in milliseconds
const timeout = options?.callGraphBuilderTimeout
? options?.callGraphBuilderTimeout * 1000
: undefined;

callGraph = await getCallGraph(
targetPath,
timeout, // expects ms
options.args,
);
maybeCallGraphMetrics = {
callGraphMetrics: javaCallGraphBuilder.runtimeMetrics(),
callGraphBuilderTimeoutSeconds: options?.callGraphBuilderTimeout,
};
}
return {
plugin: {
name: 'bundled:maven',
Expand All @@ -213,11 +190,9 @@ export async function inspect(
javaVersion,
},
},
...maybeCallGraphMetrics,
},
},
...parseResult,
callGraph,
};
} catch (err) {
if (result) debug(`>>> Output from mvn: ${result}`);
Expand Down Expand Up @@ -272,27 +247,3 @@ export function buildArgs(

return args;
}

async function getCallGraph(
targetPath: string,
timeout?: number,
customMavenArgs?: string[],
): Promise<CallGraphResult> {
debug(`getting call graph from path ${targetPath}`);
try {
const callGraph: CallGraph = await javaCallGraphBuilder.getCallGraphMvn(
path.dirname(targetPath),
timeout,
customMavenArgs,
);
debug('got call graph successfully');
return callGraph;
} catch (err) {
debug('call graph error: ' + err);
const e = err as { message: string; innerError: Error };
return {
message: e.message,
innerError: e.innerError || e,
};
}
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"dependencies": {
"@snyk/cli-interface": "2.11.3",
"@snyk/dep-graph": "^1.23.1",
"@snyk/java-call-graph-builder": "1.23.6",
"debug": "^4.1.1",
"glob": "^7.1.6",
"needle": "^2.5.0",
Expand Down
33 changes: 0 additions & 33 deletions tests/fixtures/call-graphs/simple.json

This file was deleted.

3 changes: 1 addition & 2 deletions tests/fixtures/jar-wrong-package-name/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@
"plugin": {
"name": "bundled:maven",
"runtime": "unknown"
},
"callGraph": null
}
}
1 change: 0 additions & 1 deletion tests/fixtures/maven-with-mvnw/expected.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"plugin": { "name": "bundled:maven", "runtime": "unknown" },
"callGraph": null,
"package": {
"name": "io.snyk.example:test-project",
"version": "1.0-SNAPSHOT",
Expand Down
1 change: 0 additions & 1 deletion tests/fixtures/path with spaces/expected.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"plugin": { "name": "bundled:maven", "runtime": "unknown" },
"callGraph": null,
"package": {
"name": "io.snyk.example:test-project",
"version": "1.0-SNAPSHOT",
Expand Down
6 changes: 0 additions & 6 deletions tests/fixtures/test-project/expected-with-call-graph.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{
"plugin": { "name": "bundled:maven", "runtime": "unknown" },
"callGraph": {
"options": {
"directed": true,
"multigraph": false,
"compound": false
},
"nodes": [
{
"v": "com.ibm.wala.FakeRootClass:fakeRootMethod",
Expand Down
1 change: 0 additions & 1 deletion tests/fixtures/test-project/expected-with-dev.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"plugin": { "name": "bundled:maven", "runtime": "unknown" },
"callGraph": null,
"package": {
"name": "io.snyk.example:test-project",
"version": "1.0-SNAPSHOT",
Expand Down
1 change: 0 additions & 1 deletion tests/fixtures/test-project/expected.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"plugin": { "name": "bundled:maven", "runtime": "unknown" },
"callGraph": null,
"package": {
"name": "io.snyk.example:test-project",
"version": "1.0-SNAPSHOT",
Expand Down
155 changes: 0 additions & 155 deletions tests/system/plugin-reachable-vulns.test.ts

This file was deleted.