Licence policy
The licence policy decides what a dependency’s licence means in two places:
- Pull requests. The licence scan judges the
licences of a pull request’s dependencies, and the
fremforge/license-scancheck blocks or warns. - Downloads. The package policy judges the licences of a file in your registry before it may be downloaded.
Both read the same lists. Open it at Security › Policies › Licence policy. Only an organisation owner can save it.
The rules
| Setting | Pull requests | Downloads |
|---|---|---|
| Allowed licences | Always pass. They are never blocked or flagged by the threshold. | Pass. |
| Downloads: allowed licences only | No effect. | Every licence not on the allow list is refused. Needs at least one allowed licence. |
| Denied licences | Block the merge. | Refused. |
| Licences that warn | Advisory finding. | Allowed with a warning. |
| Unknown licence | allow, warn or block a licence that is missing or is not an SPDX expression. | The same. |
| Several licences | all: every licence a component declares must pass. any: one passing licence is enough. | The same, for an expression such as MIT OR GPL-3.0-only. |
| Pull requests: block at | A licence on no list blocks at or above this level and is advisory below it. The default is restricted. | No threshold. |
List entries are SPDX identifiers, one per line, such as MIT,
LicenseRef-acme or GPL-2.0-only WITH Classpath-exception-2.0. Matching
ignores case. A licence can be on one list only. Each list holds up to 100
entries. In an expression each licence is checked on its own: with OR one
passing licence is enough, with AND every licence must pass.
When pull requests and downloads still differ
Before this page existed, each scope had its own lists, on the Licences tab and on the Package policies page. Nothing was migrated. If your two sets already agree, the page shows them as one policy. If they differ, the page says so and fills the form with a proposal in which the stricter rule wins for each scope:
- the denied licences of both;
- the warned licences of both, without the denied ones;
- the stricter action for unknown licences;
allfor several licences when either scope saidall;- for allow lists: the licences on both lists, or the one list that has entries. A licence that is also denied or warned leaves the allow list.
An allow list cannot always be merged without loosening a scope. In those cases the page shows a note. For example, a download allow list becomes the allow list for pull requests too, so those licences start to pass pull requests.
Nothing changes until you save.
See the result before you save
Under What saving changes the page lists:
- every stored setting that changes, for pull requests and for downloads;
- every licence whose result changes, with the result before and after in each scope. It checks common licences and every licence your pull requests have met.
Save licence policy is offered only for the policy whose changes are on screen. If you edit the form, choose Preview changes first. A save that would change nothing is not offered.
Not part of this policy
- Whether pull requests are scanned. Turn licence scanning on or off on Security › Policies › Scanners.
- Download gate mode. Off, Shadow or Enforce stays on Package policies.
- Per-repository overrides of the pull request rules. They are at the bottom of this page, see Per-repository overrides.
- Per-type licence settings in a package policy. A package type that sets its own licence rules keeps them. The page lists those types.
- Exceptions for one component and licence.
API
| Endpoint | Scope | Does |
|---|---|---|
GET /orgs/{org}/licence-policy | policy:read | The policy (unified: true), or policy: null with the stricter-wins proposal and its proposal_notes. Also the stored fields of each scope and package_policy_version. |
POST /orgs/{org}/licence-policy/preview | policy:read | Read-only. The changes per scope and the licences whose result changes. |
PUT /orgs/{org}/licence-policy | policy:write | Saves the policy to both scopes. Every field is required. Send the package_policy_version you read. |
curl -X PUT "https://frem.sh/_app/api/v1/orgs/acme/licence-policy" \
-H "Authorization: Bearer $FREMFORGE_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"allow": ["MIT", "Apache-2.0", "BSD-3-Clause"],
"deny": ["AGPL-3.0-only", "SSPL-1.0"],
"warn": ["MPL-2.0"],
"allow_only_downloads": false,
"unknown": "warn",
"multiple": "all",
"block_severity": "restricted",
"package_policy_version": 7
}'A stale package_policy_version is refused with 409 policy-version-conflict. A licence on two lists is refused with 400 licence-on-two-lists. A save is audited as security.licence_policy.updated
with every changed field. The download side is also audited as
package_policy.updated.
The older endpoints still work and write one scope only:
PUT /orgs/{org}/code-security/licenses/settings and the licence fields of
PUT /orgs/{org}/package-policy. If you use them, the page shows the two
scopes as different again.