diff --git a/addOns/automacrobuilder/automacrobuilder.gradle.kts b/addOns/automacrobuilder/automacrobuilder.gradle.kts index 18061e6..8843a66 100644 --- a/addOns/automacrobuilder/automacrobuilder.gradle.kts +++ b/addOns/automacrobuilder/automacrobuilder.gradle.kts @@ -1,6 +1,6 @@ import org.zaproxy.gradle.addon.AddOnStatus -version = "0.9.4" +version = "0.9.5" description = "AutoMacroBuilder for ZAP" tasks.withType { diff --git a/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/PRequestResponse.java b/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/PRequestResponse.java index 4cec04b..dabc73f 100644 --- a/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/PRequestResponse.java +++ b/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/PRequestResponse.java @@ -60,7 +60,7 @@ public PRequestResponse( init(h, p, ssl, binrequest, binresponse, pageenc, pageenc); } - public PRequestResponse(ClientDependMessageContainer cdmc) { + public PRequestResponse(ClientDependMessageContainer cdmc, Encode defaultenc) { this.cdmc = cdmc; init( cdmc.getHost(), @@ -68,8 +68,8 @@ public PRequestResponse(ClientDependMessageContainer cdmc) { cdmc.isSSL(), cdmc.getRequestByte(), cdmc.getResponseByte(), - cdmc.getRequestEncode(), - cdmc.getResponseEncode()); + cdmc.getRequestEncode() != null ? cdmc.getRequestEncode() : defaultenc, + cdmc.getResponseEncode() != null ? cdmc.getResponseEncode() : defaultenc); } public void setClientDependMessageContainer(ClientDependMessageContainer cdmc) { diff --git a/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/generated/MacroBuilderUI.java b/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/generated/MacroBuilderUI.java index 0a5bb37..da3e2f0 100644 --- a/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/generated/MacroBuilderUI.java +++ b/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/generated/MacroBuilderUI.java @@ -1763,6 +1763,16 @@ public int getCurrentSelectedRequestIndex(){ } public StyledDocumentWithChunk getMacroRequestStyledDocument() { + int pos = getCurrentSelectedRequestIndex(); + if (pos < 0 || pos != selected_request_idx) { + logger4j.error( + "getMacroRequestStyledDocument pos[" + + pos + + "]!=selected_request_idx[" + + selected_request_idx + "]"); + return null; + } + MacroRequestLoadContents(); StyledDocument doc = MacroRequest.getStyledDocument(); if ( doc instanceof StyledDocumentWithChunk) { return CastUtils.castToType(doc); diff --git a/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/zap/PopUpItemActiveScan.java b/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/zap/PopUpItemActiveScan.java index 1c79060..125a352 100644 --- a/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/zap/PopUpItemActiveScan.java +++ b/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/zap/PopUpItemActiveScan.java @@ -60,10 +60,9 @@ public class PopUpItemActiveScan extends JMenuItem { addActionListener( ev -> { - int pos = this.mbui.getCurrentSelectedRequestIndex(); - - if (pos > -1) { - PRequest newrequest = ZapUtil.getPRequestFromMacroRequest(this.mbui); + PRequest newrequest = ZapUtil.getPRequestFromMacroRequest(this.mbui); + if (newrequest != null) { + int pos = this.mbui.getCurrentSelectedRequestIndex(); ParmGenMacroTraceParams targetStepNo = new ParmGenMacroTraceParams(pos); this.extension.setTargetStepNo(targetStepNo); ParmGenMacroTrace pmt = this.mbui.getParmGenMacroTrace(); diff --git a/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/zap/PopUpItemSingleSend.java b/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/zap/PopUpItemSingleSend.java index dec7198..80d3fbd 100644 --- a/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/zap/PopUpItemSingleSend.java +++ b/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/zap/PopUpItemSingleSend.java @@ -44,12 +44,11 @@ public class PopUpItemSingleSend extends JMenuItem { addActionListener( e -> { PRequest newrequest = ZapUtil.getPRequestFromMacroRequest(f_mbui); - int pos = f_mbui.getCurrentSelectedRequestIndex(); - HttpMessage htmess = ZapUtil.getHttpMessage(newrequest); - final ParmGenMacroTraceParams pmtParams = new ParmGenMacroTraceParams(pos); - - if (htmess != null) { + if (newrequest != null) { + int pos = f_mbui.getCurrentSelectedRequestIndex(); + final HttpMessage htmess = ZapUtil.getHttpMessage(newrequest); + final ParmGenMacroTraceParams pmtParams = new ParmGenMacroTraceParams(pos); final Thread t = new Thread( new Runnable() { diff --git a/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/zap/PopupMenuAdd2MacroBuilder.java b/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/zap/PopupMenuAdd2MacroBuilder.java index fffde4c..6171113 100644 --- a/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/zap/PopupMenuAdd2MacroBuilder.java +++ b/addOns/automacrobuilder/src/main/java/org/zaproxy/zap/extension/automacrobuilder/zap/PopupMenuAdd2MacroBuilder.java @@ -36,6 +36,7 @@ public class PopupMenuAdd2MacroBuilder extends PopupMenuItemHistoryReferenceCont private ParmGenMacroTrace pmt = null; private MacroBuilderUI mbui = null; private List listprr = null; + private List hrefs = null; /** @param label */ public PopupMenuAdd2MacroBuilder(MacroBuilderUI mbui, ParmGenMacroTrace pmt, String label) { @@ -50,7 +51,8 @@ public void performAction(HistoryReference href) {} @Override protected void performHistoryReferenceActions(List hrefs) { - hrefs.stream() + this.hrefs = hrefs; + this.hrefs.stream() .forEach( href -> { System.out.println("" + href.toString()); @@ -58,7 +60,10 @@ protected void performHistoryReferenceActions(List hrefs) { this.listprr = hrefs.stream() - .map(href -> new PRequestResponse(new ClientDependMessageContainer(href))) + .map( + href -> + new PRequestResponse( + new ClientDependMessageContainer(href), null)) .collect(Collectors.toList()); if (pmt.getRlistCount() <= 0) { @@ -74,6 +79,15 @@ protected void performHistoryReferenceActions(List hrefs) { @Override public void LangOK() { + // selected encode applied to PRequestResponses. + this.listprr = + this.hrefs.stream() + .map( + href -> + new PRequestResponse( + new ClientDependMessageContainer(href), + ParmVars.enc)) + .collect(Collectors.toList()); mbui.addNewRequests(this.listprr); langdialog.setVisible(false); }