> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/security-testing-orchestration/use-sto/sto-scanner-configuration/zap/zap-scanner-reference.md).

# Zed Attack Proxy (ZAP) step configuration

You can scan your application instances and ingest results from [Zed Attack Proxy (ZAP)](https://www.zaproxy.org).

For an example workflow, go to the [DAST app scans using Zed Attack Proxy (ZAP) tutorial](/security-testing-orchestration/use-sto/sto-scanner-configuration/zap/dast-scan-zap.md).

### Important notes for running ZAP scans in STO <a href="#important-notes-for-running-zap-scans-in-sto" id="important-notes-for-running-zap-scans-in-sto"></a>

* Harness STO currently supports the following ZAP features:
  * AJAX spidering with Firefox and Selenium. Other browsers such as Chrome are not currently supported.
  * [Script-based authentication](https://www.zaproxy.org/docs/desktop/start/features/authmethods/#scriptBased).
  * [Form-based authentication](https://www.zaproxy.org/docs/desktop/start/features/authmethods/#formBased).
  * [Script-based session management](https://www.zaproxy.org/docs/desktop/start/features/sessionmanagement/#sbsm) – ECMAScript / JavaScript using Nashorn engine.
    * Other languages such as Zest, Groovy, Python, etc. are not currently supported.
* ZAP is a highly configurable tool with many options. You should verify that your context file and your authentication and other scripts work as intended before adding them to your STO pipeline.
* Add the following shared paths (**Overview** > **Shared Paths**) to your scan stage and copy your ZAP scripts and files to these paths:
  * Copy hosts and urlFile files to:
    * `/shared/customer_artifacts/hosts/`
    * `/shared/customer_artifacts/urlFile/`
  * Copy context files to `/shared/customer_artifacts/context`.
  * You also need to specify the [Context name](#context-name) to use for the scan.
    * If you're including context, hosts, and/or urlFile files in the same pipeline, they all need to be set to the value passed for the context name. For example:
      * `/shared/customer_artifacts/context/sto.context`
      * `/shared/customer_artifacts/hosts/sto.context`
      * `/shared/customer_artifacts/urlFile/sto.context`
  * Copy other scripts to `/shared/customer_artifacts/scripts/<script-type>/`.
    * Examples:
      * `/shared/customer_artifacts/scripts/session`
      * `/shared/customer_artifacts/scripts/authentication`
    * For other script paths, go to the [ZAP community-scripts repo](https://github.com/zaproxy/community-scripts/tree/main).

#### Root access requirements <a href="#root-access-requirements" id="root-access-requirements"></a>

If you want to add trusted certificates to your scan images at runtime, you need to run the scan step with root access.

You can utilize custom STO scan images and pipelines to run scans as a non-root user. For more details, refer [Configure your pipeline to use STO images from private registry](/security-testing-orchestration/troubleshooting-and-resources/sto-use-cases/set-up-sto-pipelines/configure-pipeline-to-use-sto-images-from-private-registry.md).

#### For more information <a href="#for-more-information" id="for-more-information"></a>

The following topics contain useful information for setting up scanner integrations in STO:

* [What's supported in STO](/security-testing-orchestration/new-to-sto/sto-whats-supported/sto-deployments.md)
* [Security Testing Orchestration FAQs](/security-testing-orchestration/troubleshooting-and-resources/faqs.md)
* [Optimize STO pipelines](/security-testing-orchestration/troubleshooting-and-resources/sto-use-cases/set-up-sto-pipelines/optimize-sto-pipelines.md)

### ZAP step settings for STO scans <a href="#zap-step-settings-for-sto-scans" id="zap-step-settings-for-sto-scans"></a>

The recommended workflow is to add a ZAP step to a Security Tests or CI Build stage and then configure it as described below.

#### Scan <a href="#scan" id="scan"></a>

**Scan Mode**

* **Orchestration** Configure the step to [run a scan](/security-testing-orchestration/new-to-sto/key-concepts/run-an-orchestrated-scan-in-sto.md) and then ingest, normalize, and deduplicate the results.
* **Ingestion** Configure the step to [read scan results from a data file](/security-testing-orchestration/new-to-sto/key-concepts/ingest-scan-results-into-an-sto-pipeline.md) and then ingest, normalize, and deduplicate the data.

**Scan Configuration**

The predefined configuration to use for the scan. All scan steps have at least one configuration.

The following options are supported for Zap scans:

* **Default**
* **Standard** `scanMode` = [`active`](https://www.zaproxy.org/docs/desktop/start/features/ascan/), `scanType` = [`standard`](https://www.zaproxy.org/docs/desktop/start/features/modes/)
* **Attack** `scanMode` = [`active`](https://www.zaproxy.org/docs/desktop/start/features/ascan/), `scanType` = [`attack`](https://www.zaproxy.org/docs/desktop/start/features/modes/)
* **Quick** `scanMode` = [`active`](https://www.zaproxy.org/docs/desktop/start/features/ascan/), `scanType` = [`standard`](https://www.zaproxy.org/docs/desktop/start/features/modes/), `quickMode` = `true`

  When Quick mode is enabled, the [Maximum depth to crawl](https://www.zaproxy.org/docs/desktop/addons/spider/options/#maximum-depth-to-crawl) is set to 1.

#### Target <a href="#target" id="target"></a>

**Type**

* **Instance** Scan a running application.

**Target and variant detection**

When **Auto** is enabled for application instances, the step detects these values as follows:

* The target is based on the **Instance Domain** and **Path** defined in the step or runtime input, for example `https://qa.jpgr.org:3002/login/us`.
* The variant is the UTC timestamp when the step scanned the instance.

Note the following:

* **Auto** is not available when the **Scan Mode** is Ingestion.
* **Auto** is the default selection for new pipelines. **Manual** is the default for old pipelines, but you might find that neither radio button is selected in the UI.
* You should carefully consider the [baseline you want to specify](/security-testing-orchestration/troubleshooting-and-resources/sto-use-cases/set-up-sto-pipelines/set-up-baselines.md) for your instance target. Every target needs a baseline to enable the full suite of STO features. Here are a few options:
  * Specify a RegEx baseline that captures timestamps. This ensures that every new scan compares issues in the new scan vs. the previous scan. Then it updates the baseline to the current scan.

    You can use this RegEx to capture timestamps: `\d{2}/\d{2}/\d{4}\,\s\d{2}\:\d{2}\:\d{2}`
  * Specify a fixed baseline.

    1. Scan the instance using a manual variant name.
    2. Select the baseline as a fixed value.
    3. Update the step to use auto-detect for future scans.

    This ensures that future scans get compared with one fixed baseline.

**Name**

The identifier for the [target](/security-testing-orchestration/new-to-sto/key-concepts/targets-and-baselines.md), such as `codebaseAlpha` or `jsmith/myalphaservice`. Descriptive target names make it much easier to navigate your scan data in the STO UI.

It is good practice to [specify a baseline](/security-testing-orchestration/new-to-sto/key-concepts/targets-and-baselines.md#every-target-needs-a-baseline) for every target.

**Variant**

The identifier for the specific variant to scan. This is usually the branch name, image tag, or product version. Harness maintains a historical trend for each variant.

**Workspace**

The workspace path on the pod running the scan step. The workspace path is `/harness` by default.

You can override this if you want to scan only a subset of the workspace. For example, suppose the pipeline publishes artifacts to a subfolder `/tmp/artifacts` and you want to scan these artifacts only. In this case, you can specify the workspace path as `/harness/tmp/artifacts`.

Additionally, you can specify individual files to scan as well. For instance, if you only want to scan a specific file like `/tmp/iac/infra.tf`, you can specify the workspace path as `/harness/tmp/iac/infra.tf`

#### Instance <a href="#instance" id="instance"></a>

**Domain**

Domain of the application instance to scan. You can include the full path to the app in this field, or split the full path between the **Domain** and the **Path** fields. Example: `https://myapp.io/portal/us`

**Protocol**

HTTPS (default) or HTTP.

**Port**

The TCP port used by the scanned app instance.

**Path**

Path to append to the application instance domain, if you're splitting the full path between the **Domain** and **Path** settings. For example, you might specify the domain as `https://myapp.io` and the path as `/portal/us`.

#### Scan Tool <a href="#scan-tool" id="scan-tool"></a>

**Context Name**

The ZAP context file to use for the scan. You need to add the following shared path (**Overview** > **Shared Paths**) to the stage and copy your file to this path: - `/shared/customer_artifacts/context/`

**Port**

The TCP port to communicate with the scanner. You can specify this to override the default port for that scanner.

#### Ingestion File <a href="#ingestion-file" id="ingestion-file"></a>

The path to your scan results when running an [Ingestion scan](/security-testing-orchestration/new-to-sto/key-concepts/ingest-scan-results-into-an-sto-pipeline.md), for example `/shared/scan_results/myscan.latest.sarif`.

* The data file must be in a [supported format](/security-testing-orchestration/new-to-sto/sto-whats-supported/scanners.md#supported-ingestion-formats) for the scanner.
* The data file must be accessible to the scan step. It's good practice to save your results files to a [shared path](/continuous-integration/new-to-harness-ci/key-concepts.md#stages) in your stage. In the visual editor, go to the stage where you're running the scan. Then go to **Overview** > **Shared Paths**. You can also add the path to the YAML stage definition like this:

  ```yaml
      - stage:
        spec:
          sharedPaths:
            - /shared/scan_results
  ```

#### Log Level <a href="#log-level" id="log-level"></a>

The minimum severity of the messages you want to include in your scan logs. You can specify one of the following:

* **DEBUG**
* **INFO**
* **WARNING**
* **ERROR**

#### Fail on Severity <a href="#fail-on-severity" id="fail-on-severity"></a>

Every STO scan step has a **Fail on Severity** setting. If the scan finds any vulnerability with the specified [severity level](/security-testing-orchestration/new-to-sto/key-concepts/severities.md) or higher, the pipeline fails automatically. You can specify one of the following:

* **`CRITICAL`**
* **`HIGH`**
* **`MEDIUM`**
* **`LOW`**
* **`INFO`**
* **`NONE`** — Do not fail on severity

The YAML definition looks like this: `fail_on_severity : critical # | high | medium | low | info | none`

#### Settings <a href="#settings" id="settings"></a>

You can use this field to specify environment variables for your scanner.

#### Additional Configuration <a href="#additional-configuration" id="additional-configuration"></a>

The fields under **Additional Configuration** vary based on the type of infrastructure. Depending on the infrastructure type selected, some fields may or may not appear in your settings. Below are the details for each field

* Override Security Test Image
  * [Container Registry](/security-testing-orchestration/troubleshooting-and-resources/sto-use-cases/set-up-sto-pipelines/configure-pipeline-to-use-sto-images-from-private-registry.md#step-level-override)
  * [Image Tag](/security-testing-orchestration/troubleshooting-and-resources/sto-use-cases/set-up-sto-pipelines/configure-pipeline-to-use-sto-images-from-private-registry.md#step-level-override)
* [Privileged](/continuous-integration/use-harness-ci/use-harness-ci/manage-dependencies/background-step-settings.md#privileged)
* [Image Pull Policy](/continuous-integration/use-harness-ci/use-harness-ci/manage-dependencies/background-step-settings.md#image-pull-policy)
* [Run as User](/continuous-integration/use-harness-ci/use-harness-ci/manage-dependencies/background-step-settings.md#run-as-user)
* [Set Container Resources](/continuous-integration/use-harness-ci/use-harness-ci/manage-dependencies/background-step-settings.md#set-container-resources)
* [Timeout](/continuous-integration/use-harness-ci/use-harness-ci/run-step-settings.md#timeout)

#### Advanced settings <a href="#advanced-settings" id="advanced-settings"></a>

In the **Advanced** settings, you can use the following options:

* [Conditional Execution](/harness-ai/use-harness-platform/pipelines/step-skip-condition-settings.md)
* [Failure Strategy](/harness-ai/use-harness-platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps.md)
* [Looping Strategy](/harness-ai/use-harness-platform/pipelines/looping-strategies/looping-strategies-matrix-repeat-and-parallelism.md)
* [Policy Enforcement](/harness-ai/use-harness-platform/governance/policy-as-code/harness-governance-overview.md)

### Configure ZAP as a Built-in Scanner <a href="#configure-zap-as-a-built-in-scanner" id="configure-zap-as-a-built-in-scanner"></a>

The ZAP scanner is available as a built-in scanner in STO. Configuring it as a built-in scanner enables the step to automatically perform scans using the free version without requiring any licenses. Follow these steps to set it up:

1. Search for **DAST** in the step palette or navigate to the **Built-in Scanners** section and select the **DAST** step.
2. Select **Aqua Trivy** from the list of scanners.
3. Expand the **Additional CLI Flags** section if you want to configure optional CLI flags.
4. Configure the **Domain Information** by setting the [Domain](#domain).
5. Click **Add Scanner** to save the configuration.

The scanner will automatically use the free version, detect scan targets, and can be further configured by clicking on the step whenever needed.
