Skip to content

Commit

Permalink
Column refactoring enabled, row background behaviour updated, minor r…
Browse files Browse the repository at this point in the history
…efactoring, added req & resp in Add New Sitemap Issue
  • Loading branch information
hvqzao committed Nov 15, 2017
1 parent 8b19a50 commit c7b5236
Show file tree
Hide file tree
Showing 9 changed files with 687 additions and 349 deletions.
576 changes: 373 additions & 203 deletions src/hvqzao/flow/FlowAddNewIssue.form

Large diffs are not rendered by default.

292 changes: 216 additions & 76 deletions src/hvqzao/flow/FlowAddNewIssue.java

Large diffs are not rendered by default.

94 changes: 28 additions & 66 deletions src/hvqzao/flow/FlowExtension.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Flow Burp Extension, (c) 2015-2017 Marcin Woloszyn (@hvqzao), Released under MIT license
package hvqzao.flow;

import hvqzao.flow.ui.DialogWrapper;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
Expand Down Expand Up @@ -43,7 +42,6 @@
import javax.swing.SwingUtilities;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
Expand All @@ -62,6 +60,8 @@
import burp.IResponseInfo;
import burp.IScopeChangeListener;
import burp.ITab;
import hvqzao.flow.ui.BooleanTableCellRenderer;
import static hvqzao.flow.ui.Helper.cellBackground;
import java.awt.Dialog;
import java.io.PrintWriter;
import java.util.List;
Expand All @@ -76,10 +76,12 @@

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

private final String version = "Flow v1.20 (2017-11-03)";
// Changes in v1.20:
// - Added notification when search filter is working
// - FIX: Pattern.compile inside loop
private final String version = "Flow v1.21 (2017-11-15)";
// Changes in v1.21:
// - Column reordering enabled
// - Updated row background highlight behavior
// - Added request and response preview in Add New Sitemap Issue
// - Minor refactoring
//
//private final String versionFull = "<html>" + version + ", <a href=\"https://github.com/hvqzao/burp-flow\">https://github.com/hvqzao/burp-flow</a>, MIT license</html>";
private static IBurpExtenderCallbacks callbacks;
Expand Down Expand Up @@ -162,11 +164,8 @@ public class FlowExtension implements IBurpExtender, ITab, IHttpListener, IScope
// version };
// private int adIndex = 0;
// private JLabel flowFilterAd;
private SeparateView separateView;
private SeparateViewDialog separateView;
private JButton flowFilterHelpExt;
private static final Color COLOR_HIGHLIGHT = new Color(255, 206, 130);
private static final Color COLOR_DARKGRAY = new Color(240, 240, 240);
private static final Color COLOR_LIGHTGRAY = new Color(250, 250, 250);
private ImageIcon iconHelp;
private boolean modalResult;
private int modalMode;
Expand All @@ -182,9 +181,11 @@ public class FlowExtension implements IBurpExtender, ITab, IHttpListener, IScope
private FilterWorker flowFilterWorker;
private static int sortOrder;
private String flowFilterText = "";
private static FlowExtension instance;

@Override
public void registerExtenderCallbacks(final IBurpExtenderCallbacks callbacks) {
instance = this;
FlowExtension.callbacks = callbacks;
helpers = callbacks.getHelpers();
stderr = new PrintWriter(callbacks.getStderr(), true);
Expand Down Expand Up @@ -586,7 +587,7 @@ public void mouseReleased(MouseEvent e) {
@Override
public void run() {
if (separateView == null) {
separateView = new SeparateView(burpFrame, "Flow");
separateView = new SeparateViewDialog(burpFrame, "Flow");
}
}
});
Expand All @@ -599,8 +600,7 @@ public void run() {
flowTableSorter = new TableRowSorter<>(flowTableModel);
flowTable = new FlowTable(flowTableModel);
flowTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
// flowTable.getTableHeader().setReorderingAllowed(true);
// flowTable.setAutoCreateRowSorter(true);
//flowTable.setAutoCreateRowSorter(true);
flowTable.setRowSorter(flowTableSorter);
for (int i = 0; i < flowTableModel.getColumnCount(); i++) {
TableColumn column = flowTable.getColumnModel().getColumn(i);
Expand Down Expand Up @@ -631,6 +631,7 @@ public void sorterChanged(RowSorterEvent e) {
flowTableScroll.setMinimumSize(new Dimension(40, 40));
callbacks.customizeUiComponent(flowTableScroll);
flowTable.setDefaultRenderer(Boolean.class, new BooleanTableCellRenderer());
flowTable.getTableHeader().setReorderingAllowed(true);
// flowTab.setTopComponent(flowTableScroll);
flowTablePane.add(flowTableScroll, BorderLayout.CENTER);
flowTab.setTopComponent(flowTablePane);
Expand Down Expand Up @@ -946,7 +947,7 @@ private int validateAutoDeleteKeep(String number) {
private boolean showAddNewIssueDialog() {
final JDialog dialog = new JDialog(burpFrame, "Add New Sitemap Issue", Dialog.ModalityType.DOCUMENT_MODAL);
DialogWrapper wrapper = new DialogWrapper();
final FlowAddNewIssue addNewIssue = new FlowAddNewIssue(callbacks);
final FlowAddNewIssue addNewIssue = new FlowAddNewIssue(callbacks, popupPointedFlowEntry);
// customize options pane
JButton help = addNewIssue.getHelpButton();
help.setIcon(iconHelp);
Expand All @@ -955,7 +956,7 @@ private boolean showAddNewIssueDialog() {
//
// wrap optionsPane
wrapper.getScrollPane().getViewport().add(addNewIssue);
dialog.setBounds(100, 100, 526, 670);
dialog.setBounds(100, 100, 920, 670);
dialog.setContentPane(wrapper);
//
modalResult = false;
Expand All @@ -975,7 +976,7 @@ public void actionPerformed(ActionEvent e) {
//for (int i=0 ; i < rows.length ; i++) {
// selected[i] = flow.get(rows[i]);
//}
callbacks.addScanIssue(addNewIssue.getIssue(popupPointedFlowEntry));
callbacks.addScanIssue(addNewIssue.getIssue());
dialog.dispose();
}
});
Expand All @@ -996,7 +997,7 @@ public void actionPerformed(ActionEvent e) {
private boolean showOptionsDialog() {
final JDialog dialog = new JDialog(burpFrame, "Flow Extension Options", Dialog.ModalityType.DOCUMENT_MODAL);
DialogWrapper wrapper = new DialogWrapper();
final FlowFilterPane optionsPane = new FlowFilterPane(callbacks);
final FlowOptionsPane optionsPane = new FlowOptionsPane(callbacks);
// customize options pane
JButton modeHelp = optionsPane.getModeHelp();
modeHelp.setIcon(iconHelp);
Expand Down Expand Up @@ -1048,23 +1049,7 @@ public void actionPerformed(ActionEvent e) {
return modalResult;
}

static Color cellBackground(int rowCount, int row, boolean isSelected) {
int r = row;
if (sortOrder == -1) {
r = rowCount - row;
}
if (isSelected) {
return COLOR_HIGHLIGHT;
} else if (r % 20 == 1) {
return COLOR_DARKGRAY; // new Color(225, 225, 225);
} else if (r % 2 == 1) {
return COLOR_LIGHTGRAY; // new Color(240, 240, 240);
} else {
return Color.WHITE;
}
}

void flowFilterCaptureSourceOnly(JCheckBox which) {
private void flowFilterCaptureSourceOnly(JCheckBox which) {

if (which != flowFilterCaptureSourceTargetOnly && flowFilterCaptureSourceTargetOnly.isSelected()) {
flowFilterCaptureSourceTargetOnly.setSelected(false);
Expand Down Expand Up @@ -2421,10 +2406,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole

}

//
// SeparateView
//
public class SeparateView extends JDialog {
public class SeparateViewDialog extends JDialog {

private final Component parent;
private final String title;
Expand All @@ -2446,7 +2428,7 @@ public void dispose() {
super.dispose();
}

public SeparateView(final Component parent, String title) {
public SeparateViewDialog(final Component parent, String title) {
flowFilterHelpExt.setEnabled(false);
flowComponent.remove(flowTab);
flowComponent.revalidate();
Expand All @@ -2467,31 +2449,11 @@ private void initialize() {
}
}

private static class BooleanTableCellRenderer extends JCheckBox implements TableCellRenderer {

public BooleanTableCellRenderer() {
super();
initialize();
}

private void initialize() {
setOpaque(true);
putClientProperty("JComponent.sizeVariant", "small");
SwingUtilities.updateComponentTreeUI(this);
setLayout(new GridBagLayout());
setMargin(new Insets(0, 0, 0, 0));
setHorizontalAlignment(JLabel.CENTER);
setBorderPainted(true);
}

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
//int modelRow = table.convertRowIndexToModel(row);
setBackground(cellBackground(table.getRowCount(), row, isSelected));
if (value instanceof Boolean) {
setSelected((Boolean) value);
}
return this;
}
public static int getSortOrder() {
return sortOrder;
}

public static FlowExtension getInstance() {
return instance;
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import javax.swing.JRadioButton;
import javax.swing.JTextField;

public class FlowFilterPane extends javax.swing.JPanel {
public class FlowOptionsPane extends javax.swing.JPanel {

/**
* Creates new form FlowFilterOptions
*/
public FlowFilterPane() {
public FlowOptionsPane() {
initComponents();
}

public FlowFilterPane(IBurpExtenderCallbacks callbacks) {
public FlowOptionsPane(IBurpExtenderCallbacks callbacks) {
initComponents();
callbacks.customizeUiComponent(Mode2);
callbacks.customizeUiComponent(Mode1);
Expand Down
39 changes: 39 additions & 0 deletions src/hvqzao/flow/ui/BooleanTableCellRenderer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package hvqzao.flow.ui;

import static hvqzao.flow.ui.Helper.cellBackground;
import java.awt.Component;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.TableCellRenderer;

public class BooleanTableCellRenderer extends JCheckBox implements TableCellRenderer {

public BooleanTableCellRenderer() {
super();
initialize();
}

private void initialize() {
setOpaque(true);
putClientProperty("JComponent.sizeVariant", "small");
SwingUtilities.updateComponentTreeUI(this);
setLayout(new GridBagLayout());
setMargin(new Insets(0, 0, 0, 0));
setHorizontalAlignment(JLabel.CENTER);
setBorderPainted(true);
}

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
//int modelRow = table.convertRowIndexToModel(row);
setBackground(cellBackground(table.getRowCount(), row, isSelected));
if (value instanceof Boolean) {
setSelected((Boolean) value);
}
return this;
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hvqzao.flow;
package hvqzao.flow.ui;

import javax.swing.JButton;
import javax.swing.JScrollPane;
Expand Down
27 changes: 27 additions & 0 deletions src/hvqzao/flow/ui/Helper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package hvqzao.flow.ui;

import static hvqzao.flow.FlowExtension.getSortOrder;
import java.awt.Color;

public class Helper {

private static final Color COLOR_HIGHLIGHT = new Color(255, 206, 130);
private static final Color COLOR_DARKGRAY = new Color(240, 240, 240);
private static final Color COLOR_LIGHTGRAY = new Color(250, 250, 250);

public static Color cellBackground(int rowCount, int row, boolean isSelected) {
int r = row;
if (getSortOrder() < 1) {
r = rowCount - row;
}
if (isSelected) {
return COLOR_HIGHLIGHT;
} else if (r % 20 == 1) {
return COLOR_DARKGRAY; // new Color(225, 225, 225);
} else if (r % 2 == 1) {
return COLOR_LIGHTGRAY; // new Color(240, 240, 240);
} else {
return Color.WHITE;
}
}
}

0 comments on commit c7b5236

Please sign in to comment.