Skip to content

Commit

Permalink
Fix race condition on variables
Browse files Browse the repository at this point in the history
  • Loading branch information
felixb1515 committed Oct 15, 2024
1 parent 93ec1c0 commit 02ac09b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/java/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ private void restoreFilterState(PersistedObject persistence) {
try {
BurpUtils.getInstance().setFilterState(new ObjectMapper().readValue(persistence.getString("FilterState"), FilterState.class));
RequestFilterDialog.getInstance().updateFilterSettings();
view.preventRaceConditionOnVariables();
} catch (Exception e) {
Logger.getInstance().log(
"Could not restore the filter state. If this is the first time using CSTC in a project, you can ignore this message. " + e.getMessage());
Expand Down
36 changes: 34 additions & 2 deletions src/main/java/de/usd/cstchef/view/RecipePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public class RecipePanel extends JPanel implements ChangeListener {
private JButton addLaneButton = new JButton();
private JButton removeLaneButton = new JButton();

private JCheckBox bakeCheckBox = new JCheckBox("Auto bake");
private JButton bakeButton = new JButton("Bake");

public RecipePanel(BurpOperation operation, MessageType messageType) {

this.operation = operation;
Expand Down Expand Up @@ -200,6 +203,7 @@ public void actionPerformed(ActionEvent e) {
RequestFilterDialog.getInstance().getFilterMask(BurpOperation.INCOMING),
RequestFilterDialog.getInstance().getFilterMask(BurpOperation.OUTGOING));
}
BurpUtils.getInstance().getView().preventRaceConditionOnVariables();
BurpUtils.getInstance().getView().updateInactiveWarnings();
if (!BurpUtils.getInstance().getApi().burpSuite().version().edition()
.equals(BurpSuiteEdition.COMMUNITY_EDITION)) {
Expand All @@ -208,7 +212,6 @@ public void actionPerformed(ActionEvent e) {
}
});

JButton bakeButton = new JButton("Bake");
bakeButton.setEnabled(!autoBake);
activeOperationsPanel.addActionComponent(bakeButton);
bakeButton.addActionListener(new ActionListener() {
Expand Down Expand Up @@ -255,7 +258,6 @@ public void actionPerformed(ActionEvent arg0) {
}
});

JCheckBox bakeCheckBox = new JCheckBox("Auto bake");
bakeCheckBox.setSelected(this.autoBake);
activeOperationsPanel.addActionComponent(bakeCheckBox);
bakeCheckBox.addActionListener(new ActionListener() {
Expand Down Expand Up @@ -377,6 +379,36 @@ public void actionPerformed(ActionEvent e) {
startAutoBakeTimer();
}

public void disableAutobakeIfFilterActive() {
for(Boolean b : BurpUtils.getInstance().getFilterState().getIncomingFilterSettings().values()) {
if(b) {
this.bakeCheckBox.setSelected(false);
this.bakeButton.setEnabled(true);
this.bakeCheckBox.setEnabled(false);
this.bakeCheckBox.setToolTipText("Auto bake is disabled if Filter is active.");
return;
}
else if(!this.bakeCheckBox.isEnabled() && !b) {
this.bakeCheckBox.setEnabled(true);
this.bakeCheckBox.setToolTipText("");
}
}

for(Boolean b : BurpUtils.getInstance().getFilterState().getOutgoingFilterSettings().values()) {
if(b) {
this.bakeCheckBox.setSelected(false);
this.bakeButton.setEnabled(true);
this.bakeCheckBox.setEnabled(false);
this.bakeCheckBox.setToolTipText("Auto bake is disabled if Filter is active.");
return;
}
else if(!this.bakeCheckBox.isEnabled() && !b) {
this.bakeCheckBox.setEnabled(true);
this.bakeCheckBox.setToolTipText("");
}
}
}

private void increaseLaneNumber(int number) {
this.operationSteps += number;

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/de/usd/cstchef/view/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,10 @@ public void updateInactiveWarnings() {
outgoingRecipePanel.hideInactiveWarning();
}
}

public void preventRaceConditionOnVariables() {
incomingRecipePanel.disableAutobakeIfFilterActive();
outgoingRecipePanel.disableAutobakeIfFilterActive();
formatRecipePanel.disableAutobakeIfFilterActive();
}
}

0 comments on commit 02ac09b

Please sign in to comment.