> 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/3.0/new-to-sto/key-concepts/fail-pipelines-by-severity.md).

# Fail pipelines based on scan results

You can set up your pipelines to fail automatically if a scan step detects any issues that meet your failure criteria. This is good practice for all integrated pipelines because it ensures that the pipeline doesn't build and publish updates with serious vulnerabilities.

### Basic workflow to fail pipelines by severity in STO <a href="#basic-workflow-to-fail-pipelines-by-severity-in-sto" id="basic-workflow-to-fail-pipelines-by-severity-in-sto"></a>

### Use Policy as Code to fail pipelines and notify users in STO <a href="#use-policy-as-code-to-fail-pipelines-and-notify-users-in-sto" id="use-policy-as-code-to-fail-pipelines-and-notify-users-in-sto"></a>

You can implement failure-handling mechanisms using [Harness Policy as Code](/harness-ai/use-harness-platform/governance/policy-as-code.md). Using policies to stop pipelines has the following advantages:

* You can define one set of policies based on your organization's requirements and then enforce these policies across all pipelines. This allows for centralized enforcement.
* You can define advanced policies such as "The target can't have any critical or high-severity issues, or any medium-severity issues that aren't in the target's baseline."
* Because the pipeline fails after (not during) the scan, you can view the test results in detail after the pipeline fails. You can include the scan results in automatic email or Slack notifications when a target violates specific policies.

For an example workflow, go to [Create OPA policies to stop STO pipelines automatically](/security-testing-orchestration/3.0/use-sto/enforce-sto-policies-for-governance/create-opa-policies.md).
