Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
#87
Browse files Browse the repository at this point in the history
  • Loading branch information
4ra1n committed Feb 18, 2023
1 parent d22b9c2 commit f20ee85
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ Others:
- [important] 选择文件时只显示JAR/WAR文件提高效率 #84
- [bug] 应该支持隐藏文件/目录 #85
- [feat] 显示每一个方法和类来自哪一个Jar文件 #86
- [feat] 常见搜索允许自定义补充 #87
- [improve] 限制JAR包大小防止加载过多过大的文件 #83
- 简单优化 UI 界面
- 完善 README 文档
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,15 @@

![](img/006.png)

注意:这里的常见搜索内容可以自定义补充

在当前目录新建`search.txt`文件,一行一个以`#`分割类名和方法,例如

```text
java.lang.Runtime#getRuntime
java.lang.String#equals
```

二进制搜索只会返回是否存在,不会返回具体信息

![](img/004.png)
Expand Down
2 changes: 2 additions & 0 deletions search.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java.lang.Runtime#getRuntime
java.lang.String#equals
47 changes: 37 additions & 10 deletions src/main/java/com/chaitin/jar/analyzer/form/CommonForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@

import javax.swing.*;
import javax.swing.table.DefaultTableModel;

import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

public class CommonForm {
public JPanel commonPanel;
Expand All @@ -21,16 +27,37 @@ public class CommonForm {

static {
a = new String[]{"Class", "Method"};
b = new String[][]{
new String[]{"javax.naming.Context", "lookup"},
new String[]{"java.lang.Runtime", "exec"},
new String[]{"java.lang.ProcessBuilder", "start"},
new String[]{"java.io.ObjectInputStream", "readObject"},
new String[]{"org.springframework.expression.Expression", "getValue"},
new String[]{"org.yaml.snakeyaml.Yaml", "load"},
new String[]{"com.alibaba.fastjson.JSON", "parse"},
new String[]{"java.beans.XMLDecoder", "readObject"}
};
List<String[]> temp = new ArrayList<>();
temp.add(new String[]{"javax.naming.Context", "lookup"});
temp.add(new String[]{"java.lang.Runtime", "exec"});
temp.add(new String[]{"java.lang.ProcessBuilder", "start"});
temp.add(new String[]{"java.io.ObjectInputStream", "readObject"});
temp.add(new String[]{"org.springframework.expression.Expression", "getValue"});
temp.add(new String[]{"org.yaml.snakeyaml.Yaml", "load"});
temp.add(new String[]{"com.alibaba.fastjson.JSON", "parse"});
temp.add(new String[]{"java.beans.XMLDecoder", "readObject"});
Path path = Paths.get("search.txt");
if (Files.exists(path)) {
try {
byte[] data = Files.readAllBytes(path);
String input = new String(data);
String[] sp = input.split("\n");
for (String s : sp) {
s = s.trim();
if (s.equals("")) {
continue;
}
if (s.endsWith("\r")) {
s = s.substring(0, s.length() - 1);
}
String[] k = s.split("#");
String[] r = new String[]{k[0], k[1]};
temp.add(r);
}
} catch (Exception ignored) {
}
}
b = temp.toArray(new String[0][0]);
}

public CommonForm(JarAnalyzerForm instance) {
Expand Down

0 comments on commit f20ee85

Please sign in to comment.