MCPcopy Create free account
hub / github.com/LFYSec/MScan / parseJar

Method parseJar

src/main/java/Starter.java:40–81  ·  view source on GitHub ↗
(String jarDir)

Source from the content-addressed store, hash-verified

38 }
39
40 public static void parseJar(String jarDir) throws IOException {
41 boolean reuse = Config.reuse;
42 Path targetPath = Path.of(Config.targetPath);
43 if (!reuse) {
44 logger.info("[+] removing cache");
45 try (Stream<Path> paths = Files.list(targetPath)) {
46 paths.forEach(path -> {
47 try {
48 if (path.toFile().isDirectory()) {
49 FileUtils.deleteDirectory(path.toFile());
50 } else {
51 FileUtils.delete(path.toFile());
52 }
53 } catch (Exception e) {
54 logger.warn(e);
55 }
56 });
57 } catch (Exception e) {
58 logger.warn(e);
59 }
60 }
61 logger.info("[+] processing jars");
62 List<Path> jars = JarUtil.getJarFiles(Path.of(jarDir));
63 for (Path jar : jars) {
64 // init service discovery
65 ServiceUtil.parseService(jar);
66 // unzip jars to extract classes and lib
67 if (!reuse) {
68 JarUtil.extractJar(jar, targetPath);
69 }
70 }
71 for (Path jar : jars) {
72 ServiceUtil.parseService(jar);
73 }
74 if (!reuse) {
75 logger.info("[+] moving mapper");
76 JarUtil.moveMapper(targetPath);
77 logger.info("[+] moving classes");
78 JarUtil.unsafeMoveClasses(targetPath);
79 }
80 logger.info("[+] starter end");
81 }
82
83}

Callers 1

mainMethod · 0.95

Calls 8

getJarFilesMethod · 0.95
parseServiceMethod · 0.95
extractJarMethod · 0.95
moveMapperMethod · 0.95
unsafeMoveClassesMethod · 0.95
ofMethod · 0.65
forEachMethod · 0.65
deleteMethod · 0.45

Tested by

no test coverage detected