Koji/Policies

From FedoraProject

Jump to: navigation, search

Defining a policy on the hub allows you fine control over certain activities in the system. At present, policy allows you to control:

In the future, we expect to add more policy hooks for controlling more aspects of the system.

Policy configuration is optional. If you don't define one, then by default:

Contents

Configuration

The hub policy is configured in the hub.conf file, which is an ini-style configuration file. Policies are defined in the section named [policy]. Each name = value pair defines the policy of that name. With multiple line policies, successive lines should be indented so that the parser treats them as part of the whole.

Consider the following simple (and strict) example:

[policy]
tag =
    has_perm admin :: allow
    tag *-candidate :: allow
    all :: deny

This policy section defines a single policy (named 'tag'). The policy is a series of rules, one per line. The rule lines must be indented. Each rule is a test and an action, separated by a double colon. The valid actions for current policies are 'allow' and 'deny'. There are many tests available, though not all of them are applicable for all policies. Each test is specified by giving the name of the test followed by any arguments the test accepts.

Each rule in the policy is checked until a match is found. Upon finding a match, the action is applied. Our example above limits non-admins to tags ending in -candidate.

Getting a bit more complicated The example above is very simple. The policy syntax also supports compound tests, negated tests, and nested tests. Consider the following example:

[policy]
tag =
    buildtag *epel* :: {
        tag *epel* !! deny
    }
    tag *-updates :: {
        operation move :: {
            fromtag *-updates-candidate :: allow
            fromtag *-updates-testing :: allow
            all :: deny
        }
        operation tag && hastag *-updates-candidate *-updates-testing :: deny
    }
    all :: allow

This policy sets up some rules concerning tags ending in -updates and tags containing epel, but is otherwise permissive.

The first nested rule limits builds built from a tag matching *epel* to only such tags. Note the use of !! instead of :: negates the test.

For tags matching *-updates, a particular work-flow is enforced. Moving is only allowed if the move is coming from a tag matching *-updates-candidate or *-updates-testing. Conversely, a basic tag operation (not a move) is denied if the build also has such a tag (the policy requires a move instead).

General format

The general form of a basic policy line is one of the following

    test [params] [&& test [params] ...] :: action-if-true
    test [params] [&& test [params] ...] !! action-if-false

And for nested rules:

    test [params] [&& ...] [::|!!] {
        test [params] [&& ...] [::|!!] action
        test [params] [&& ...] [::|!!] {
            ...
            }
    }

Note that each closing brace must be on a line by itself. Using !! instead of :: negates the entire test. Tests can only be joined with &&, the syntax does not support ||.

Available policies

The system currently looks for the following policies

These policies are set by assigning a rule set to the given name in the policy section.

Note that the use of tag policies does not bypass tag locks or permissions

Note that an admin can bypass the tag policy by using --force.

Actions

Most of the policies are simply allow/deny policies. They have two possible actions: allow or deny.

The channel policy is used to determine the channel for a task. It supports the following actions:

Available tests

true

all

false

none

operation

package

tag

fromtag

hastag

buildtag

skip_tag

imported

is_build_owner

user_in_group

has_perm

source

policy

is_new_package

is_child_task

method

user