plainbox.impl.secure.qualifiers – Job Qualifiers

Qualifiers are callable objects that can be used to ‘match’ a job definition to some set of rules.

class plainbox.impl.secure.qualifiers.CompositeQualifier(qualifier_list)[source]

A JobQualifier that has qualifies jobs matching any inclusive qualifiers while not matching all of the exclusive qualifiers

designates(job)[source]
get_primitive_qualifiers()[source]
get_vote(job)[source]

Get one of the VOTE_IGNORE, VOTE_INCLUDE, VOTE_EXCLUDE votes that this qualifier associated with the specified job.

Parameters:job – A IJobDefinition instance that is to be visited
Returns:
  • VOTE_INCLUDE if the job matches at least one qualifier voted to select it and no qualifiers voted to deselect it.
  • VOTE_EXCLUDE if at least one qualifier voted to deselect it
  • VOTE_IGNORE otherwise or if the list of qualifiers is empty.
is_primitive[source]
class plainbox.impl.secure.qualifiers.FieldQualifier(field, matcher, inclusive=True)[source]

A SimpleQualifer that uses matchers to compare particular fields

get_simple_match(job)[source]

Check if the given job matches this qualifier.

This method should not be called directly, it is an implementation detail of SimpleQualifier class.

class plainbox.impl.secure.qualifiers.IMatcher[source]

Interface for objects that perform some kind of comparison on a value

match(value)[source]

Match (or not) specified value

Parameters:value – value to match
Returns:True if it matched, False otherwise
class plainbox.impl.secure.qualifiers.JobIdQualifier(id, inclusive=True)[source]

A JobQualifier that designates a single job with a particular id

get_simple_match(job)[source]

Check if the given job matches this qualifier.

This method should not be called directly, it is an implementation detail of SimpleQualifier class.

class plainbox.impl.secure.qualifiers.NonLocalJobQualifier(inclusive=True)[source]

A JobQualifier that designates only non local jobs

get_simple_match(job)[source]

Check if the given job matches this qualifier.

This method should not be called directly, it is an implementation detail of SimpleQualifier class.

class plainbox.impl.secure.qualifiers.OperatorMatcher(op, value)[source]

A matcher that applies a binary operator to the value

match(value)[source]
class plainbox.impl.secure.qualifiers.PatternMatcher(pattern)[source]

A matcher that compares values by regular expression pattern

match(value)[source]
class plainbox.impl.secure.qualifiers.RegExpJobQualifier(pattern, inclusive=True)[source]

A JobQualifier that designates jobs by matching their id to a regular expression

get_simple_match(job)[source]

Check if the given job matches this qualifier.

This method should not be called directly, it is an implementation detail of SimpleQualifier class.

pattern_text[source]

text of the regular expression embedded in this qualifier

class plainbox.impl.secure.qualifiers.SimpleQualifier(inclusive=True)[source]

Abstract base class that implements common features of simple (non composite) qualifiers. This allows two concrete subclasses below to have share some code.

designates(job)[source]
get_primitive_qualifiers()[source]

Return a list of primitives that constitute this qualifier.

Returns:A list of IJobQualifier objects that each is the smallest, indivisible entity. Here it just returns a list of one element, itself.
get_simple_match(job)[source]

Get a simple yes-or-no boolean answer if the given job matches the simple aspect of this qualifier. This method should be overridden by concrete subclasses.

get_vote(job)[source]

Get one of the VOTE_IGNORE, VOTE_INCLUDE, VOTE_EXCLUDE votes that this qualifier associated with the specified job.

Parameters:job – A IJobDefinition instance that is to be visited
Returns:
  • VOTE_INCLUDE if the job matches the simple qualifier concept embedded into this qualifier and this qualifier is inclusive.
  • VOTE_EXCLUDE if the job matches the simple qualifier concept embedded into this qualifier and this qualifier is not inclusive.
  • VOTE_IGNORE otherwise.
inclusive[source]
is_primitive[source]
class plainbox.impl.secure.qualifiers.WhiteList(pattern_list, name=None, origin=None, implicit_namespace=None)[source]

A qualifier that understands checkbox whitelist files.

A whitelist file is a plain text, line oriented file. Each line represents a regular expression pattern that can be matched against the id of a job.

The file can contain simple shell-style comments that begin with the pound or hash key (#). Those are ignored. Comments can span both a fraction of a line as well as the whole line.

For historical reasons each pattern has an implicit ‘^’ and ‘$’ prepended and appended (respectively) to the actual pattern specified in the file.

classmethod from_file(pathname, implicit_namespace=None)[source]

Load and initialize the WhiteList object from the specified file.

Parameters:
  • pathname – file to load
  • implicit_namespace – (optional) implicit namespace for jobs that are using partial identifiers (all jobs)
Returns:

a fresh WhiteList object

classmethod from_string(text, *, filename=None, name=None, origin=None, implicit_namespace=None)[source]

Load and initialize the WhiteList object from the specified string.

Parameters:
  • text – full text of the whitelist
  • filename – (optional, keyword-only) filename from which text was read from. This simulates a call to from_file() which properly computes the name and origin of the whitelist.
  • name – (optional) name of the whitelist, only used if filename is not specified.
  • origin – (optional) origin of the whitelist, only used if a filename is not specified. If omitted a default origin value will be constructed out of UnknownTextSource instance
  • implicit_namespace – (optional) implicit namespace for jobs that are using partial identifiers (all jobs)
Returns:

a fresh WhiteList object

The optional filename or a pair of name and origin arguments may be provided in order to have additional meta-data. This is typically needed when the from_file() method cannot be used as the caller already has the full text of the intended file available.

implicit_namespace[source]

namespace used to qualify patterns without explicit namespace

name[source]

name of this WhiteList (might be None)

classmethod name_from_filename(filename)[source]

Compute the name of a whitelist based on the name of the file it is stored in.

origin[source]

origin object associated with this WhiteList (might be None)

plainbox.impl.secure.qualifiers.get_flat_primitive_qualifier_list(qualifier_list)[source]
plainbox.impl.secure.qualifiers.select_jobs(job_list, qualifier_list)[source]

Select desired jobs.

Parameters:
  • job_list – A list of JobDefinition objects
  • qualifier_list – A list of IJobQualifier objects.
Returns:

A sub-list of JobDefinition objects, selected from job_list.

Previous topic

plainbox.impl.secure.providers.v1 – Implementation of V1 provider

Next topic

plainbox.impl.secure.rfc822 – RFC822 parser

This Page