Skip to content

Commit 8830384

Browse files
committed
Support BurpSuite 2 dark theme, reflections bugfix
1 parent 7c3f627 commit 8830384

File tree

8 files changed

+213
-80
lines changed

8 files changed

+213
-80
lines changed

src/hvqzao/flow/FlowExtension.java

Lines changed: 106 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Flow Burp Extension, (c) 2015-2017 Marcin Woloszyn (@hvqzao), Released under MIT license
1+
// Flow Burp Extension, (c) 2015-2019 Marcin Woloszyn (@hvqzao), Released under MIT license
22
package hvqzao.flow;
33

44
import hvqzao.flow.ui.DialogWrapper;
@@ -61,7 +61,7 @@
6161
import burp.IScopeChangeListener;
6262
import burp.ITab;
6363
import hvqzao.flow.ui.BooleanTableCellRenderer;
64-
import static hvqzao.flow.ui.Helper.cellBackground;
64+
import hvqzao.flow.ui.ThemeHelper;
6565
import java.awt.Dialog;
6666
import java.io.PrintWriter;
6767
import java.util.List;
@@ -77,7 +77,11 @@
7777

7878
public class FlowExtension implements IBurpExtender, ITab, IHttpListener, IScopeChangeListener, IExtensionStateListener {
7979

80-
private final String version = "Flow v1.23 (2018-04-16) (unreleased)";
80+
private final String version = "Flow v1.24 (2019-05-20)";
81+
// Changes in v1.24:
82+
// - rows coloring is now disabled on dark theme
83+
// - reflections count display limit introduced
84+
//
8185
// Changes in v1.23:
8286
// - Center "Add new sitemap issue" dialog, resize according to preferred size
8387
// - Filter by search term does not break window anymore when search is too long
@@ -176,9 +180,15 @@ public class FlowExtension implements IBurpExtender, ITab, IHttpListener, IScope
176180
private boolean autoDelete = false;
177181
private int autoDeleteKeep = 1000;
178182
private boolean autoPopulate = false;
183+
private boolean showReflections = true;
184+
private int showReflectionsCount;
185+
private final int showReflectionsCountMax = 50;
186+
private final int showReflectionsCountDefault = 10;
179187
private boolean modalAutoPopulate;
180188
private boolean modalAutoDelete;
181189
private int modalAutoDeleteKeep;
190+
private boolean modalShowReflections;
191+
private int modalShowReflectionsCount;
182192
private static PrintWriter stderr;
183193
private FilterWorker flowFilterWorker;
184194
private static int sortOrder;
@@ -206,7 +216,7 @@ public void run() {
206216
ImageIcon iconNewWindow = new ImageIcon(new ImageIcon(getClass().getResource("/hvqzao/flow/resources/newwindow.png")).getImage().getScaledInstance(13, 13, java.awt.Image.SCALE_SMOOTH));
207217
ImageIcon iconCheckbox = new ImageIcon(new ImageIcon(getClass().getResource("/hvqzao/flow/resources/checkbox.png")).getImage().getScaledInstance(13, 13, java.awt.Image.SCALE_SMOOTH));
208218
Dimension iconDimension = new Dimension(24, 24);
209-
219+
210220
// flow tab prolog: vertical split
211221
flowTab = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
212222
callbacks.customizeUiComponent(flowTab);
@@ -723,6 +733,14 @@ public void actionPerformed(ActionEvent e) {
723733
flowTableSorter.sort();
724734
}
725735
}
736+
if (showReflections != modalShowReflections) {
737+
showReflections = modalShowReflections;
738+
callbacks.saveExtensionSetting("showReflections", showReflections ? "1" : "0");
739+
}
740+
if (showReflectionsCount != modalShowReflectionsCount) {
741+
showReflectionsCount = modalShowReflectionsCount;
742+
callbacks.saveExtensionSetting("showReflectionsCount", String.valueOf(showReflectionsCount));
743+
}
726744
}
727745
}
728746
});
@@ -742,6 +760,8 @@ public void actionPerformed(ActionEvent e) {
742760
autoPopulate = "1".equals(callbacks.loadExtensionSetting("autoPopulateProxy"));
743761
autoDeleteKeep = validateAutoDeleteKeep(callbacks.loadExtensionSetting("autoDeleteKeep"));
744762
autoDelete = "1".equals(callbacks.loadExtensionSetting("autoDelete"));
763+
showReflections = "0".equals(callbacks.loadExtensionSetting("showReflections")) == false;
764+
showReflectionsCount = parseReflectionsCount(callbacks.loadExtensionSetting("showReflectionsCount"));
745765
//
746766

747767
//
@@ -751,6 +771,14 @@ public void actionPerformed(ActionEvent e) {
751771
//callbacks.printOutput("Initializing extension with contents of Burp Proxy...");
752772
(new PopulateWorker(callbacks.getProxyHistory())).execute();
753773
}
774+
775+
//Set<Map.Entry<Object, Object>> entries = UIManager.getLookAndFeelDefaults().entrySet();
776+
//for (Map.Entry<Object, Object> entry : entries) {
777+
// if (entry.getValue() instanceof Color) {
778+
// stderr.println(String.valueOf(entry.getKey()) + "\t" + String.valueOf(UIManager.getColor(entry.getKey())) + "\t" + String.valueOf(entry.getValue()));
779+
// }
780+
//}
781+
754782
//callbacks.printOutput("Loaded.");
755783
// TODO end main
756784
}
@@ -1033,7 +1061,7 @@ private boolean showOptionsDialog() {
10331061
//
10341062
// wrap optionsPane
10351063
wrapper.getScrollPane().getViewport().add(optionsPane);
1036-
dialog.setBounds(100, 100, 526, 420);
1064+
dialog.setBounds(100, 100, 526, 500);
10371065
dialog.setContentPane(wrapper);
10381066
//
10391067
modalResult = false;
@@ -1043,6 +1071,8 @@ private boolean showOptionsDialog() {
10431071
optionsPane.getAutoPopulate().setSelected(autoPopulate);
10441072
optionsPane.getAutoDelete().setSelected(autoDelete);
10451073
optionsPane.getAutoDeleteKeep().setText(String.valueOf(autoDeleteKeep));
1074+
optionsPane.getShowReflections().setSelected(showReflections);
1075+
optionsPane.getShowReflectionsCount().setText(String.valueOf(showReflectionsCount));
10461076
//
10471077
JButton ok = wrapper.getOkButton();
10481078
callbacks.customizeUiComponent(ok);
@@ -1054,6 +1084,8 @@ public void actionPerformed(ActionEvent e) {
10541084
modalAutoPopulate = optionsPane.getAutoPopulate().isSelected();
10551085
modalAutoDelete = optionsPane.getAutoDelete().isSelected();
10561086
modalAutoDeleteKeep = validateAutoDeleteKeep(optionsPane.getAutoDeleteKeep().getText());
1087+
modalShowReflections = optionsPane.getShowReflections().isSelected();
1088+
modalShowReflectionsCount = parseReflectionsCount(optionsPane.getShowReflectionsCount().getText());
10571089
dialog.dispose();
10581090
}
10591091
});
@@ -2399,44 +2431,62 @@ protected void setValue(Object value) {
23992431
@Override
24002432
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
24012433
final Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
2402-
// c.setBackground(row % 2 == 0 ? Color.LIGHT_GRAY : Color.WHITE);
2403-
//if (!isSelected && tempy != null && flowTable.convertRowIndexToModel(row) == flow.indexOf(tempy)) {
2404-
// c.setForeground(Color.blue);
2405-
//} else {
2406-
// c.setForeground(Color.black);
2407-
//}
24082434
int modelRow = table.convertRowIndexToModel(row);
24092435
FlowEntry entry = flow.get(modelRow);
2410-
int r = 0, g = 0, b = 0;
2411-
if (entry.status == 404 || entry.status == 403) {
2412-
r += 196;
2413-
g += 128;
2414-
b += 128;
2415-
}
2416-
if (entry.status == 500) {
2417-
g += 196;
2418-
}
2419-
if (entry.toolFlag != IBurpExtenderCallbacks.TOOL_PROXY) {
2420-
b += 196;
2421-
}
2422-
if (r > 255) {
2423-
r = 255;
2424-
}
2425-
if (g > 255) {
2426-
g = 255;
2427-
}
2428-
if (b > 255) {
2429-
b = 255;
2430-
}
2431-
c.setForeground(new Color(r, g, b));
2436+
if (ThemeHelper.isDarkTheme() == false) {
2437+
// c.setBackground(row % 2 == 0 ? Color.LIGHT_GRAY : Color.WHITE);
2438+
//if (!isSelected && tempy != null && flowTable.convertRowIndexToModel(row) == flow.indexOf(tempy)) {
2439+
// c.setForeground(Color.blue);
2440+
//} else {
2441+
// c.setForeground(Color.black);
2442+
//}
2443+
int r = 0, g = 0, b = 0;
2444+
if (entry.status == 404 || entry.status == 403) {
2445+
r += 196;
2446+
g += 128;
2447+
b += 128;
2448+
}
2449+
if (entry.status == 500) {
2450+
g += 196;
2451+
}
2452+
if (entry.toolFlag != IBurpExtenderCallbacks.TOOL_PROXY) {
2453+
b += 196;
2454+
}
2455+
if (r > 255) {
2456+
r = 255;
2457+
}
2458+
if (g > 255) {
2459+
g = 255;
2460+
}
2461+
if (b > 255) {
2462+
b = 255;
2463+
}
2464+
c.setForeground(new Color(r, g, b));
24322465

2433-
c.setBackground(cellBackground(table.getRowCount(), row, isSelected));
2466+
c.setBackground(ThemeHelper.cellBackground(table.getRowCount(), row, isSelected));
2467+
}
24342468

24352469
final ArrayList<String> reflections = new ArrayList<>();
2436-
for (IParameter reflection : entry.getReflections()) {
2437-
reflections.add(new StringBuilder(" &nbsp; &nbsp; (").append(paramType(reflection.getType())).append(") ").append(reflection.getName()).append("=").append(reflection.getValue()).toString());
2438-
}
2439-
if (reflections.size() > 0) {
2470+
final ArrayList<IParameter> allReflections = entry.getReflections();
2471+
int reflectionsAmount = allReflections.size();
2472+
if (reflectionsAmount > showReflectionsCount) {
2473+
reflectionsAmount = showReflectionsCount;
2474+
}
2475+
if (allReflections.size() > 0) {
2476+
for (IParameter reflection : allReflections.subList(0, reflectionsAmount)) {
2477+
String param = reflection.getName();
2478+
if (param.length() > 50) {
2479+
param = param.substring(0, 50 - 3) + "...";
2480+
}
2481+
String val = reflection.getValue();
2482+
if (val.length() > 50) {
2483+
val = val.substring(0, 50 - 3) + "...";
2484+
}
2485+
reflections.add(new StringBuilder(" &nbsp; &nbsp; (").append(paramType(reflection.getType())).append(") ").append(param).append("=").append(val).toString());
2486+
}
2487+
if (allReflections.size() > showReflectionsCount) {
2488+
reflections.add("...");
2489+
}
24402490
((JLabel) c).setToolTipText(new StringBuilder("<html>Reflections:<br/>").append(String.join("<br/>", reflections)).append("</html>").toString());
24412491
} else {
24422492
((JLabel) c).setToolTipText(null);
@@ -2501,4 +2551,22 @@ public static FlowExtension getInstance() {
25012551
public static PrintWriter getStderr() {
25022552
return stderr;
25032553
}
2554+
2555+
private int parseReflectionsCount(String text) {
2556+
int result = showReflectionsCountDefault;
2557+
if (text != null) {
2558+
try {
2559+
showReflectionsCount = Integer.parseInt(text);
2560+
if (showReflectionsCount > showReflectionsCountMax) {
2561+
showReflectionsCount = showReflectionsCountMax;
2562+
}
2563+
if (showReflectionsCount < 0) {
2564+
showReflectionsCount = 0;
2565+
}
2566+
} catch (NumberFormatException ex) {
2567+
// do nothing
2568+
}
2569+
}
2570+
return result;
2571+
}
25042572
}

src/hvqzao/flow/FlowFilterPopup.form

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<CompoundBorder>
88
<Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
99
<LineBorder thickness="2">
10-
<Color PropertyName="color" blue="ff" green="ff" id="white" palette="1" red="ff" type="palette"/>
10+
<Color PropertyName="color" blue="ff" green="ff" id="Table.background" palette="3" red="ff" type="palette"/>
1111
</LineBorder>
1212
</Border>
1313
<Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo">

src/hvqzao/flow/FlowFilterPopup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ private void initComponents() {
297297
FlowFilterCaptureSourceProxyOnly = new javax.swing.JCheckBox();
298298
FlowFilterBottom = new javax.swing.JPanel();
299299

300-
setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.white, 2), javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.darkGray), javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5))));
300+
setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Table.background"), 2), javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.darkGray), javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5))));
301301

302302
flowFilterHelp.setMargin(new java.awt.Insets(0, 0, 0, 0));
303303
flowFilterHelp.setMaximumSize(new java.awt.Dimension(24, 24));

src/hvqzao/flow/FlowOptionsPane.form

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
<Group type="102" attributes="0">
4545
<EmptySpace min="21" pref="21" max="-2" attributes="0"/>
4646
<Group type="103" groupAlignment="0" attributes="0">
47-
<Component id="jLabel2" pref="0" max="32767" attributes="0"/>
48-
<Component id="jLabel3" pref="308" max="32767" attributes="0"/>
47+
<Component id="jLabel2" pref="341" max="32767" attributes="0"/>
48+
<Component id="jLabel3" pref="341" max="32767" attributes="0"/>
4949
</Group>
5050
</Group>
5151
</Group>
@@ -56,13 +56,18 @@
5656
<Group type="103" groupAlignment="0" attributes="0">
5757
<Group type="102" alignment="0" attributes="0">
5858
<Component id="autoDelete" min="-2" max="-2" attributes="0"/>
59-
<EmptySpace max="-2" attributes="0"/>
59+
<EmptySpace type="unrelated" max="-2" attributes="0"/>
6060
<Component id="autoDeleteKeep" min="-2" pref="40" max="-2" attributes="0"/>
6161
</Group>
6262
<Component id="autoPopulate" alignment="0" min="-2" max="-2" attributes="0"/>
6363
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
64+
<Group type="102" alignment="0" attributes="0">
65+
<Component id="showReflections" min="-2" max="-2" attributes="0"/>
66+
<EmptySpace max="-2" attributes="0"/>
67+
<Component id="showReflectionsCount" min="-2" pref="32" max="-2" attributes="0"/>
68+
</Group>
6469
</Group>
65-
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
70+
<EmptySpace min="0" pref="81" max="32767" attributes="0"/>
6671
</Group>
6772
</Group>
6873
</Group>
@@ -94,13 +99,18 @@
9499
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
95100
</Group>
96101
<EmptySpace type="unrelated" max="-2" attributes="0"/>
102+
<Group type="103" groupAlignment="3" attributes="0">
103+
<Component id="showReflections" alignment="3" min="-2" max="-2" attributes="0"/>
104+
<Component id="showReflectionsCount" alignment="3" min="-2" max="-2" attributes="0"/>
105+
</Group>
106+
<EmptySpace max="-2" attributes="0"/>
97107
<Component id="autoPopulate" min="-2" max="-2" attributes="0"/>
98108
<EmptySpace max="-2" attributes="0"/>
99109
<Group type="103" groupAlignment="3" attributes="0">
100110
<Component id="autoDelete" alignment="3" min="-2" max="-2" attributes="0"/>
101111
<Component id="autoDeleteKeep" alignment="3" min="-2" max="-2" attributes="0"/>
102112
</Group>
103-
<EmptySpace pref="12" max="32767" attributes="0"/>
113+
<EmptySpace max="32767" attributes="0"/>
104114
</Group>
105115
</Group>
106116
</DimensionLayout>
@@ -194,5 +204,15 @@
194204
<Property name="text" type="java.lang.String" value="Populate with requests from Proxy history"/>
195205
</Properties>
196206
</Component>
207+
<Component class="javax.swing.JCheckBox" name="showReflections">
208+
<Properties>
209+
<Property name="text" type="java.lang.String" value="Show parameter reflections. Count:"/>
210+
</Properties>
211+
</Component>
212+
<Component class="javax.swing.JTextField" name="showReflectionsCount">
213+
<Properties>
214+
<Property name="text" type="java.lang.String" value="10"/>
215+
</Properties>
216+
</Component>
197217
</SubComponents>
198218
</Form>

0 commit comments

Comments
 (0)