Blame python/sepolgen/HACKING

Packit Service 9fb14c
Code Overview
Packit Service 9fb14c
=============
Packit Service 9fb14c
Packit Service 9fb14c
The source for Sepolgen is divided into the python library (sepolgen)
Packit Service 9fb14c
and tools (e.g., audit2allow).
Packit Service 9fb14c
Packit Service 9fb14c
The library is structured to give flexibility to the application using
Packit Service 9fb14c
it - it avoids assumptions and close coupling of components where
Packit Service 9fb14c
possible. The audit2allow application demonstrates how to hook the
Packit Service 9fb14c
components together.
Packit Service 9fb14c
Packit Service 9fb14c
There is a test suite in the test subdirectory. The run-tests.py
Packit Service 9fb14c
script will run all of the tests.
Packit Service 9fb14c
Packit Service 9fb14c
The library is is divided into several functional areas:
Packit Service 9fb14c
Packit Service 9fb14c
Reference Policy Representation (sepolgen.refpolicy)
Packit Service 9fb14c
-------------------------------------------------------------
Packit Service 9fb14c
Packit Service 9fb14c
Objects for representing policies and the reference policy
Packit Service 9fb14c
interfaces. Includes basic components (security contexts, allow rules,
Packit Service 9fb14c
etc.) and reference policy specific components (interfaces, modules,
Packit Service 9fb14c
etc.).
Packit Service 9fb14c
Packit Service 9fb14c
This representation can be used as output from the parser to represent
Packit Service 9fb14c
the reference policy interfaces. It can also be used to generate
Packit Service 9fb14c
policy by building up the relevent data structures and then outputting
Packit Service 9fb14c
them. See sepolgen.policygen and sepolgen.output for information on how
Packit Service 9fb14c
this can be done.
Packit Service 9fb14c
Packit Service 9fb14c
Access (sepolgen.access, sepolgen.interfaces, sepolgen.matching)
Packit Service 9fb14c
-------------------------------------------------------------
Packit Service 9fb14c
Packit Service 9fb14c
Objects and algorithms for representing access and sets of access in
Packit Service 9fb14c
an abstract way and searching that access. The basic concept is that
Packit Service 9fb14c
of an access vector (source type, target type, object class, and
Packit Service 9fb14c
permissions). These can be grouped into sets without overlapping
Packit Service 9fb14c
access. Access vectors and access vector sets can be matched against
Packit Service 9fb14c
other access vectors - this forms the backbone of how we turn audit
Packit Service 9fb14c
messages into interface calls.
Packit Service 9fb14c
Packit Service 9fb14c
The highest-level form of access represented in interfaces - which
Packit Service 9fb14c
includes algorithms to turn the raw output of the parser into access
Packit Service 9fb14c
vector sets representing the access allowed by each interface.
Packit Service 9fb14c
Packit Service 9fb14c
Parsing (sepolgen.refparser)
Packit Service 9fb14c
-------------------------------------------------------------
Packit Service 9fb14c
Packit Service 9fb14c
Parser for reference policy "headers" - i.e.,
Packit Service 9fb14c
/usr/share/selinux/devel/include. This uses the LGPL parsing library
Packit Service 9fb14c
[PLY](http://www.dabeaz.com/ply/) which is included in the source
Packit Service 9fb14c
distribution in the files lex.py and yacc.py. It may be necessary to
Packit Service 9fb14c
switch to a more powerful parsing library in the future, but for now
Packit Service 9fb14c
this is fast and easy.
Packit Service 9fb14c
Packit Service 9fb14c
Audit Messages (sepolgen.audit)
Packit Service 9fb14c
-------------------------------------------------------------
Packit Service 9fb14c
Packit Service 9fb14c
Infrastructure for parsing SELinux related messages as produced by the
Packit Service 9fb14c
audit system. This is not a general purpose audit parsing library - it
Packit Service 9fb14c
is only meant to capture SELinux messages - primarily access vector
Packit Service 9fb14c
cache (AVC) messages and policy load messages.
Packit Service 9fb14c
Packit Service 9fb14c
Policy Generation (sepolgen.policygen and sepolgen.output)
Packit Service 9fb14c
-------------------------------------------------------------
Packit Service 9fb14c
Packit Service 9fb14c
Infrastructure for generating policy based on required access. This
Packit Service 9fb14c
deliberately only loosely coupled to the audit parsing to allow
Packit Service 9fb14c
required accesses to be feed in from anywhere.
Packit Service 9fb14c
Packit Service 9fb14c
Object Model (sepolgen.objectmodel)
Packit Service 9fb14c
-------------------------------------------------------------
Packit Service 9fb14c
Packit Service 9fb14c
Information about the SELinux object classes. This is semantic
Packit Service 9fb14c
information about the object classes - including information flow. It
Packit Service 9fb14c
is separated to keep the core from being concerned about the details
Packit Service 9fb14c
of the object classes.
Packit Service 9fb14c
Packit Service 9fb14c
[selist]: http://www.nsa.gov/research/selinux/info/list.cfm