What is the difference between running a ZAP automation plan with -autorun and checking it with -autocheck?
answer
- one loads and runs, one only loads
- the argument is a source, not a file
- nothing is scanned by a check
- the exit value needs a command-line run
basics
~20 s-autorun loads a plan, creates its environment and runs its jobs. -autocheck loads and validates the same plan and stops there, running none of it. Both accept a file path or an http/https URL as the source.
solid answer
~40 sBoth options come from the `automation` add-on and both take a **source** — a file path, or an `http`/`https` URL that is fetched and treated as the plan. `-autorun` parses the plan, verifies each job, creates the environment and then executes the jobs in order. `-autocheck` performs the same parse and verification and then stops: no environment is created and no job runs, so the target is not touched. Either way, the exit value is set only when ZAP is running as a command-line process, which is why the documented invocation pairs the option with `-cmd`. That makes `-autocheck` the cheap gate for a repository of plans: it catches an unknown job type, an unrecognised environment element, a bad job parameter or a malformed test in seconds.
go deeper
Know that -autorun runs a plan and -autocheck only validates it, that both take a file or a URL, and that the usual pipeline invocation pairs the option with the command-line mode.
Explain that both share one loading path and diverge only after verification, and list what a check can find in the file against this build versus what only a run can establish.
Show the pipeline shape: check every plan on change as a fast gate, run on schedule, and look at the run's own output rather than only its exit value before calling a scan evidence of anything.
Own where plans come from. A plan is a control file for a tool that attacks a system, so whether one may be fetched from a URL, and who may change the one a pipeline runs, is a supply-chain decision rather than a convenience.
## Two options, one loader The `automation` add-on contributes a small family of command-line options, and two of them take a plan: - **`-autorun <source>`** — run the plan. - **`-autocheck <source>`** — check the plan. They share the loading path entirely. Each parses the YAML, reads the environment, resolves every job's `type` against the registry the installed add-ons filled, verifies each job's parameters, and builds each job's tests. Everything that can be discovered from the file alone is discovered by both. They then diverge: 1. `-autorun` creates the environment — bringing the contexts and users described in `env` into existence — and executes the job list in order. 2. `-autocheck` stops. No environment, no jobs, nothing sent to the site under test. Both then set the exit value from what was recorded: an error gives the error value, a warning with no error gives the warning value, and a clean load or run gives a clean one. ## What a check catches, and what it cannot A check is a **static** verdict on the file against **this build**. It catches: - an unknown job type — that is, a job whose owning add-on is not installed here; - an unrecognised element inside `env`, or an environment with no contexts at all; - a job parameter the job does not recognise; - a test with a missing or invalid `onFail`, or an alert test on a job that cannot produce alerts; - a deprecated job, such as `addOns`, which contributes its warning during verification. It cannot tell you anything that only exists at run time: whether the target is reachable, whether the credentials work, whether the crawl finds anything, whether the run will take twenty minutes or four hours. A plan that checks clean can still scan nothing. ## The source may be a URL The argument is deliberately called a **source**, not a filename. If it parses as an `http` or `https` URL the add-on fetches it and treats the response body as the plan; a response that is not a success is itself a failure of the run. Anything else is treated as a path on disk. Two things follow that are easy to miss: - A plan fetched over the network is **whatever that server returned at that moment**. It is a control file for a tool that attacks a target, so where it comes from is a supply-chain question, not a convenience one. - Relative paths inside a plan normally resolve against **the directory holding the plan file**, which is what makes a plan portable between a workstation and a container. A plan fetched from a URL has no file on disk, so its relative paths fall back to the process working directory instead — the same plan, quietly resolving differently. ## The exit value needs a command-line run The framework sets a process exit value **only when ZAP is running as a command-line process**. Run a plan in the desktop or in a long-lived background instance and it still runs, still reports, still writes its output — but nothing sets an exit value for a pipeline to read. That is why the documented invocation pairs the two, as `-cmd -autorun plan.yaml`, and it is the first thing to check when a pipeline step reports success no matter what the plan did. ## Using them together | step | option | what it costs | what it proves | |---|---|---|---| | on every change to a plan | `-autocheck` | seconds | the plan is loadable and complete on this build | | on the schedule you scan | `-autorun` | the length of the scan | what the run actually found | A repository of plans benefits from the first as a fast gate: plans drift as add-ons change under them, and the failure mode of a stale plan is an expensive scheduled job that stops before it starts. The `-autogenmin` and `-autogenmax` options round out the family by writing a template built from the job types the running build actually registers — the honest starting point for a new plan, and the quickest look at what this build offers. One caution about what either option proves. A check and a run both validate the plan against **the build executing them**, so a plan that checks clean on a workstation says nothing about the image a pipeline uses, and the reverse is equally true. Run the check on the same image that will run the plan, or the gate is measuring the wrong thing.
- What can `-autocheck` not tell you?Anything that only exists at run time: whether the target answers, whether the login works, whether the crawl reaches anything, how long the run takes. It is a verdict on the file against this build, so a plan can check clean and still scan nothing.
- Why is the argument called a source rather than a filename?Because it may be an http or https URL as well as a path. The add-on fetches the URL and treats the response as the plan, and an unsuccessful response fails the run. A plan fetched that way has no file on disk, so relative paths inside it resolve against the working directory.
- A pipeline step running a plan always reports success. What would you check first?Whether ZAP was started as a command-line process. The framework sets an exit value only in that mode, so the same plan run in a long-lived background instance produces output but nothing for the shell to act on, and the step passes whatever happened.
saying these in an interview costs you the question
- Thinks -autocheck performs a harmless dry-run scan
- Assumes the plan argument must be a local file
- Expects an exit value from any way of running a plan
- Says a clean check proves the target will be scanned
- Believes a checked plan is portable to any build