For the complete documentation index, see llms.txt. This page is also available as Markdown.

Write policy definitions

Learn how to write policy definitions for SBOM policy files.

When you create SBOM policies, you define rules for open-source component usage based on criteria such as component name, version, license, PURL, and supplier.

The SCS module supports deny list and allow list policies. Your policy files can include both lists. This topic explains how to write rules for each list.

Use OPA policies

You can define OPA policy sets at project, org, and account levels. A typical SBOM policy set has three sections:

  • deny_list: Rules for denying the use of components based on specified criteria.

  • allow_list: Rules for allowed licenses, suppliers, and PURLs.

  • Enforcement Logic: Do not edit this part. It provides policy examples and logic that ensures your policies are consistently enforced.

When creating a policy set for SBOM, set the Entity Type to SBOM.

Sample policies

Harness has the following samples in the Policy Library to help you create rules for SBOM policy enforcement:

  • SBOM - Allow list

  • SBOM - Deny list

  • SBOM - Allow and Deny list

Here is an example of a sample policy:

Supported operators

In this section you can find the operators supported by SBOM OPA policies

String operators

Version operators

Sample rules

In this section, you can find examples of various rules that you can create for SBOM policy enforcement

Sample deny list rules

Block 'curl' below a Certain Version

This rule blocks the usage of 'curl' if the version is 3.0.0 or lower.

Block Versions of 'log4j' using Regex

Targets any component matching the regex '.log4j.' that is below version 3.0.0.

Block 'busybot' Between Version 3.0.0 and 5.0.0

Prohibits the usage of 'busybot' for versions strictly between 3.0.0 and 5.0.0.

Block 'curl' at or Above a Certain Version

Blocks 'curl' if its version is 3.0.0 or higher.

Block 'curl' Above a Certain Version

Blocks 'curl' if its version is greater than 3.0.0.

Block 'curl' Except a Specific Version

Blocks all versions of 'curl' except for 3.0.0.

Block Specific 'log4j' Version

Blocks the specific version 3.0.0 of any component matching '.log4j.'.

Block Components with Regex Pattern in Name

Blocks any component whose name starts with 'c'.

Block Components with a Specific License

Blocks components with the 'BSD-3-Clause' license.

Block Components Within a Version Range

Targets components whose versions are greater than or equal to 1.3.0 and less than 2.12.0.

Block Components from a Specific Supplier

Blocks components supplied by "Red Hat, Inc."

Sample allow list rules

Allow list rules are grouped under licenses, suppliers or purls

Allow a list of licenses based on various criteria

This group of rules permits components based on their license types. The first rule explicitly allows components with the 'MIT' license. The next two rules use regex to allow any licenses containing 'Apache' or 'eclipse' in their names, respectively. This grouping ensures a broad but specific allowance based on license criteria.

Allow a list of suppliers

These rules allow components from suppliers that include ‘Red Hat' or 'Apache’ in their names. The use of regex (~) allows for flexible matching to any supplier name that contains 'Red Hat', accommodating variations in naming.

Last updated

Was this helpful?