Skip to content

Commit

Permalink
reworked the layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
aress31 committed Dec 24, 2023
1 parent 323ea06 commit 77fcbc4
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 152 deletions.
2 changes: 1 addition & 1 deletion src/main/java/swurg/gui/components/tables/TablePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public void initComponents() {
this.setLayout(new GridBagLayout());

this.table = createTable(this.tableModel, this.cellRenderer, this.requestViewer);

JScrollPane scrollPane = new JScrollPane(this.table);

JPanel filterPanel = new FilterPanel(this.tableRowSorter);

GridBagConstraints gbc = new GridBagConstraints();
Expand Down
42 changes: 21 additions & 21 deletions src/main/java/swurg/gui/views/AboutPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ public AboutPanel() {
private void initComponents() {
this.setLayout(new BorderLayout());

JPanel svgPanel = createSvgCanvas();
svgPanel.setPreferredSize(new Dimension(192, 192));
svgPanel.setBorder(new EmptyBorder(16, 16, 0, 16));
JPanel northPanel = createNorthPanel();
northPanel.setPreferredSize(new Dimension(192, 192));
northPanel.setBorder(new EmptyBorder(16, 16, 0, 16));

JPanel contentPanel = createContentPanel();
contentPanel.setBorder(new EmptyBorder(0, 16, 0, 16));
JPanel centerPanel = createCenterPanel();
centerPanel.setBorder(new EmptyBorder(0, 16, 0, 16));

this.add(svgPanel, BorderLayout.NORTH);
this.add(contentPanel, BorderLayout.CENTER);
this.add(northPanel, BorderLayout.NORTH);
this.add(centerPanel, BorderLayout.CENTER);
this.add(new StatusPanel(), BorderLayout.SOUTH);
}

private JPanel createSvgCanvas() {
JPanel svgPanel = new JPanel(new BorderLayout());
private JPanel createNorthPanel() {
JPanel panel = new JPanel(new BorderLayout());
JSVGCanvas svgCanvas = new JSVGCanvas();

try {
Expand All @@ -63,27 +63,27 @@ private JPanel createSvgCanvas() {
svgCanvas.setOpaque(false);
svgCanvas.setBackground(new Color(0, 0, 0, 0));

svgPanel.add(svgCanvas, BorderLayout.CENTER);
panel.add(svgCanvas, BorderLayout.CENTER);

return svgPanel;
return panel;
}

private JPanel createContentPanel() {
JPanel contentPanel = new JPanel();
contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
private JPanel createCenterPanel() {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

JEditorPane editorPane = createTextLabel();
JEditorPane editorPane = createEditorPane("about.html");
JScrollPane scrollPane = new JScrollPane(editorPane);

contentPanel.add(scrollPane);
contentPanel.add(Box.createVerticalStrut(16));
contentPanel.add(createButtonPanel());
panel.add(scrollPane);
panel.add(Box.createVerticalStrut(16));
panel.add(createButtonPanel());

return contentPanel;
return panel;
}

private JEditorPane createTextLabel() {
String htmlContent = HtmlResourceLoader.loadHtmlContent("aboutText.html");
private JEditorPane createEditorPane(String resourcePath) {
String htmlContent = HtmlResourceLoader.loadHtmlContent(resourcePath);
String formattedHtmlContent = MessageFormat.format(htmlContent, VERSION, EXTENSION);

JEditorPane editorPane = new JEditorPane();
Expand Down
80 changes: 38 additions & 42 deletions src/main/java/swurg/gui/views/ParametersPanel.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package swurg.gui.views;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.Frame;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ItemEvent;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -14,8 +14,9 @@

import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import burp.api.montoya.logging.Logging;
import burp.http.MyHttpParameter;
Expand All @@ -41,12 +42,12 @@
public class ParametersPanel extends JPanel
implements HttpHandler, ParametersPanelObserver {

private MontoyaApi montoyaApi;
private Logging logging;

private transient List<ToolType> toolsInScope = new ArrayList<>();

private ParametersTableModel parametersTableModel;

private transient List<ToolType> toolsInScope = new ArrayList<>();
private List<ToolType> toolsMap = List.of(
ToolType.EXTENSIONS,
ToolType.INTRUDER,
Expand All @@ -55,10 +56,10 @@ public class ParametersPanel extends JPanel
ToolType.SCANNER,
ToolType.SEQUENCER,
ToolType.TARGET);

private List<MyHttpRequest> myHttpRequests;

public ParametersPanel(MontoyaApi montoyaApi, List<MyHttpRequest> myHttpRequests) {
this.montoyaApi = montoyaApi;
this.logging = montoyaApi.logging();
this.myHttpRequests = myHttpRequests;

Expand All @@ -70,43 +71,27 @@ public ParametersPanel(MontoyaApi montoyaApi, List<MyHttpRequest> myHttpRequests
@Override
public void onRequestWithMetadatasUpdate() {
parametersTableModel.updateData(myHttpRequests);

}

private void initComponents() {
this.setLayout(new BorderLayout());

JPanel northPanel = createNorthPanel();

TablePanel tablePanel = new TablePanel(parametersTableModel, new CustomTableCellRenderer());
ParametersContextMenu contextMenu = new ParametersContextMenu(tablePanel.getTable());
tablePanel.setContextMenu(contextMenu);

JPanel eastPanel = createEastPanel();
JPanel southPanel = new StatusPanel();

JPanel centerContainer = new JPanel(new GridBagLayout());
centerContainer.setBackground(Color.ORANGE);

this.add(northPanel, BorderLayout.NORTH);
this.add(tablePanel, BorderLayout.CENTER);
this.add(eastPanel, BorderLayout.EAST);
this.add(southPanel, BorderLayout.SOUTH);

// add a nested JPanel with a GridBagLayout to the CENTER of the main container
JPanel centerContainer = new JPanel(new GridBagLayout());
this.add(centerContainer, BorderLayout.CENTER);

GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 3;
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 0.75;
gbc.weighty = 1.0;
centerContainer.add(tablePanel, gbc);

gbc.gridx = 3;
gbc.gridwidth = 1;
gbc.weightx = 0.25;
centerContainer.add(eastPanel, gbc);

// set the preferred sizes of the center and east panels
tablePanel.setPreferredSize(new Dimension(0, 0));
eastPanel.setPreferredSize(new Dimension(0, 0));
}

private JPanel createNorthPanel() {
Expand Down Expand Up @@ -134,23 +119,34 @@ private JPanel createNorthPanel() {
}

private JPanel createEastPanel() {
String htmlContent = HtmlResourceLoader.loadHtmlContent("howToText.html");
JLabel label = new JLabel(htmlContent);
label.putClientProperty("html.disable", null);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createTitledBorder("How To"));

JEditorPane editorPane = createEditorPane("howTo.html");
JScrollPane scrollPane = new JScrollPane(editorPane);
scrollPane.setBorder(null);

JPanel eastPanel = new JPanel(new GridBagLayout());
eastPanel.setBorder(BorderFactory.createTitledBorder("How To"));
Frame suiteFrame = this.montoyaApi.userInterface().swingUtils().suiteFrame();

// Eyebolling the height offset
scrollPane.setPreferredSize(
new Dimension((int) (suiteFrame.getWidth() * 0.25),
suiteFrame.getHeight() - 210));

panel.add(scrollPane);

return panel;
}

GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new Insets(4, 8, 4, 8);
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
private JEditorPane createEditorPane(String resourcePath) {
String htmlContent = HtmlResourceLoader.loadHtmlContent(resourcePath);

eastPanel.add(label, gridBagConstraints);
JEditorPane editorPane = new JEditorPane();
editorPane.setContentType("text/html");
editorPane.setText(htmlContent);
editorPane.setEditable(false);

return eastPanel;
return editorPane;
}

@Override
Expand Down
31 changes: 31 additions & 0 deletions src/main/resources/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<html>

<body style='text-align: justify; text-justify: inter-word; font-family: Arial, sans-serif;'>
<h1>Version:</b> <strong>{0}</strong></h1>

<h2>About {1}</h2>
<p>{1} is a powerful tool designed specifically for testing OpenAPI-based APIs using Burp Suite. Developed by
<strong>Alexandre Teyar</strong>, Managing Director at <strong>Aegis Cyber</strong>, this tool offers a
comprehensive set of features to streamline and enhance your API testing experience. With {1}, you can
efficiently analyze and validate OpenAPI specifications, perform in-depth testing of API endpoints, and gain
valuable insights into the API behavior and security vulnerabilities.
</p>

<h2>Feedback and Contributions</h2>
<p>Your feedback and contributions are highly valued! We actively encourage you to share your thoughts, suggestions,
and ideas for new features, enhancements, or improvements. To facilitate this, we provide a ticket submission
system where you can directly contribute to shaping the future of {1}. We appreciate your input and strive to
incorporate user feedback to make {1} even more user-friendly and powerful. Additionally, we welcome and
appreciate community contributions through pull requests. By contributing to {1}, you can contribute to the
growth and improvement of the tool, making it even more robust and effective for the entire community of API
testers and developers.</p>

<h2>Support and Appreciation</h2>
<p>If you have found {1} valuable in testing OpenAPI-based APIs, we kindly request your support. Taking a moment to
give the repository a star and rating it on the BApp Store would mean a lot to us. Your support and feedback are
pivotal in motivating us to continue enhancing the tool for the benefit of the entire community. Your positive
ratings and recommendations can help us reach a wider audience, enabling more developers to benefit from {1} and
enhance their API testing workflows.</p>
</body>

</html>
13 changes: 0 additions & 13 deletions src/main/resources/aboutText.html

This file was deleted.

77 changes: 77 additions & 0 deletions src/main/resources/howTo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<html>

<body style="
text-align: justify;
text-justify: inter-word;
font-family: Arial, sans-serif;
">
<p>
This tab allows for the visualization and editing of detected parameters,
including their parsed types and values, within parsed OpenAPI files found
in the 'Parser' tab.
</p>

<p>
To effectively utilize the match and replace feature when assessing
RESTful APIs based on OpenAPI, ensure that valid test values are set in
the 'Edited Value' column. The match and replace functionality will only
be applied to requests that meet the following conditions:
</p>

<ul>
<li>
The BurpSuite tool for monitoring/processing is selected in the
'Match/Replace Scope' section of this tab.
</li>
<li>
The request contains at least one parameter with a name and type that
match the 'Parameter' and 'Type' fields, respectively, and its value
matches the 'Parsed Value'.
</li>
</ul>

<p>
For optimal results and accuracy, populate the 'Edited Value' column with
valid test parameters that trigger an HTTP 200 response before initiating
any scans.
</p>

<p>
<u>Warning:</u> Operations performed in the 'Parser' tab, such as clicking
'Clear item(s)' or 'Clear all' options in the contextual menu, or clicking
the 'Browse/Load' button, will reset the 'Parameters' tab. These operations include:
</p>

<ul>
<li>
Any click on the 'Clear item(s)' or 'Clear all' options in the
contextual menu.
</li>
<li>Any click on the 'Browse/Load' button.</li>
</ul>


<p>Known bugs <b>(Pull Requests are welcome)</b>:</p>
<ul>
<li>
Body parameters can only be formatted as
'application/x-www-form-urlencoded' due to current limitations in the
Burp Extender API.
</s>
</li>
<li>
<s>
Editing the 'Edited Value' column in the 'Parameters' tab while
filtering the table may result in the edited value being set to
'null'.
</s>
</li>
<li>
To register a change made in the 'Edited Value' column, you should press
the Enter key first and then press the Escape key.
</li>
<li>Deep/recursive parsing of OpenAPI Schema fields is not supported.</li>
</ul>
</body>

</html>

0 comments on commit 77fcbc4

Please sign in to comment.