Gate: packages
Introduction
The “packages” gate allows users to perform checks against the packages discovered in an SBOM. It has a different set of triggers for each kind of rule set:
- Image rule sets — triggers for requiring specific packages, denylisting unwanted packages, filtering on package metadata, and verifying package integrity against the package database. See the example use cases and Reference: packages.
- SBOM rule sets — the
matchtrigger, which Anchore Enterprise evaluates against every package in an app version. See SBOM Rule Sets:matchTrigger.
The packages gate requires the Anchore Enforce license entitlement. See Gate Licensing.
Example Use-cases
Scenario 1
Goal: Create a rule that results in a STOP action if libssl packages are not found in an image SBOM.
Example rule set configuration in Anchore Enterprise
Gate: packages
Trigger: required package
Required Parameters: name = “libssl”
Action: STOP

Scenario 2
Goal: Create a rule that results in a STOP action if libssl-dev packages are found in an image SBOM but running on a version other than 1.1.1-1ubuntu2.1~18.04.23.
Example rule set configuration in Anchore Enterprise
Gate: packages
Trigger: metadata
Optional Parameters: name = “libssl-dev”, name comparison = “=”, version = “1.1.1-1ubuntu2.1~18.04.23”, version comparison = “!=”
Action: STOP

Reference: packages
| Trigger Name | Description | Parameter | Description | Example |
|---|---|---|---|---|
| required_package | Triggers if the specified package and optionally a specific version is not found in the image. | name | Name of package that must be found installed in image. | libssl |
| required_package | Triggers if the specified package and optionally a specific version is not found in the image. | version | Optional version of package for exact version match. | 1.10.3rc3 |
| required_package | Triggers if the specified package and optionally a specific version is not found in the image. | version_match_type | The type of comparison to use for version if a version is provided. | exact |
| verify | Check package integrity against package db in the image. Triggers for changes or removal or content in all or the selected “dirs” parameter if provided, and can filter type of check with the “check_only” parameter. Requires enable_package_db_load to be enabled. See Enable the Package Database. | only_packages | List of package names to limit verification. | libssl,openssl |
| verify | Check package integrity against package db in the image. Triggers for changes or removal or content in all or the selected “dirs” parameter if provided, and can filter type of check with the “check_only” parameter. Requires enable_package_db_load to be enabled. See Enable the Package Database. | only_directories | List of directories to limit checks so as to avoid checks on all dir. | /usr,/var/lib |
| verify | Check package integrity against package db in the image. Triggers for changes or removal or content in all or the selected “dirs” parameter if provided, and can filter type of check with the “check_only” parameter. Requires enable_package_db_load to be enabled. See Enable the Package Database. | check | Check to perform instead of all. | changed |
| denylist | Triggers if the evaluated image has a package installed that matches the named package optionally with a specific version as well. | name | Package name to denylist. | openssh-server |
| denylist | Triggers if the evaluated image has a package installed that matches the named package optionally with a specific version as well. | version | Specific version of package to denylist. | 1.0.1 |
| denylist | Triggers if the evaluated image has a package installed that matches the named package optionally with a specific version as well. | version comparison | The type of comparison to use for version if a version is provided. | > |
| metadata | Triggers on a package type comparison. | type | The type of package. | rpm |
| metadata | Triggers on a package name comparison. | name | The name of the package. Wildcards are supported. | *ssl |
| metadata | Triggers on a package version comparison. | version | The version of the package. Wildcards are supported. | *fips |
The minimum version match of the required_package trigger and the version comparison of the denylist trigger compare versions using the version rules of each package’s type, the same rules Anchore Enterprise uses for vulnerability matching.
Enable the Package Database
The verify trigger requires the package database to be loaded into the policy engine. This setting is disabled by default in newer deployments of Anchore Enterprise, though it was previously enabled by default. Only enable this setting if you intend to use the verify trigger, as loading the package database has a significant performance impact on the database.
You can confirm the current value of this setting from the System -> Configuration screen by searching for “load”.
To enable it, change enable_package_db_load from false to true:
services:
policy_engine:
enable_package_db_load: true
SBOM Rule Sets: match Trigger
In an SBOM rule set, the packages gate’s match trigger fires once for each package in the app version that matches the criteria you set. Use it to fail or flag a release that ships a banned package, or a package older than a minimum version.
| Parameter | Description | Values | Default |
|---|---|---|---|
name | Package name to match. | Any string. With ~= or !~=, a glob pattern. | — |
name_comparison | How to compare name. | =, !=, ~=, !~= | = |
version | Package version to match. | Any string. With ~= or !~=, a glob pattern. | — |
version_comparison | How to compare version. | =, !=, >, >=, <, <=, ~=, !~= | = |
type | Package type, as reported in the SBOM, for example rpm, deb, python, npm or java-archive. | Any string. With ~= or !~=, a glob pattern. | — |
type_comparison | How to compare type. | =, !=, ~=, !~= | = |
A rule must set at least one of name, version and type.
How Packages Are Matched
- Every criterion must match. A package matches only when all of the criteria you set match. Criteria you leave out are not checked.
- Matching ignores case.
Log4j-Coreandlog4j-coreare the same name. ~=and!~=take glob patterns.*matches any run of characters and?matches one character, so aversionof2.*with~=matches every 2.x release.=and!=compare exact strings.>,>=,<and<=compare versions by package type. They use the version rules of each package’s ecosystem, the same rules Anchore Enterprise uses for vulnerability matching, so1.10.0is greater than1.9.0. If a package’s version cannot be compared, the rule records an evaluation error for that package instead of treating it as not matching. Evaluation errors are listed by the experimentalGET /exp/apps/{app_id}/versions/{version_id}/policy/evaluation-errorsendpoint.
Each matching package produces one finding, which names the package’s name, version, type and PURL, and the assets that contain it.
Examples
Fail any release that includes a Log4j 2 core library:
{
"action": "STOP",
"gate": "packages",
"trigger": "match",
"params": [
{ "name": "name", "value": "log4j-core" },
{ "name": "version", "value": "2.*" },
{ "name": "version_comparison", "value": "~=" }
]
}
Warn when a release includes a Java jackson-databind library older than 2.15.0:
{
"action": "WARN",
"gate": "packages",
"trigger": "match",
"params": [
{ "name": "name", "value": "jackson-databind" },
{ "name": "type", "value": "java-archive" },
{ "name": "version", "value": "2.15.0" },
{ "name": "version_comparison", "value": "<" }
]
}
Review Package Findings
- In the Anchore Enterprise GUI, select the Packages gate on the app version’s Compliance tab. See Evaluate Policy Against an App Version.
- With the API, call
GET /apps/{app_id}/versions/{version_id}/policy/findings/packages. - To export the findings as CSV, see Export the Compliance Report.