Commit Graph

1056 Commits

Author SHA1 Message Date
Vit Mojzis
52838ce632 Support old boolean names in policy queries
Translate old boolean names based on /etc/selinux/*/booleans.subs_dist
file. The translation is only attempted when "policy" was not specified
to avoid influencing queries of policies from other systems.

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
2020-06-29 19:45:22 +02:00
Chris PeBenito
d93da398eb
Merge pull request #47 from pebenito/sechecker
Add sechecker
2020-06-15 08:23:47 -04:00
Chris PeBenito
d9e9a4d902 sediff: Fix new issues from newer pylint.
Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
2020-06-10 11:09:37 -04:00
Chris PeBenito
b58fdc00cd sechecker: Implement sechecker.
This is a command line tool for the configuration file-driven automated
policy analysis.

Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
2020-06-10 11:09:37 -04:00
Chris PeBenito
bf03b6749c PolicyChecker: Implement config file-driven automated analysis checker.
This is a .ini config file-driven analysis check.

Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
2020-06-10 11:09:17 -04:00
Chris PeBenito
9ca7e648e3 ReadOnlyExecutables: Implement read-only executables assertion check.
This determines all file types that are executable and checks if they are
also read-only.

Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
2020-06-10 11:09:06 -04:00
Chris PeBenito
e8c172c720 AssertTE: Implement type enforcement allow rule assertion check.
This checks for the nonexistance of allow rules that match the criteria
set in the check's options.

Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
2020-06-10 11:09:06 -04:00
Chris PeBenito
bb698389af EmptyTypeAttr: Implement empty type attribute assertion check.
This asserts that an attribute is empty.

Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
2020-06-10 11:09:06 -04:00
Chris PeBenito
a0c70bda73 CheckerModule: Implement abstract base class for policy checker modules.
Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
2020-06-10 11:09:06 -04:00
Chris PeBenito
210665f575 Implement utility functions for parsing configuration strings.
These are various functions such as parsing comma separated strings,
looking up objects in the policy, and expanding attributes.

Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
2020-06-10 11:09:06 -04:00
Chris PeBenito
d7ca8d7dee
Merge pull request #45 from pebenito/master
Fix CI errors.
2020-05-07 16:18:56 -04:00
Chris PeBenito
f28fa429c7 DomainTransitionAnalysis/InfoFlowAnalysis: Fix lint errors.
Pylint seems to be buggy in analyzing this statement.  Splitting it into
two statements didn't help.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-05-07 16:02:25 -04:00
Chris PeBenito
74f3efc59e Update libsepol dependency to 3.0 for glblub.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-05-07 15:01:47 -04:00
Chris PeBenito
d3a9fcb1d6 Default: Add support for default_range glblub.
Closes #44

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-05-07 11:16:37 -04:00
Chris PeBenito
46334ed7d4 Default: Add better messages for unsupported default values.
For #44

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-05-07 11:12:38 -04:00
Chris PeBenito
ae9b784e6a Update setup.py for 4.4 dev.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-04-01 10:59:45 -04:00
Chris PeBenito
f708056f6d Update README and Changelog for release.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-04-01 10:54:59 -04:00
Chris PeBenito
bd1db8ffc6 Genfscon: Add object class attribute.
Since this is used to determine the file type, keep the reference.  If
a genfscon does not have a filetype, this attribute will be None.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-04-01 09:41:03 -04:00
Chris PeBenito
507775236c .coveragerc: Reenable Cython coverage plugin.
Cython coverage is only a problem when run through tox.  Disable the coverage
target in Travis Ci until this can be addressed.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-03-16 12:58:39 -04:00
Chris PeBenito
b54c18b667 .travis.yml: Update to bionic distro.
Update supported Python versions accordingly.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-03-12 11:32:52 -04:00
Chris PeBenito
dbf2c197c7 Genfscon: Look up object class references since object class values are not static.
The object class values have not been static for many years.  This has only
worked because libsepol was similarly setting static class values.  This
will soon be removed, see SELinuxProject/selinux#200.

Add file object classes to the unit tests where genfscons are used.  The
classes are added in the same alignment as the static values since old
policies will have these class values.

Remove static class values from sepol.pxd.

Closes #39

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-03-10 15:55:24 -04:00
Chris PeBenito
093e4834e0 AVRule: Drop permissions check in derive_expanded().
This is an invalid check as the permission sets can be disjoint when
redundant permissions are removed.

Identified by Jim Carter.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-01-11 10:07:30 -05:00
Chris PeBenito
156c7d9931 AVRule: Fix derive_expanded() permission set exception message.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-12-27 11:55:49 -05:00
Chris PeBenito
1a20e985c0 AVRule: Change derive_expanded() permission set check to disjoint check.
Jim Carter first figured out this bug in PR #33

In class AVRUle, when deriving an expanded rule remove the check for
permissions beings a subset of the original rule.

This is not a condition that holds when attributes are expanded.

Ex/
attribute a1;
attribute a2;
type t1;
typeatrribute t1 a1, a2;
allow a1 self: c1 p1;
allow a2 self: c1 p2;

In this case the expanded rule "allow t1 t1: c1 {p1 p2};" has permissions
that are not a subset of either the allow rule with a1 or the one with a2.

Change the check to a set-disjoint check to make sure there is some
intersection between the original rule permission set and the derived
permission set.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-12-27 11:35:52 -05:00
Chris PeBenito
8b42918f6a
Merge pull request #32 from BigBadWolfSecurity/master
Correct permmap stating that sendto is a read.
2019-11-27 09:07:36 -05:00
Karl MacMillan
beb8979072 Commit permmap stating that sendto is a read.
sendto on some object classes was marked as a read when it should be
a write.
2019-11-26 21:24:11 -05:00
Chris PeBenito
73e8c28845 ApolMainWindow: PEP8 style fix.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-11-26 13:33:15 -05:00
Chris PeBenito
e80c3a1280 ApolConfig: Move apol configuration file management to a new class.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-11-26 13:32:59 -05:00
Chris PeBenito
e42ec3fb67 ApolMainWindow: Try to find Qt assistant if help fails to start.
First search for it and if that fails, ask the user to select it.

Closes #28

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-11-24 22:48:22 -05:00
Chris PeBenito
459eb474ff ApolMainWindow: Add an apol config file.
First setting is location of qt assisstant.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-11-24 22:48:22 -05:00
Chris PeBenito
5c68b61f3c
Merge pull request #27 from jwcart2/improve_sediff_03
Change how differences in AV rules are generated in sediff
2019-10-24 22:16:27 -04:00
James Carter
89cad5e1b7 Change how differences in AV rules are generated in sediff
The primary motivation for the change is to correctly handle redundant
rules. Recent changes in the SELinux toolchain added support for an
optimization that removes redundant rules from a policy. These are
conditional rules that are either already specified in unconditional
policy or rules using types that are also specified more generally
through an attribute. Since attributes are always expanded in sediff,
the second type of redundant rules are already effectively removed. But
redundant conditional rules show up as differences when a binary version
of a policy that has been optimized is compared to one that has not been.

A secondary motivation for the change is to reduce memory usage and diff
times. A modern Fedora policy cannot be diffed with a system with less than
32Gb of memory and it takes over four hours to complete.

With this change AV rules are processed by creating a data structure which
consists of nested dictionaries that store BOTH the left and the right
policies. All of the keys are interned strings to save space.

The basic structure is
  rule_db[cond_exp][block_bool][src][tgt][tclass]=sides
where:
  cond_exp is a boolean expression
  block_bool is either true or false
  src is the source type
  tgt is the target type
  tclass is the target class
  sides is a namedtuple with "left" and "right" attributes
    Each side is either None or another namedtuple with "perms" and
    "orig_rule" attributes
      perms is the set of permissions for this rule
      orig_rule is the original unexpanded rule

These changes improve diff times and memory usage.
Without the change
                         Time        Memory Usage
Older Fedora Policy    3 min 17 sec      4.5Gb
Recent Refpolicy       4 min 19 sec      6.0Gb
Recent Fedora Policy   4 hrs  9 min     31.9Gb

With the change
                         Time        Memory Usage
Older Fedora Policy          28 sec      1.7Gb
Recent Refpolicy             34 sec      1.9Gb
Recent Fedora Policy   4 min 45 sec      7.7Gb

Also added a unit test to check that redundant rules are removed.

Signed-off-by: James Carter <jwcart2@tycho.nsa.gov>
2019-10-24 09:00:19 -04:00
Chris PeBenito
87674b2e17 ApolMainWindow: Fix question when closing the policy.
Closes #29.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-10-23 18:49:42 -04:00
Chris PeBenito
474c4e0566 Various apol tabs: Fix typo in result message.
Closes #30

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-10-23 18:47:09 -04:00
Chris PeBenito
2fd3739fd0 TypeAttribute: Add methods to make it a proper Python Collection.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-10-19 11:49:02 -04:00
Chris PeBenito
2557369f00 ibendportconquery.ui: Fix title. 2019-08-14 20:59:24 -04:00
Chris PeBenito
3df2bf11c6
Merge pull request #23 from fishilico/fix-lgtm-errors
Fix errors reported by lgtm.com
2019-08-13 17:28:10 -04:00
Nicolas Iooss
faf3d1b204
diff: compare with other instead of self
This issue has been found using lgtm.com.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-08-13 21:52:28 +02:00
Nicolas Iooss
186b77bc2d
diff: return a hash instead of raising it
Method __hash__ should return an integer.

This issue has been found using lgtm.com.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-08-13 21:49:09 +02:00
Chris PeBenito
9d319a3b96 netifconquery.ui: Fix tooltip for the device name regex checkbox.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-07-19 23:05:27 -04:00
Chris PeBenito
d251e344b0 apol: Add nicer titles for network context tabs.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-07-19 23:05:27 -04:00
Chris PeBenito
5eab4ac7a4 apol: Add ibendportcon analysis tab.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-07-19 23:05:16 -04:00
Chris PeBenito
f12640cd6b IbendportconQuery: Add setter for port.
Ensure it is an integer in the correct range.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-07-17 21:27:34 -04:00
Chris PeBenito
6333cfaff3 apol: Add ipbkeycon query tab.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-07-17 21:17:49 -04:00
Chris PeBenito
022adcb715 TERulesDifference: Add additional debugging statements.
Record the rule list and expanded rule statistics for determining if
memory size issues are due to rule size vs. something else.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-07-13 20:23:54 -04:00
Chris PeBenito
cf1342f4c8 sediff: Fix issue with policy properties heading with 0 changes.
The policy properties header would always be displayed if no specific
difference was chosen.
2019-07-08 20:22:32 -04:00
Chris PeBenito
f0bbab9547 Release 4.2.2.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-06-15 15:52:10 -04:00
Chris PeBenito
ba305bfd74 Remove source policy references from man pages.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-05-18 08:33:36 -04:00
Chris PeBenito
58bd5c871e SELinuxPolicy: Create a map of aliases on policy load.
Addresses a performance regression after the alias fixes in #17.

Closes #20
2019-04-29 07:57:16 -04:00
Chris PeBenito
324a24ea1a Update .gitignore. 2019-02-23 23:46:52 -08:00