Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,24 @@ public class ExtensionScript extends ExtensionAdaptor implements CommandLineList

protected static final String SCRIPT_NAME_ATT = "zap.script.name";

/**
* @deprecated (2.18.0) Replaced by scripts add-on.
*/
@Deprecated(since = "2.18.0", forRemoval = true)
public static final String TYPE_HTTP_SENDER = "httpsender";

/**
* @deprecated (2.18.0) Replaced by scripts add-on.
*/
@Deprecated(since = "2.18.0", forRemoval = true)
public static final String TYPE_PROXY = "proxy";

public static final String TYPE_STANDALONE = "standalone";

/**
* @deprecated (2.18.0) Replaced by scripts add-on.
*/
@Deprecated(since = "2.18.0", forRemoval = true)
public static final String TYPE_TARGETED = "targeted";

private ScriptEngineManager mgr = new ScriptEngineManager();
Expand All @@ -127,8 +142,6 @@ public class ExtensionScript extends ExtensionAdaptor implements CommandLineList
private ScriptTreeModel treeModel = null;
private List<ScriptEngineWrapper> engineWrappers = new ArrayList<>();
private Map<String, ScriptType> typeMap = new ConcurrentHashMap<>();
private ProxyListenerScript proxyListener = null;
private HttpSenderScriptListener httpSenderScriptListener;

private List<ScriptEventListener> listeners = new ArrayList<>();
private MultipleWriters writers = new MultipleWriters();
Expand Down Expand Up @@ -189,36 +202,16 @@ public String getUIName() {
public void hook(ExtensionHook extensionHook) {
super.hook(extensionHook);

this.registerScriptType(
new ScriptType(
TYPE_PROXY,
"script.type.proxy",
createIcon("/resource/icon/16/script-proxy.png"),
true));
this.registerScriptType(
new ScriptType(
TYPE_STANDALONE,
"script.type.standalone",
createIcon("/resource/icon/16/script-standalone.png"),
false,
new String[] {ScriptType.CAPABILITY_APPEND}));
this.registerScriptType(
new ScriptType(
TYPE_TARGETED,
"script.type.targeted",
createIcon("/resource/icon/16/script-targeted.png"),
false));
this.registerScriptType(
new ScriptType(
TYPE_HTTP_SENDER,
"script.type.httpsender",
createIcon("/resource/icon/16/script-httpsender.png"),
true));

extensionHook.addSessionListener(new ClearScriptVarsOnSessionChange());

extensionHook.addProxyListener(this.getProxyListener());
extensionHook.addHttpSenderListener(getHttpSenderScriptListener());
extensionHook.addOptionsParamSet(getScriptParam());

extensionHook.addCommandLine(getCommandLineArguments());
Expand Down Expand Up @@ -251,20 +244,6 @@ private OptionsScriptPanel getOptionsScriptPanel() {
return optionsScriptPanel;
}

private ProxyListenerScript getProxyListener() {
if (this.proxyListener == null) {
this.proxyListener = new ProxyListenerScript(this);
}
return this.proxyListener;
}

private HttpSenderScriptListener getHttpSenderScriptListener() {
if (this.httpSenderScriptListener == null) {
this.httpSenderScriptListener = new HttpSenderScriptListener(this);
}
return this.httpSenderScriptListener;
}

public List<String> getScriptingEngines() {
List<String> engineNames = new ArrayList<>();
List<ScriptEngineFactory> engines = mgr.getEngineFactories();
Expand Down Expand Up @@ -1651,8 +1630,11 @@ public void handleScriptError(ScriptWrapper script, String error) {
* @param script the script to invoke.
* @param msg the HTTP message to process.
* @since 2.2.0
* @deprecated (2.18.0) Replaced by scripts add-on.
* @see #getInterface(ScriptWrapper, Class)
*/
@SuppressWarnings("removal")
@Deprecated(since = "2.18.0", forRemoval = true)
public void invokeTargetedScript(ScriptWrapper script, HttpMessage msg) {
validateScriptType(script, TYPE_TARGETED);

Expand Down Expand Up @@ -1754,8 +1736,11 @@ private void handleUnspecifiedScriptError(
* @param request {@code true} if processing the request, {@code false} otherwise.
* @return {@code true} if the request should be forward to the server, {@code false} otherwise.
* @since 2.2.0
* @deprecated (2.18.0) Replaced by scripts add-on.
* @see #getInterface(ScriptWrapper, Class)
*/
@SuppressWarnings("removal")
@Deprecated(since = "2.18.0", forRemoval = true)
public boolean invokeProxyScript(ScriptWrapper script, HttpMessage msg, boolean request) {
validateScriptType(script, TYPE_PROXY);

Expand Down Expand Up @@ -1800,8 +1785,11 @@ public boolean invokeProxyScript(ScriptWrapper script, HttpMessage msg, boolean
* @param sender the sender of the given {@code HttpMessage}.
* @param request {@code true} if processing the request, {@code false} otherwise.
* @since 2.4.1
* @deprecated (2.18.0) Replaced by scripts add-on.
* @see #getInterface(ScriptWrapper, Class)
*/
@SuppressWarnings("removal")
@Deprecated(since = "2.18.0", forRemoval = true)
public void invokeSenderScript(
ScriptWrapper script,
HttpMessage msg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
* following scripts/listeners may modify it.
*
* @since 2.4.1
* @deprecated (2.18.0) Replaced by scripts add-on.
*/
@SuppressWarnings("removal")
@Deprecated(since = "2.18.0", forRemoval = true)
public interface HttpSenderScript {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@

import org.parosproxy.paros.network.HttpSender;

/**
* @deprecated (2.18.0) Replaced by scripts add-on.
*/
@Deprecated(since = "2.18.0", forRemoval = true)
public class HttpSenderScriptHelper {

private HttpSender httpSender;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
import org.zaproxy.zap.extension.script.ScriptsCache.Configuration;
import org.zaproxy.zap.network.HttpSenderListener;

/**
* @deprecated (2.18.0) Replaced by scripts add-on.
*/
@SuppressWarnings("removal")
@Deprecated(since = "2.18.0", forRemoval = true)
class HttpSenderScriptListener implements HttpSenderListener {

private final ScriptsCache<HttpSenderScript> scriptsCache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
import org.zaproxy.zap.extension.script.ScriptsCache.CachedScript;
import org.zaproxy.zap.extension.script.ScriptsCache.Configuration;

/**
* @deprecated (2.18.0) Replaced by scripts add-on.
*/
@SuppressWarnings("removal")
@Deprecated(since = "2.18.0", forRemoval = true)
public class ProxyListenerScript implements ProxyListener {

// Should be the last one but one before the listener that saves the HttpMessage to the db
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
* modify it or drop it.
*
* @since 2.2.0
* @deprecated (2.18.0) Replaced by scripts add-on.
*/
@Deprecated(since = "2.18.0", forRemoval = true)
public interface ProxyScript {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
* A script that is executed on demand by the user for selected {@link HttpMessage HTTP message}(s).
*
* @since 2.2.0
* @deprecated (2.18.0) Replaced by scripts add-on.
*/
@Deprecated(since = "2.18.0", forRemoval = true)
public interface TargetedScript {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2503,19 +2503,13 @@ script.resource = Script: {0}
script.tree.root = Scripting
script.tree.scripts = Scripts
script.tree.templates = Templates
script.type.httpsender = HTTP Sender
script.type.httpsender.desc = HTTP Sender scripts run against every request/response sent/received by ZAP.\nThis includes the proxied messages, messages sent during active scanner, fuzzer, ...\n\nYou must enable them before they will be used.
script.type.inline = Inline
script.type.library = Library
script.type.proxy = Proxy
script.type.proxy.desc = Proxy scripts run against every request and response proxied through ZAP.\n\nYou must enable them before they will be used.
script.type.sequence = Sequence
script.type.sitemodifier = Site Modifier
script.type.sitemodifier.desc = Site Modifier scripts can change the structure of the application as understood by ZAP by changing the Sites Tree as new requests and responses are added.\n\n
script.type.standalone = Stand Alone
script.type.standalone.desc = Stand Alone scripts are self contained scripts that can only be run manually.\n\nYou run them using the 'Run' button in the above toolbar.
script.type.targeted = Targeted
script.type.targeted.desc = Targeted scripts are scripts that act on a specified URL or set of URLs.\n\nYou typically invoke them by right-clicking on a node in the Sites tree or on a record in a list of responses and selecting 'Run with Script'.

search.api.desc =
search.api.other.harByHeaderRegex = Returns the HTTP messages, in HAR format, that match the given regular expression in the header(s) optionally filtered by URL and paginated with 'start' position and 'count' of messages.
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.zaproxy.zap.extension.script.ScriptsCache.ScriptAction;

/** Unit test for {@link HttpSenderScriptListener}. */
@SuppressWarnings("removal")
class HttpSenderScriptListenerUnitTest extends WithConfigsTest {

private static final String SCRIPT_TYPE = ExtensionScript.TYPE_HTTP_SENDER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.zaproxy.zap.extension.script.ScriptsCache.InterfaceErrorMessageProvider;

/** Unit test for {@link ProxyListenerScript}. */
@SuppressWarnings("removal")
class ProxyListenerScriptUnitTest extends WithConfigsTest {

private static final String SCRIPT_TYPE = ExtensionScript.TYPE_PROXY;
Expand Down
Loading