Skip to content

Commit 0f7ecf8

Browse files
authored
Merge pull request #5306 from kingthorin/pd-tweaks
paramdigger: Handle session change & previous PR follow-up
2 parents abe0a49 + 44f6b2e commit 0f7ecf8

File tree

4 files changed

+40
-13
lines changed

4 files changed

+40
-13
lines changed

addOns/paramdigger/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1010
### Changed
1111
- Maintenance changes.
1212
- Update minimum ZAP version to 2.15.0.
13+
- The output panel is now properly reset on ZAP session change (part of Issue 7694).
1314

1415
## [0.2.0] - 2023-06-06
1516
### Fixed

addOns/paramdigger/src/main/java/org/zaproxy/addon/paramdigger/CacheController.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -861,21 +861,19 @@ private boolean checkAlwaysMiss(String url, Method method, Cache cache) {
861861
String indicValue = msg.getResponseHeader().getHeader(cache.getIndicator());
862862
if (indicValue == null || indicValue.isEmpty()) {
863863
return true;
864-
} else {
865-
if (!this.checkCacheHit(indicValue, cache) && cache.getIndicator() != null) {
866-
sleeper(2000);
867-
httpSender.sendAndReceive(msg);
868-
addCacheMessage(msg);
869-
indicValue = msg.getResponseHeader().getHeader(cache.getIndicator());
870-
if (this.checkCacheHit(indicValue, cache)) {
871-
return false;
872-
} else {
873-
return true;
874-
}
864+
}
865+
if (!this.checkCacheHit(indicValue, cache) && cache.getIndicator() != null) {
866+
sleeper(2000);
867+
httpSender.sendAndReceive(msg);
868+
addCacheMessage(msg);
869+
indicValue = msg.getResponseHeader().getHeader(cache.getIndicator());
870+
if (this.checkCacheHit(indicValue, cache)) {
871+
return false;
875872
}
876-
return false;
873+
return true;
877874
}
878875

876+
return false;
879877
} catch (Exception e) {
880878
return false;
881879
}

addOns/paramdigger/src/main/java/org/zaproxy/addon/paramdigger/ExtensionParamDigger.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121

2222
import javax.swing.ImageIcon;
2323
import org.parosproxy.paros.Constant;
24+
import org.parosproxy.paros.control.Control.Mode;
2425
import org.parosproxy.paros.extension.ExtensionAdaptor;
2526
import org.parosproxy.paros.extension.ExtensionHook;
2627
import org.parosproxy.paros.extension.ExtensionPopupMenuItem;
28+
import org.parosproxy.paros.extension.SessionChangedListener;
29+
import org.parosproxy.paros.model.Session;
2730
import org.parosproxy.paros.network.HttpMessage;
2831
import org.zaproxy.addon.paramdigger.gui.ParamDiggerDialog;
2932
import org.zaproxy.addon.paramdigger.gui.ParamDiggerPanel;
@@ -83,6 +86,8 @@ public void hook(ExtensionHook extensionHook) {
8386
extensionHook.getHookMenu().addToolsMenuItem(getMenu());
8487
extensionHook.getHookView().addStatusPanel(getParamDiggerPanel());
8588
extensionHook.getHookMenu().addPopupMenuItem(getPopupMsg());
89+
90+
extensionHook.addSessionListener(new SessionChangedListenerImpl());
8691
}
8792
}
8893

@@ -153,4 +158,27 @@ public void showParamDiggerDialog(HttpMessage node) {
153158
public String getDescription() {
154159
return Constant.messages.getString(PREFIX + ".desc");
155160
}
161+
162+
private class SessionChangedListenerImpl implements SessionChangedListener {
163+
164+
@Override
165+
public void sessionChanged(Session session) {
166+
getParamDiggerPanel().reset();
167+
}
168+
169+
@Override
170+
public void sessionAboutToChange(Session session) {
171+
// Nothing to do
172+
}
173+
174+
@Override
175+
public void sessionScopeChanged(Session session) {
176+
// Nothing to do
177+
}
178+
179+
@Override
180+
public void sessionModeChanged(Mode mode) {
181+
// Nothing to do
182+
}
183+
}
156184
}

addOns/paramdigger/src/main/java/org/zaproxy/addon/paramdigger/HeaderGuesser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public class HeaderGuesser implements Runnable {
7474
private static final String POISON_DEFINITION = "paramdigger.results.poison.definition";
7575
private static final String POISON_DEFINITION_FIRST =
7676
"paramdigger.results.poison.definition.first";
77-
private static List<Integer> ERROR_CODES = List.of(400, 413, 418, 429, 503);
77+
private static final List<Integer> ERROR_CODES = List.of(400, 413, 418, 429, 503);
7878

7979
private static final int PORT = 31337;
8080
private static final String[] PORTS = {":" + PORT, ":@" + PORT, " " + PORT};

0 commit comments

Comments
 (0)