> For the complete documentation index, see [llms.txt](https://docs.debricked.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.debricked.com/product/automation/policy-as-code.md).

# Policy as Code

Policy as Code lets you define Fortify SCA automation policies in a standalone JSON file and include them in a scan request.

Policy as Code lets you define Fortify SCA automation policies in a JSON file. Include the file with a scan request.

Name the policy file `debricked_policy.json`. It is independent of `debricked.config`. Use it to:

* Keep security and compliance policies under version control.
* Apply policies to stateless scan requests.
* Include policies in Fortify on Demand (FoD) scan payloads.
* Define consistent, deterministic automation behavior.
* Validate policies before executing automation rules.
* Manage policy configuration alongside application configuration.

The `debricked_policy.json` file contains three main sections:

* schemaVersion
* settings
* automations

Each automation rule defines:

1. Conditions that determine when the rule matches.
2. Actions that Fortify SCA performs when those conditions match.

### Getting started

Create a JSON file named `debricked_policy.json`. This minimal example creates one automation rule:

```json
{
  "schemaVersion": "1.0",
  "settings": {
    "executionMode": "fileOnly",
    "invalidPolicyBehavior": "fail"
  },
  "automations": {
    "rules": [
      {
        "enabled": true,
        "conditions": [
          {
            "subject": "dependency",
            "op": "is_in",
            "value": [
              "denied_list"
            ],
            "conj": "and"
          }
        ],
        "actions": {
          "failPipeline": false,
          "warnPipeline": true,
          "markUnaffected": false,
          "markVulnerable": false,
          "ignoreIfMarkedUnaffected": false,
          "notifyEmailAddresses": [],
          "notifyRoles": [],
          "webhookUrl": "",
          "webhookSecret": ""
        }
      }
    ]
  }
}
```

{% hint style="info" %}
Use the supplied sample `debricked_policy.json` file as a starting point. Then modify its rules for your organization.
{% endhint %}

### File structure

#### schemaVersion

`schemaVersion` identifies the Policy as Code contract version. Use the following value for version 1:

```json
"schemaVersion": "1.0"
```

Fortify SCA rejects unsupported schema versions during policy validation.

#### settings

The `settings` object controls how Fortify SCA processes the policy file.

```json
"settings": {
  "executionMode": "fileOnly",
  "invalidPolicyBehavior": "fail"
}
```

| Value                  | Behavior                                                                  |
| ---------------------- | ------------------------------------------------------------------------- |
| `fileOnly`             | Evaluates only the rules in `debricked_policy.json` for the scan request. |
| `mergeWithWebappRules` | Evaluates file rules together with rules configured in Fortify SCA.       |

**invalidPolicyBehavior**

`invalidPolicyBehavior` determines how Fortify SCA handles an invalid policy file.

| Value  | Behavior                                                |
| ------ | ------------------------------------------------------- |
| `fail` | Fails the scan request when the policy file is invalid. |
| `warn` | Reports a warning when the policy file is invalid.      |

### Defining automation rules

Define automation rules in `automations.rules`. Each rule contains `enabled`, `conditions`, and `actions`.

```json
"automations": {
  "rules": []
}
```

#### Enable or disable a rule

Set `enabled` to `true` to evaluate a rule. Set it to `false` to keep it in the file without evaluating it.

```json
"enabled": true
```

#### Conditions

Conditions define what must match before Fortify SCA executes a rule's actions.

```json
{
  "subject": "licenseRisk",
  "op": "greater",
  "value": ["4"],
  "conj": "and"
}
```

| Property  | Description                                                   |
| --------- | ------------------------------------------------------------- |
| `subject` | The item or attribute being evaluated.                        |
| `op`      | The comparison operator.                                      |
| `value`   | The comparison value or values. Supply values as an array.    |
| `conj`    | How the condition combines with other conditions in the rule. |

#### Supported condition subjects

* `vulnerability`
* `dependency`
* `branch`
* `cvss`
* `rule`
* `license`
* `licenseFamily`
* `licenseRisk`
* `vulnerabilityDiscoveredDate`
* `securityScore`
* `contributorScore`
* `popularityScore`
* `scope`
* `licenseReviewStatus`
* `dependencyDepth`
* `cve`
* `dependencyAge`
* `dependencyVersion`

#### Supported condition operators

* `is`
* `less`
* `greater`
* `is_not`
* `untriggered`
* `is_more_than`
* `is_in`
* `is_less_than`

{% hint style="warning" %}
Not every operator works with every subject. Each `subject`, `op`, and `value` combination must be supported and use the expected value format.
{% endhint %}

#### Combining conditions with AND and OR

Use `conj` to control condition grouping:

* `and` keeps the condition in the current group.
* `or` starts a new OR group.

Fortify SCA evaluates conditions using this pattern:

```
(A AND B) OR (C AND D) OR ...
```

**Mixed AND/OR example**

This rule matches either group:

* CVSS is greater than low **and** the branch is `feature`.
* The dependency is in `denied_list` **and** CVSS is greater than medium.

```json
{
  "schemaVersion": "1.0",
  "settings": {
    "executionMode": "fileOnly",
    "invalidPolicyBehavior": "fail"
  },
  "automations": {
    "rules": [
      {
        "enabled": true,
        "conditions": [
          {
            "subject": "cvss",
            "op": "greater",
            "value": [
              "low"
            ],
            "conj": "and"
          },
          {
            "subject": "branch",
            "op": "is",
            "value": [
              "feature"
            ],
            "conj": "and"
          },
          {
            "subject": "dependency",
            "op": "is_in",
            "value": [
              "denied_list"
            ],
            "conj": "or"
          },
          {
            "subject": "cvss",
            "op": "greater",
            "value": [
              "medium"
            ],
            "conj": "and"
          }
        ],
        "actions": {
          "failPipeline": true,
          "warnPipeline": false,
          "markUnaffected": false,
          "markVulnerable": false,
          "ignoreIfMarkedUnaffected": true,
          "notifyEmailAddresses": [
            "security@company.com"
          ],
          "notifyRoles": [],
          "webhookUrl": "",
          "webhookSecret": ""
        }
      }
    ]
  }
}
```

#### Dependency lists

When `subject` is `dependency` and `op` is `is_in`, use one of these list values:

* `allowed_list`
* `denied_list`
* `allowed_list_direct_only`
* `denied_list_direct_only`

```json
{
  "subject": "dependency",
  "op": "is_in",
  "value": ["denied_list"],
  "conj": "and"
}
```

### Actions

| Action                     | Purpose                                               |
| -------------------------- | ----------------------------------------------------- |
| `failPipeline`             | Fails the pipeline when the rule matches.             |
| `warnPipeline`             | Generates a pipeline warning.                         |
| `markUnaffected`           | Marks matching vulnerabilities as unaffected.         |
| `markVulnerable`           | Marks the matching item as vulnerable.                |
| `ignoreIfMarkedUnaffected` | Ignores vulnerabilities already marked as unaffected. |
| `notifyEmailAddresses`     | Notifies the specified email addresses.               |
| `notifyRoles`              | Notifies users assigned the specified roles.          |
| `webhookUrl`               | Specifies the webhook destination.                    |
| `webhookSecret`            | Specifies the secret associated with the webhook.     |

### Troubleshooting

#### The policy file is rejected

Verify the following:

* The file contains valid JSON and is named `debricked_policy.json`.
* `schemaVersion` is set to `"1.0"`.
* `executionMode` and `invalidPolicyBehavior` use supported values.
* `automations.rules` contains at least one rule.
* Each condition uses a supported subject, operator, and value format.
* No rule sets both `failPipeline` and `warnPipeline` to `true`.
* No rule sets both `markUnaffected` and `markVulnerable` to `true`.

#### A rule is not evaluated

Verify the following:

* `enabled` is set to `true`.
* The rule is defined under `automations.rules`.
* The condition values match the scanned project.
* The selected operator is supported for the condition subject.
* The AND/OR grouping matches the intended logic.
* The selected execution mode includes the rule source.

#### Web application rules are not evaluated

When `executionMode` is set to `fileOnly`, only rules defined in `debricked_policy.json` are evaluated.

To evaluate file-based rules together with rules configured in the web application, set `executionMode` to `mergeWithWebappRules`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.debricked.com/product/automation/policy-as-code.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
