You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: addOns/scripts/src/main/javahelp/org/zaproxy/zap/extension/scripts/resources/help/contents/automation.html
+52-5Lines changed: 52 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -36,17 +36,63 @@ <H2>Action: remove</H2>
36
36
37
37
<H2>Action: run</H2>
38
38
39
-
Runs the specified script to ZAP. The script must already be available in ZAP, for example added using the 'add' action.
39
+
Runs the specified script in ZAP. The script must already be available in ZAP, for example added using the 'add' action.
40
40
41
41
<ul>
42
42
<li>type: mandatory, can be 'standalone' or 'targeted'
43
-
<li>name: mandatory, the name of the script in ZAP
43
+
<li>name: mandatory for single script run, the name of the script in ZAP (if both 'name' and 'chain' are specified, 'name' is ignored)
44
+
<li>chain: optional for running multiple scripts in sequence, a list of script names (takes precedence over 'name' if both are specified)
44
45
<li>engine: optional, can be used to override the default engine for the file extension
45
46
<li>target: mandatory, if type is 'targeted', the target URL to be invoked for 'targeted' script
46
47
<li>context: optional, the name of the context to use when running the script
47
-
<li>user: optional, the name of the user to use when running the standalone script. Currently only supported for Zest scripts, if the context has browser-based or client-script authentication configured, the user will be authenticated before the script executes.
48
+
<li>user: optional, the name of the user when running the Zest standalone script or chain (requires context). See Script Chaining for authentication with chains.
49
+
</ul>
50
+
51
+
<H3>Script Chaining</H3>
52
+
<p>
53
+
The run action can execute one or more Zest standalone scripts in sequence using the <code>chain</code> parameter.
54
+
This is useful for workflows that require several scripts to run in order.
55
+
</p>
56
+
<p>
57
+
Chaining requires the Zest add-on to be installed. If it is not loaded or chain preparation fails, the job reports an error and the chain does not run.
58
+
</p>
59
+
60
+
<H4>Requirements:</H4>
61
+
<ul>
62
+
<li>All scripts in the chain must be Zest standalone scripts</li>
63
+
<li>All scripts must be added via "add" actions in the same plan (or already loaded in ZAP)</li>
64
+
<li>Script existence and type are validated at runtime, not during plan validation</li>
65
+
<li>If both <code>chain</code> and <code>name</code> are specified, <code>chain</code> is used and <code>name</code> is ignored (a warning is issued)</li>
66
+
<li>The first script must contain at least one browser launch (<code>ZestClientLaunch</code>)</li>
67
+
<li>Subsequent scripts reuse that browser (extra launch statements are disabled)</li>
68
+
<li>At the end of the chain, all browser windows opened by the scripts are closed automatically</li>
48
69
</ul>
49
70
71
+
<H4>Authentication:</H4>
72
+
<p>
73
+
If <code>user</code> is specified, the user is authenticated when the context has browser-based or client-script authentication configured (Zest only).
74
+
For chains, authentication is performed once before the first script runs; all scripts in the chain share the same authenticated session.
75
+
</p>
76
+
77
+
<H4>Error Handling:</H4>
78
+
<p>
79
+
If chain preparation fails (e.g. Zest not loaded) or any script in the chain fails during execution, the job reports an error and stops. Later scripts in the chain are not run.
80
+
</p>
81
+
82
+
<H4>Example:</H4>
83
+
<pre>
84
+
- type: script
85
+
parameters:
86
+
action: run
87
+
type: standalone
88
+
chain:
89
+
- access-script
90
+
- navigate-script
91
+
- perform-action-script
92
+
context: mycontext
93
+
user: testuser
94
+
</pre>
95
+
50
96
<H2>Action: loaddir</H2>
51
97
52
98
Loads all of the scripts in the subdirectories under the specified source path to ZAP.
@@ -84,12 +130,13 @@ <H2>YAML definition</H2>
84
130
action: # String: The executed action - available actions: add, remove, run, enable, disable
85
131
type: # String: The type of the script
86
132
engine: # String: The script engine to use - can be used to override the default engine for the file extension
87
-
name: # String: The name of the script, defaults to the file name
133
+
name: # String: The name of the script, defaults to the file name (for single script run; ignored if 'chain' is specified)
134
+
chain: # List: optional; script names to run in sequence (takes precedence over name if both specified)
88
135
source: # String: The full or relative file path, must be readable
89
136
inline: # String: The full script (may be multi-line) - supply this or 'source' not both
90
137
target: # String: The URL to be invoked for "targeted" script type
91
138
context: # String: The name of the context to use when running the script (optional)
92
-
user: # String: The name of the user to use when running the standalone script (optional, requires context) [Currently only supported for Zest scripts]
139
+
user: # String: The name of the user to use when running the Zest standalone script or chain (optional, requires context)
93
140
</pre>
94
141
95
142
The <code>source</code> parameter was previously called <code>file</code>, both will work.
scripts.automation.error.chainReflectionFailed = Job: {0} Failed to prepare chain for execution (Zest may not be loaded or reflection error). First script: ''{1}''
85
+
scripts.automation.error.chainRequiresStandalone = Job {0}: Chain can only be used with standalone scripts
86
+
scripts.automation.error.chainScriptMissingMethods = Job {0}: Script ''{1}'' does not support chaining (missing required methods)
87
+
scripts.automation.error.chainScriptNotFound = Job {0}: Script ''{1}'' in chain not found
88
+
scripts.automation.error.chainScriptNotZestScript = Job {0}: Script ''{1}'' in chain is not a Zest script
89
+
scripts.automation.error.chainScriptNotZestStandalone = Job {0}: Script ''{1}'' in chain is not a Zest standalone script
scripts.automation.warn.chainAndNameBothSpecified = Job {0}: Both 'name' and 'chain' parameters specified, 'name' will be ignored and chain will be processed
106
117
scripts.automation.warn.fileNotNeeded = Job: {0} Source specified but not needed so will be ignored
107
118
scripts.automation.warn.userParameterSetButActionNotRun = Job: {0} User parameter is set but action is not run
Copy file name to clipboardExpand all lines: addOns/scripts/src/main/resources/org/zaproxy/zap/extension/scripts/resources/script-max.yaml
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,10 @@
3
3
action: # String: The executed action - available actions: add, remove, run, loaddir, enable, disable
4
4
type: # String: The type of the script
5
5
engine: # String: The script engine to use - can be used to override the default engine for the file extension
6
-
name: # String: The name of the script, defaults to the file name
6
+
name: # String: The name of the script, defaults to the file name (for single script run; ignored if 'chain' is specified)
7
+
chain: # List: optional; script names to run in sequence (takes precedence over name if both specified)
7
8
source: # String: The full or relative path, must be readable
8
9
inline: # String: The full script (may be multi-line) - supply this or 'source' not both
9
10
target: # String: The URL to be invoked for "targeted" script type
10
11
context: # String: The name of the context to use when running the script (optional)
11
-
user: # String: The name of the user to use when running the standalone script (optional, requires context) [Currently only supported for Zest scripts]
12
+
user: # String: The name of the user to use when running the Zest standalone script or chain (optional, requires context)
Copy file name to clipboardExpand all lines: addOns/scripts/src/test/java/org/zaproxy/zap/extension/scripts/automation/actions/AddScriptActionUnitTest.java
0 commit comments