-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option to create Rules from the context menu of Proxy History i…
…tems. Fixed file saving when using the default encoding.
- Loading branch information
Showing
21 changed files
with
680 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/synfron/reshaper/burp/core/utils/Select.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package synfron.reshaper.burp.core.utils; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class Select<T> { | ||
|
||
@Getter | ||
private final List<T> options; | ||
@Getter @Setter | ||
private T selectedOption; | ||
|
||
public Select(List<T> options, T selectedOption) { | ||
this.options = Collections.unmodifiableList(options); | ||
this.selectedOption = selectedOption != null ? selectedOption : options.stream().findFirst().orElse(null); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
src/main/java/synfron/reshaper/burp/ui/components/rules/wizard/WhenWizardItemComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package synfron.reshaper.burp.ui.components.rules.wizard; | ||
|
||
import net.miginfocom.swing.MigLayout; | ||
import synfron.reshaper.burp.core.messages.MessageValue; | ||
import synfron.reshaper.burp.ui.components.IFormComponent; | ||
import synfron.reshaper.burp.ui.models.rules.wizard.WhenWizardItemModel; | ||
import synfron.reshaper.burp.ui.models.rules.wizard.WizardMatchType; | ||
import synfron.reshaper.burp.ui.utils.ComponentVisibilityManager; | ||
import synfron.reshaper.burp.ui.utils.DocumentActionListener; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.awt.event.ActionEvent; | ||
import java.util.List; | ||
|
||
public class WhenWizardItemComponent extends JPanel implements IFormComponent { | ||
private final WhenWizardItemModel model; | ||
private final boolean deletable; | ||
private JComboBox<MessageValue> messageValue; | ||
private JComboBox<String> identifier; | ||
private JComboBox<WizardMatchType> matchType; | ||
private JTextField text; | ||
|
||
public WhenWizardItemComponent(WhenWizardItemModel model, boolean deletable) { | ||
this.model = model; | ||
this.deletable = deletable; | ||
initComponent(); | ||
} | ||
|
||
private void initComponent() { | ||
setLayout(new BorderLayout()); | ||
JPanel container = new JPanel(new MigLayout()); | ||
|
||
messageValue = new JComboBox<>(MessageValue.values()); | ||
identifier = new JComboBox<>(model.getIdentifiers().getOptions().toArray(new String[0])); | ||
matchType = new JComboBox<>(WizardMatchType.values()); | ||
text = createTextField(); | ||
text.setColumns(20); | ||
text.setMaximumSize(new Dimension(text.getPreferredSize().width, text.getPreferredSize().height)); | ||
text.setAlignmentX(Component.LEFT_ALIGNMENT); | ||
|
||
messageValue.setSelectedItem(model.getMessageValue()); | ||
identifier.setSelectedItem(model.getIdentifiers().getSelectedOption()); | ||
matchType.setSelectedItem(model.getMatchType()); | ||
text.setText(model.getText()); | ||
|
||
messageValue.addActionListener(this::onMessageValueChanged); | ||
identifier.addActionListener(this::onIdentifierChanged); | ||
matchType.addActionListener(this::onMatchTypeChanged); | ||
text.getDocument().addDocumentListener(new DocumentActionListener(this::onTextChanged)); | ||
|
||
container.add(text, "wrap"); | ||
container.add(messageValue, "wrap"); | ||
container.add(ComponentVisibilityManager.withVisibilityFieldChangeDependency( | ||
identifier, | ||
List.of(messageValue, identifier), | ||
() -> ((MessageValue) messageValue.getSelectedItem()).isIdentifierRequired() && identifier.getItemCount() != 0 | ||
), "wrap"); | ||
container.add(ComponentVisibilityManager.withVisibilityFieldChangeDependency( | ||
new JLabel("Not Applicable"), | ||
List.of(messageValue, identifier), | ||
() -> ((MessageValue) messageValue.getSelectedItem()).isIdentifierRequired() && identifier.getItemCount() == 0 | ||
), "wrap"); | ||
container.add(ComponentVisibilityManager.withVisibilityFieldChangeDependency( | ||
matchType, | ||
List.of(messageValue, identifier), | ||
() -> !((MessageValue) messageValue.getSelectedItem()).isIdentifierRequired() || identifier.getItemCount() != 0 | ||
), "wrap"); | ||
container.add(ComponentVisibilityManager.withVisibilityFieldChangeDependency( | ||
text, | ||
List.of(matchType, messageValue, identifier), | ||
() -> (!((MessageValue) messageValue.getSelectedItem()).isIdentifierRequired() || identifier.getItemCount() != 0) && ((WizardMatchType) matchType.getSelectedItem()).isMatcher() | ||
), "wrap"); | ||
|
||
add(new JSeparator(), BorderLayout.PAGE_START); | ||
add(container, BorderLayout.CENTER); | ||
if (deletable) { | ||
JButton delete = new JButton("Delete"); | ||
delete.addActionListener(this::onDelete); | ||
add(getRightJustifiedButton(delete), BorderLayout.PAGE_END); | ||
} | ||
} | ||
|
||
private void resetIdentifiers() { | ||
identifier.removeAllItems(); | ||
model.getIdentifiers().getOptions().forEach(option -> identifier.addItem(option)); | ||
identifier.setSelectedItem(model.getIdentifiers().getSelectedOption()); | ||
} | ||
|
||
private void resetText() { | ||
text.setText(model.getText()); | ||
} | ||
|
||
private void onMessageValueChanged(ActionEvent actionEvent) { | ||
model.setMessageValue((MessageValue) messageValue.getSelectedItem()); | ||
resetIdentifiers(); | ||
resetText(); | ||
} | ||
|
||
private void onIdentifierChanged(ActionEvent actionEvent) { | ||
model.setIdentifier((String) identifier.getSelectedItem()); | ||
resetText(); | ||
} | ||
|
||
private void onMatchTypeChanged(ActionEvent actionEvent) { | ||
model.setMatchType((WizardMatchType) matchType.getSelectedItem()); | ||
} | ||
|
||
private void onTextChanged(ActionEvent actionEvent) { | ||
model.setText(text.getText()); | ||
} | ||
|
||
private void onDelete(ActionEvent actionEvent) { | ||
model.setDeleted(true); | ||
} | ||
|
||
protected Component getRightJustifiedButton(JButton button) { | ||
JPanel outerContainer = new JPanel(new FlowLayout(FlowLayout.RIGHT)); | ||
outerContainer.setAlignmentX(LEFT_ALIGNMENT); | ||
outerContainer.setAlignmentY(TOP_ALIGNMENT); | ||
outerContainer.add(button); | ||
return outerContainer; | ||
} | ||
} |
Oops, something went wrong.