Skip to content

Commit

Permalink
优化 Databoard 数据看板的过滤功能,将过滤规则存储在配置文件中
Browse files Browse the repository at this point in the history
  • Loading branch information
vaycore committed Nov 7, 2023
1 parent 3480796 commit 27098fa
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/java/burp/vaycore/onescan/common/Config.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package burp.vaycore.onescan.common;

import burp.vaycore.common.config.ConfigManager;
import burp.vaycore.common.filter.FilterRule;
import burp.vaycore.common.log.Logger;
import burp.vaycore.common.utils.FileUtils;
import burp.vaycore.common.utils.GsonUtils;
import burp.vaycore.common.utils.PathUtils;
import burp.vaycore.common.utils.StringUtils;
import burp.vaycore.onescan.manager.FpManager;
Expand Down Expand Up @@ -36,6 +38,7 @@ public class Config {
public static final String KEY_HAE_PLUGIN_PATH = "hae-plugin-path";
public static final String KEY_INCLUDE_METHOD = "include-method";
public static final String KEY_WORDLIST_PATH = "dict-path";
public static final String KEY_DATABOARD_FILTER_RULES = "databoard-filter-rules";
// 首页开关配置项
public static final String KEY_ENABLE_LISTEN_PROXY = "enable-listen-proxy";
public static final String KEY_ENABLE_EXCLUDE_HEADER = "enable-exclude-header";
Expand Down Expand Up @@ -212,6 +215,7 @@ private static void upgradePayloadProcessing(String version) {

private static void onPreloadConfig() {
preparePayloadProcessList();
prepareDataboardFilterRules();
}

private static void initDefaultConfig(String key, String defValue) {
Expand Down Expand Up @@ -339,8 +343,23 @@ private static ArrayList<PayloadItem> mapItemsConvert(ArrayList<LinkedTreeMap<St
return result;
}

private static void prepareDataboardFilterRules() {
Object obj = sConfigManager.get(Config.KEY_DATABOARD_FILTER_RULES);
if (obj == null) {
obj = new ArrayList<>();
}
String json = GsonUtils.toJson(obj);
ArrayList<FilterRule> rules = GsonUtils.toList(json, FilterRule.class);
put(Config.KEY_DATABOARD_FILTER_RULES, rules);
}

public static ArrayList<ProcessingItem> getPayloadProcessList() {
checkInit();
return sConfigManager.get(Config.KEY_PAYLOAD_PROCESS_LIST);
}

public static ArrayList<FilterRule> getDataboardFilterRules() {
checkInit();
return sConfigManager.get(Config.KEY_DATABOARD_FILTER_RULES);
}
}
21 changes: 21 additions & 0 deletions src/main/java/burp/vaycore/onescan/ui/tab/DataBoardTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,25 @@ public void init(Component requestTextEditor, Component responseTextEditor) {
mainSplitPanel.add(dataSplitPanel, JSplitPane.RIGHT);
// 将布局进行展示
add(mainSplitPanel, "100%");
// 加载过滤规则
loadFilterRules();
}

/**
* 从配置文件中加载过滤规则
*/
private void loadFilterRules() {
ArrayList<FilterRule> rules = Config.getDataboardFilterRules();
if (rules == null || rules.isEmpty()) {
return;
}
// 借助 TableFilterPanel 组件转换配置
TableFilterPanel panel = new TableFilterPanel(TaskTable.TaskTableModel.COLUMN_NAMES, rules);
ArrayList<TableFilter<AbstractTableModel>> filters = panel.exportTableFilters();
String rulesText = panel.exportRulesText();
mTaskTable.setRowFilter(RowFilter.andFilter(filters));
mFilterRuleText.setText(rulesText);
mLastFilters = rules;
}

private JCheckBox newJCheckBox(JPanel panel, String text, String configKey) {
Expand Down Expand Up @@ -238,13 +257,15 @@ public void onConfirm(ArrayList<FilterRule> filterRules, ArrayList<TableFilter<A
mTaskTable.setRowFilter(RowFilter.andFilter(filters));
mFilterRuleText.setText(rulesText);
mLastFilters = filterRules;
Config.put(Config.KEY_DATABOARD_FILTER_RULES, filterRules);
}

@Override
public void onReset() {
mTaskTable.setRowFilter(null);
mFilterRuleText.setText("");
mLastFilters = null;
Config.put(Config.KEY_DATABOARD_FILTER_RULES, new ArrayList<>());
}
});
}
Expand Down

0 comments on commit 27098fa

Please sign in to comment.