@@ -33,19 +33,19 @@ public class Jbom implements Runnable {
3333 @ CommandLine .Option (names = { "-h" , "--host" }, description = "Hostname or IP address to connect to" )
3434 private String host = null ;
3535
36- @ CommandLine .Option (names = { "-u " , "--user" }, description = "Username of user to connect as" )
36+ @ CommandLine .Option (names = { "-U " , "--user" }, description = "Username of user to connect as" )
3737 private String user ;
3838
39- @ CommandLine .Option (names = { "-p " , "--pass " }, description = "Password for user" )
39+ @ CommandLine .Option (names = { "-P " , "--password " }, description = "Password for user" )
4040 private String pass ;
4141
4242 @ CommandLine .Option (names = { "-r" , "--remote" }, defaultValue = "/tmp/jbom" , description = "Remote directory to use" )
4343 private String remoteDir = "/tmp/jbom" ;
4444
45- @ CommandLine .Option (names = { "-j " , "--jvmpid " }, defaultValue = "all" , description = "JVM PID to attach to or 'all'" )
45+ @ CommandLine .Option (names = { "-p " , "--pid " }, defaultValue = "all" , description = "Java process pid to attach to or 'all'" )
4646 private String pid = "all" ;
4747
48- @ CommandLine .Option (names = { "-x" , "--exclude" }, description = "JVM PID to exclude" )
48+ @ CommandLine .Option (names = { "-x" , "--exclude" }, description = "Java process pid to exclude" )
4949 private String exclude ;
5050
5151 @ CommandLine .Option (names = { "-f" , "--file" }, description = "File to be scanned" )
@@ -60,6 +60,9 @@ public class Jbom implements Runnable {
6060 @ CommandLine .Option (names = { "-t" , "--tag" }, description = "Tag to use in output filenames" )
6161 private String tag ;
6262
63+ @ CommandLine .Option (names = { "-D" , "--debug" }, description = "Enable debug output" )
64+ private boolean debug = false ;
65+
6366
6467 public static void main (String [] args ){
6568 int exitCode = new CommandLine (new Jbom ()).execute (args );
@@ -71,6 +74,7 @@ public void run() {
7174
7275 Jbom jbom = new Jbom ();
7376 jbom .printBanner ();
77+ Logger .setDebug ( debug );
7478
7579 // remote
7680 if ( host != null ) {
@@ -131,7 +135,7 @@ public void doLocalProcess(String pid, String exclude, String outputDir, String
131135 }
132136 } else {
133137 Logger .log ( "Analyzing local Java process with pid " + pid );
134- String name = outputDir + "/jbom- " + ( tag == null ? "" : "-" +tag ) + "-" + pid + ".json" ;
138+ String name = outputDir + "/jbom" + ( tag == null ? "" : "-" +tag ) + "-" + pid + ".json" ;
135139 generateBOM ( pid , name );
136140 }
137141 }
@@ -152,7 +156,15 @@ public Libraries doLocalFile(String file, String outputDir) {
152156 }
153157
154158 try {
155- String name = file .substring ( 0 , file .lastIndexOf ('.' ));
159+ String name = file ;
160+ int idx = name .lastIndexOf ('/' );
161+ if ( idx != -1 ) {
162+ name = name .substring ( idx + 1 );
163+ }
164+ idx = name .lastIndexOf ('.' );
165+ if ( idx != -1 ) {
166+ name = name .substring ( 0 , idx );
167+ }
156168 name = outputDir + "/jbom-" + name + ( tag == null ? "" : "-" +tag ) + ".json" ;
157169 libs .runScan ( f );
158170 libs .save (name );
@@ -209,7 +221,7 @@ public void doRemoteDirectory(String dir, String outputDir, String host, String
209221
210222 // 2. run java -jar jbom.jar on remote server
211223 Logger .log ( "Connecting to " + host );
212- remote .exec ( "java -jar " + agentFile .getAbsolutePath () + " -d " + dir + " -o " + remoteDir + " -p " + tag );
224+ remote .exec ( "java -jar " + agentFile .getAbsolutePath () + " -d " + dir + " -o " + remoteDir + " -p " + tag + ( debug ? " -D" : "" ) );
213225
214226 // 3. download results and cleanup
215227 File odir = new File ( outputDir );
@@ -268,7 +280,7 @@ public void doRemoteProcess(String pid, String exclude, String outputDir, String
268280 // 2. run java -jar jbom.jar on remote server
269281 Logger .log ( "Connecting to " + host );
270282 String myPid = ByteBuddyAgent .ProcessProvider .ForCurrentVm .INSTANCE .resolve ();
271- remote .exec ( "java -jar " + agentFile .getAbsolutePath () + " -x " + myPid + " -o " + remoteDir + " -p " + tag );
283+ remote .exec ( "java -jar " + agentFile .getAbsolutePath () + " -x " + myPid + " -o " + remoteDir + " -p " + tag + ( debug ? " -D" : "" ) );
272284
273285 // 3. download results and cleanup
274286 File odir = new File ( outputDir );
0 commit comments