Socket
Socket
Sign inDemoInstall

@snyk/java-call-graph-builder

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@snyk/java-call-graph-builder - npm Package Compare versions

Comparing version 1.12.3 to 1.13.0

dist/errors.d.ts

2

dist/gradle-wrapper.d.ts
import 'source-map-support/register';
export declare function getGradleCommandArgs(targetPath: string): string[];
export declare function getGradleCommand(targetPath: string): string;
export declare function getCallGraphGradle(targetPath: string): Promise<string>;
export declare function getClassPathFromGradle(targetPath: string): Promise<string>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCallGraphGradle = exports.getGradleCommand = exports.getGradleCommandArgs = void 0;
exports.getClassPathFromGradle = exports.getGradleCommand = exports.getGradleCommandArgs = void 0;
const tslib_1 = require("tslib");

@@ -9,2 +9,3 @@ require("source-map-support/register");

const fs = require("fs");
const errors_1 = require("./errors");
function getGradleCommandArgs(targetPath) {

@@ -31,21 +32,16 @@ const gradleArgs = [

exports.getGradleCommand = getGradleCommand;
function runGradleCommand(gradleCommand, gradleCommandArgs, targetPath) {
function getClassPathFromGradle(targetPath) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return sub_process_1.execute('gradle', gradleCommandArgs, { cwd: targetPath });
});
}
function getCallGraphGradle(targetPath) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const gradleCommandArgs = getGradleCommandArgs(targetPath);
const gradleCommand = getGradleCommand(targetPath);
const cmd = getGradleCommand(targetPath);
const args = getGradleCommandArgs(targetPath);
try {
const gradleOutput = yield runGradleCommand(gradleCommand, gradleCommandArgs, targetPath);
return gradleOutput.trim();
const output = yield sub_process_1.execute(cmd, args, { cwd: targetPath });
return output.trim();
}
catch (e) {
throw new Error(`gradle command '${gradleCommand} ${gradleCommandArgs.join(' ')} failed with error: ${e}`);
throw new errors_1.ClassPathGenerationError(e);
}
});
}
exports.getCallGraphGradle = getCallGraphGradle;
exports.getClassPathFromGradle = getClassPathFromGradle;
//# sourceMappingURL=gradle-wrapper.js.map

@@ -10,6 +10,13 @@ "use strict";

const metrics_1 = require("./metrics");
const errors_1 = require("./errors");
function getCallGraphMvn(targetPath, timeout) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const classPath = yield metrics_1.timeIt('getMvnClassPath', () => mvn_wrapper_1.getClassPathFromMvn(targetPath));
return yield metrics_1.timeIt('getCallGraph', () => java_wrapper_1.getCallGraph(classPath, targetPath, timeout));
try {
const classPath = yield metrics_1.timeIt('getMvnClassPath', () => mvn_wrapper_1.getClassPathFromMvn(targetPath));
return yield metrics_1.timeIt('getCallGraph', () => java_wrapper_1.getCallGraph(classPath, targetPath, timeout));
}
catch (e) {
throw new errors_1.CallGraphGenerationError(e.userMessage ||
'Failed to scan for reachable vulnerabilities. Please contact our support or submit an issue at https://github.com/snyk/java-call-graph-builder/issues. Re-running the command with the `-d` flag will provide useful information for the support engineers.', e);
}
});

@@ -20,3 +27,3 @@ }

return tslib_1.__awaiter(this, void 0, void 0, function* () {
const classPath = yield metrics_1.timeIt('getGradleClassPath', () => gradle_wrapper_1.getCallGraphGradle(targetPath));
const classPath = yield metrics_1.timeIt('getGradleClassPath', () => gradle_wrapper_1.getClassPathFromGradle(targetPath));
return yield metrics_1.timeIt('getCallGraph', () => java_wrapper_1.getCallGraph(classPath, targetPath, timeout));

@@ -23,0 +30,0 @@ });

@@ -12,8 +12,8 @@ "use strict";

const call_graph_1 = require("./call-graph");
const promisifedFs = require("./promisified-fs-glob");
const promisified_fs_glob_1 = require("./promisified-fs-glob");
const class_parsing_1 = require("./class-parsing");
const metrics_1 = require("./metrics");
const debug_1 = require("./debug");
const promisifedFs = require("./promisified-fs-glob");
const tempDir = require("temp-dir");
const errors_1 = require("./errors");
function getCallGraphGenCommandArgs(classPath, jarPath, targets) {

@@ -31,11 +31,2 @@ return [

exports.getCallGraphGenCommandArgs = getCallGraphGenCommandArgs;
function runJavaCommand(javaCommandArgs, targetPath, timeout) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
debug_1.debug(`executing java command: "java ${javaCommandArgs.join(' ')}"`);
return sub_process_1.execute('java', javaCommandArgs, {
cwd: targetPath,
timeout,
});
});
}
function getTargets(targetPath) {

@@ -45,3 +36,3 @@ return tslib_1.__awaiter(this, void 0, void 0, function* () {

if (!targetDirs.length) {
throw new Error('Could not find a target folder');
throw new errors_1.MissingTargetFolderError(targetPath);
}

@@ -81,3 +72,6 @@ return targetDirs;

const [javaOutput, classPerJarMapping] = yield Promise.all([
metrics_1.timeIt('generateCallGraph', () => runJavaCommand(callgraphGenCommandArgs, targetPath, timeout)),
metrics_1.timeIt('generateCallGraph', () => sub_process_1.execute('java', callgraphGenCommandArgs, {
cwd: targetPath,
timeout,
})),
metrics_1.timeIt('mapClassesPerJar', () => getClassPerJarMapping(classPath)),

@@ -87,5 +81,2 @@ ]);

}
catch (e) {
throw new Error(`java command 'java ${callgraphGenCommandArgs.join(' ')} failed with error: ${e}`);
}
finally {

@@ -92,0 +83,0 @@ // Fire and forget - we don't have to wait for a deletion of a temporary file

@@ -7,2 +7,3 @@ "use strict";

const sub_process_1 = require("./sub-process");
const errors_1 = require("./errors");
function getMvnCommandArgsForMvnExec(targetPath) {

@@ -22,7 +23,2 @@ return [

}
function runMvnCommand(mvnCommandArgs, targetPath) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
return sub_process_1.execute('mvn', mvnCommandArgs, { cwd: targetPath });
});
}
function parseMvnDependencyPluginCommandOutput(mvnCommandOutput) {

@@ -56,5 +52,4 @@ const outputLines = mvnCommandOutput.split('\n');

return tslib_1.__awaiter(this, void 0, void 0, function* () {
let mvnCommandArgs = [];
let mvnOutput;
let classPaths = [];
let args = [];
try {

@@ -64,5 +59,5 @@ try {

// try `mvn exec` for classpath
mvnCommandArgs = getMvnCommandArgsForMvnExec(targetPath);
mvnOutput = yield runMvnCommand(mvnCommandArgs, targetPath);
classPaths = parseMvnExecCommandOutput(mvnOutput);
args = getMvnCommandArgsForMvnExec(targetPath);
const output = yield sub_process_1.execute('mvn', args, { cwd: targetPath });
classPaths = parseMvnExecCommandOutput(output);
}

@@ -72,11 +67,14 @@ catch (e) {

// TODO send error message for further analysis
mvnCommandArgs = getMvnCommandArgsForDependencyPlugin(targetPath);
mvnOutput = yield runMvnCommand(mvnCommandArgs, targetPath);
classPaths = parseMvnDependencyPluginCommandOutput(mvnOutput);
args = getMvnCommandArgsForDependencyPlugin(targetPath);
const output = yield sub_process_1.execute('mvn', args, { cwd: targetPath });
classPaths = parseMvnDependencyPluginCommandOutput(output);
}
return mergeMvnClassPaths(classPaths);
}
catch (e) {
throw new Error(`mvn command 'mvn ${mvnCommandArgs.join(' ')} failed with error: ${e}`);
throw new errors_1.ClassPathGenerationError(e);
}
if (classPaths.length === 0) {
throw new errors_1.EmptyClassPathError(`mvn ${args.join(' ')}`);
}
return mergeMvnClassPaths(classPaths);
});

@@ -83,0 +81,0 @@ }

@@ -5,2 +5,4 @@ "use strict";

const childProcess = require("child_process");
const debug_1 = require("./debug");
const errors_1 = require("./errors");
function execute(command, args, options) {

@@ -14,9 +16,11 @@ const spawnOptions = { shell: true };

let stderr = '';
debug_1.debug(`executing command: "${command} ${args.join(' ')}"`);
const proc = childProcess.spawn(command, args, spawnOptions);
let timerId = null;
if (options === null || options === void 0 ? void 0 : options.timeout) {
const timeoutSeconds = options.timeout / 1000;
timerId = setTimeout(() => {
proc.kill();
reject(`Timeout; It took longer than ${timeoutSeconds}s to generate the call graph.`);
const err = new errors_1.SubprocessTimeoutError(command, args.join(' '), options.timeout || 0);
debug_1.debug(err.message);
reject(err);
}, options.timeout);

@@ -35,5 +39,7 @@ }

if (code !== 0) {
return reject(stdout || stderr);
const err = new errors_1.SubprocessError(command, args.join(' '), code);
debug_1.debug(err.message);
return reject(err);
}
resolve(stdout || stderr);
resolve(stdout);
});

@@ -40,0 +46,0 @@ });

@@ -10,4 +10,5 @@ {

"lint:eslint": "eslint --color --cache 'lib/**/*.{js,ts}'",
"test": "npm run lint && npm run test:unit",
"test:unit": "jest",
"test": "npm run lint && npm run test:unit && npm run test:integration",
"test:unit": "jest test/lib",
"test:integration": "jest test/integration --runInBand",
"test:coverage": "npm run test:unit -- --coverage",

@@ -70,3 +71,3 @@ "test:watch": "tsc-watch --onSuccess 'npm run test:unit'",

},
"version": "1.12.3"
"version": "1.13.0"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc