Repository navigation
Tamp Zap
Wrapper for ZAP (Zed Attack Proxy) — dynamic application security testing against a deployed target. SARIF is native, so there is no converter step.
using Tamp.Zap;Full reference: https://github.com/tamp-build/tamp-zap.
Naming. ZAP left OWASP in September 2023 (to the Linux Foundation's Software Security Project), and in September 2024 the core maintainers joined Checkmarx and it was rebranded ZAP by Checkmarx. It is still Apache-2.0. If a contract or policy says "OWASP ZAP", this is that tool — worth reconciling explicitly in compliance paperwork rather than leaving an auditor to infer it.
Every other scanner in the security pipeline reads artefacts at rest — source, a lockfile, an image, a repo's history. ZAP needs a running application with a URL, which changes where it belongs in a build: it cannot run in the same job that produced the package, only after something has been deployed.
That makes a deploy a prerequisite, not a detail. See Failure Handling for the "deploy succeeded but the scan target isn't up yet" shape.
Zap.Automation(s => …) // the Automation Framework — canonical
Zap.PackagedScan(s => …) // zap-baseline / zap-full-scan / zap-api-scanThe packaged scripts are the better-known entry point and the wrong default. They hardcode report handling and cannot express an authentication context.
A real application has more than one auth surface — anonymous routes, a token-authenticated API, a session-authenticated UI. A single packaged scan only ever sees the first. That is how a team ends up with a green DAST scan that never got past the login page: nothing failed, nothing was tested.
The Automation Framework composes contexts, authentication, spec import, spidering, active scanning and reporting as declarative jobs in one plan. Zap.Automation drives that.
You do not hand-author the Automation Framework schema. ZapAutomationPlan emits one plan per auth surface:
ZapAutomationPlan.Anonymous(url, reportFile) // unauthenticated routes
ZapAutomationPlan.Active(…) // session-authenticated UI
ZapAutomationPlan.Api(…) // OpenAPI spec import, token auth
ZapAutomationPlan.Spa(…) // client-rendered app (AJAX spider)
ZapAutomationPlan.Write(path, planYaml) // -> AbsolutePath, for SetPlanFileZapAutomationPlan.DefaultAssetExcludes drops static assets from the scan scope. Images, fonts and bundles are not an attack surface worth spidering, and excluding them is most of the difference between a scan that finishes and one that times out.
ZapAutomationPlan.SarifReportFileOnDisk(reportFile) resolves where the plan will actually write its SARIF — use it rather than assuming, because the plan's report path is relative to the container's work directory, not the runner's. That mismatch is the single most common reason a scan passes and the pipeline then finds no evidence file.
The default mode runs the official image, which bundles a JRE. The alternative is a local zap.sh with a JRE 17+.
In Docker mode the work directory is bind-mounted, so every path in the plan is a path inside the container. SetWorkDirectory is the host side of that mount and is required in Docker run mode — the wrapper refuses the plan without it rather than guessing. SetContainerWorkDirectory overrides the other side. A plan that names a host path will fail to find its input, or write its report somewhere you are not looking.
Shared by both verbs (ZapSettingsBase):
| Area | Setting |
|---|---|
| Run mode |
SetRunMode (Docker or local zap.sh), SetImage, SetNetworkMode, SetDockerCommand, SetZapCommand
|
| Paths |
SetWorkDirectory (required in Docker mode), SetContainerWorkDirectory, SetWorkingDirectory
|
| Reports |
SetJsonReportFile, SetHtmlReportFile
|
| Diagnostics |
SetDebug, SetIgnoreWarnings
|
| Environment |
SetEnvironmentVariable, SetSecretEnvironmentVariable, SetContainerUser
|
| Escape hatches |
AddZapArgument, AddDockerArgument
|
Automation adds SetPlanFile — a host path, which in Docker mode must sit under WorkDirectory or the container will not see it. PackagedScan adds SetKind (baseline / full / api), SetTarget, SetApiFormat, SetSpiderMinutes, SetAjaxSpider, SetPassiveScanTimeoutMinutes, SetHeadless and SetConfig.
SetNetworkMode is the one people need and don't expect: a container scanning an app on the runner's own localhost cannot reach it on the default bridge network.
An authenticated plan needs a bearer token or session cookie, and a plan file is a file on disk that gets archived. Don't put the credential in it.
SetSecretEnvironmentVariable(name) forwards a variable by name only, inheriting the value from the runner. The value never appears on the command line or in the plan file; the plan references it as ${NAME}:
var scan = Zap.Automation(s => s
.SetWorkDirectory(SecurityArtifactsDir)
.SetPlanFile(plan)
.SetSecretEnvironmentVariable("ZAP_BEARER_TOKEN")); // plan says ${ZAP_BEARER_TOKEN}SetEnvironmentVariable(name, value) sets a literal and is for non-sensitive configuration only.
Target SecurityScanZap => _ => _
.Description("ZAP DAST scan against the deployed app; SARIF for the security pipeline.")
.DependsOn(Deploy)
.Executes(() =>
{
var plan = ZapAutomationPlan.Write(
SecurityArtifactsDir / "zap-anon.yaml",
ZapAutomationPlan.Anonymous(TargetUrl, "zap-anon.sarif"));
var scan = Zap.Automation(s => s
.SetWorkDirectory(SecurityArtifactsDir)
.SetPlanFile(plan));
var rc = ProcessRunner.Execute(scan, Console.Out, Console.Error);
if (rc != 0) throw new Exception($"zap exited with {rc}");
});ZAP writes an explicit per-result level, so its findings arrive with a severity of their own rather than inheriting one from the rule. That matters because SARIF 2.1.0 §3.27.10 lets a result omit level and defer to the rule's defaultConfiguration — and a scanner that does so was mis-read by Tamp before 1.21.0 (tamp#166): the absent member was overwritten with default(SarifLevel), i.e. None, and written back into the evidence file as "level": "none".
ZAP's own output was therefore largely unaffected. Scanners that do lean on defaultConfiguration were not, so if you ingest ZAP alongside others, 1.21.0 is still the floor worth pinning.
- Module Catalog
- Tamp.Nuclei — the complement: template-driven probing and API fuzzing against the same deployed target
- Tamp.CodeQL — SAST; reads code at rest, where ZAP reads a running app
- Failure Handling
- Satellite repo: https://github.com/tamp-build/tamp-zap
The example(s) above use the fluent Set*-chain shape. Every wrapper verb on this page also accepts a new XxxSettings { ... } object-init form. Both produce identical CommandPlans; the fluent shape stays canonical in docs and the tamp init template. See Build Script Authoring → Two authoring styles for the side-by-side comparison.
Start here
Modules
- Module Catalog (canonical list, 50+ satellites)
- .NET toolchain
- Containers
- JS toolchain
- Supply-chain security
- Runtime security (DAST)
Analyzers
Tooling
Execution
CI integration
Editor integration
Migration
Reference
Project