Commit graph

4978 commits

Author SHA1 Message Date
Launchpad Translations on behalf of apparmor-dev
41b5fecbcf
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:29:59 -07:00
Launchpad Translations on behalf of apparmor-dev
dc98e8ff55
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:29:09 -07:00
Launchpad Translations on behalf of apparmor-dev
ba3dc9fc85
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:28:53 -07:00
Launchpad Translations on behalf of apparmor-dev
42b43d58d0
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:28:40 -07:00
Launchpad Translations on behalf of apparmor-dev
301857ef5d
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:28:10 -07:00
Launchpad Translations on behalf of apparmor-dev
303deea3a8
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:27:22 -07:00
Launchpad Translations on behalf of apparmor-dev
894c6cd6d2
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:26:56 -07:00
Launchpad Translations on behalf of apparmor-dev
eb38db5953
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:26:30 -07:00
Launchpad Translations on behalf of apparmor-dev
5cc8718965
Launchpad automatic translations update.
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2019-06-13 14:26:01 -07:00
Jamie Strandboge
1f9cc702ed Merge branch 'cache-fix' into 'master'
parser: Don't skip cache just because optimizations are specified

See merge request apparmor/apparmor!385
2019-06-06 21:54:06 +00:00
John Johansen
f6cd5c01c1 parser: Don't skip cache just because optimizations are specified
The parser currently skips the cache if optimizations are specified
because it can not determine if the cached policy was compiled
with the specified optimization. However this causes cache misses
even if policy is cached with those options, and distros are setting
some optimizations by default.

Instead of skipping reading the cache if optimizations are set, users
can force overwriting the cache if needed, until the parser can
store aditional meta info in the cache.

BugLink: http://bugs.launchpad.net/bugs/1820068
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-06-05 02:18:46 -07:00
John Johansen
a6ac6f4cfc libapparmor python: Fix 'aa_log_record' object has no attribute '__getattr__'
When building with swig 4 we are seeing the error

AttributeError: 'aa_log_record' object has no attribute '__getattr__'

Which forces swig to use modern classes which do not generate __getattr__
methods.

issue: https://gitlab.com/apparmor/apparmor/issues/33
Acked-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-06-04 21:43:48 -07:00
Christian Boltz
60d3be22cf Merge branch 'cboltz-finishing' into 'master'
drop unused 'finishing' in do_logprof_pass()

See merge request apparmor/apparmor!383

Acked-by: Eric Chiang <ericchiang@google.com>
2019-05-20 15:30:19 +00:00
Christian Boltz
5abfb08a3e
drop unused 'finishing' in do_logprof_pass()
finishing was always false, resulting in always returning 'NORMAL'.

Remove the variable, remove the unused condition - and change the only
place (aa-genprof) that expected a return value from do_logprof_pass()
to not expect it anymore.

found by Coverity, CID 198637
2019-05-17 22:27:57 +02:00
Christian Boltz
758a6b214f Merge branch 'cboltz-rewrite-logparser' into 'master'
Rewrite log handling

logparser.py puts each log event on a big "stack" in self.pid. Later,
handle_children() in aa.py then converts that (named 'log' in aa.py) to
the prelog hasher.

This commit changes logparser.py to create a prelog-like structure itsself
(named hashlog), which
- removes one level of indirection
- probably saves some memory because the hashlog automatically
  de-duplicates events

In aa.py, collapse_log() gets updated to work with hashlog. (There's
also a handle_hashlog() function in this patch series, but it didn't 
survive the final patches ;-)

OTOH, the now superfluous code handling capability, network etc.
events gets removed from handle_children(). The remaining parts of
this function get split into ask_exec() and ask_addhat().

logparser.py gets a new function init_hashlog() to initialize hashlog
for each profile. It also gets changed to store capability, network etc.
events into hashlog instead of storing them in self.pid.

hashlog uses the full profile name as key, which is the first baby step
to support nested child profiles. (for now, collapse_log() still
splits the profile name into profile and hat.)

There are many more details, see the individual commits ;-)

See merge request apparmor/apparmor!377

Acked-by: Seth Arnold <seth.arnold@canonical.com>
2019-05-12 10:56:14 +00:00
John Johansen
ab0f2af1da tests/regression: fix mount test to use next available loop device
looping through the first 16 loop devices to find a free device will
fail if those mount devices are taken, and unfortunately there are
now services that use an excessive amount of loop devices causing
the regression test to fail.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2019-05-10 18:06:55 -07:00
John Johansen
30348ebe9d README make the subsections of Regression Tests more obvious
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-05-09 23:01:31 -07:00
John Johansen
c50eb09ebc Update README build instructions to have cross links
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-05-09 22:58:50 -07:00
John Johansen
74ade80cf1 Update README with instructions on USE_SYSTEM=1 for the regression tests
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-05-09 22:54:19 -07:00
Christian Boltz
205ae4a256
collapse_log(): don't overwrite existing ProfileStorage
When a user chooses the ix exec mode, don't overwrite the existing
ProfileStoragge to avoid loosing the already collected events.
2019-05-09 18:22:07 +02:00
Christian Boltz
836caca462
collapse_log: ignore events from null-* profiles
If final_name still includes null-*, that's most likely caused by nested
execs which aren't supported by the tools yet. Ignoring them is better
than creating a useless null-* hat.

Note: The tools always had this restriction, so this is not a regression ;-)

Also note that test-libapparmor-test_multi expects that null-* hats get
created (which makes sense because the one-line log sniplets don't have
any exec indication), therefore add an optional parameter to keep this
behaviour for the tests.
2019-05-09 18:14:18 +02:00
Christian Boltz
387d1646c8
Merge handle_hashlog() into collapse_log()
Now that all log events arrive in hashlog, having a separate 'prelog' no
longer makes sense. Changing collapse_log() to accept 'hashlog' directly
removes that level of indirection.
2019-05-09 17:29:26 +02:00
Christian Boltz
c5f0097f65
make 'prelog' non-global
It's only used by two functions:
- handle_hashlog() - writes to prelog, and now returns it
- collapse_log() - reads prelog, and now gets it as parameter
2019-05-09 17:29:26 +02:00
Christian Boltz
c77426ed62
Introduce 'final_name' to hashlog and handle exec choices
'final_name' by default is the profile name, but ask_exec() will change
it for the target profile (which is a null-* profile at this stage)
based on exec mode choice. ask_addhat() will also change it based on the
chosen hat.

Choosing "deny" or "unconfined" will result in an empty final_name and
ignoring these log events.

All other choices set final_name to the full profile name ("foo" for Px,
"foo//bar" for Cx, current profile for ix).

Also fix the order of handling log events - since ask_exec() changes the
hashlog final_name, it has to run first so that ask_addhat() (which
"only" adjusts the hat name in final_name) and handle_hashlog() can work
with the updated profile name.

Finally, update test-libapparmor-test_multi.py to ignore final_name when
checking if hashlog is empty, and fix the call order of ask_exec() etc.
2019-05-09 17:29:26 +02:00
Christian Boltz
d1b8772a1d
ask_exec(): simplify to_name logic
At this stage of ask_exec(), to_name is always empty, therefore drop an
if condition that checks it (and the code inside that branch).
2019-05-09 17:15:35 +02:00
Christian Boltz
5953ac3dda
ask_exec(): drop useless setting of profile and hat
profile and hat don't get used in the following lines, and later get
overwritten in the next round of the for loop.

The deleted code was last useful for setting the (dropped)
profile_changes array.
2019-05-09 17:15:35 +02:00
Christian Boltz
3ec4869adf
ask_exec(): Get rid of unused context_new variable 2019-05-09 17:15:35 +02:00
Christian Boltz
48cc1b2837
add a split_name() function to split a profile name
... into profile and hat.

Also change several places to use split_name().
2019-05-09 17:15:35 +02:00
Christian Boltz
305b378bfd
Delete apparmor/aamode.py and its testsuite
After the logparser cleanup, aamode.py and its overly complicated
permission handling is no longer needed.
2019-05-09 17:15:35 +02:00
Christian Boltz
45a3d8920a
Drop unused 'pid' parameter from ReadLog.__init__()
... and self.pid which is also unused.

This simple change also means to adjust all the code that uses ReadLog.
We get rid of log_pid in aa.py, and have to change lots of test-*
2019-05-09 17:15:35 +02:00
Christian Boltz
9a92909a89
Change read_log to return only hashlog
self.log is unused, drop it.

Also change all places that call read_log() to match the simplified
return value.
2019-05-09 17:15:35 +02:00
Christian Boltz
d4512aa5d7
Drop add_to_tree and some superfluous code
After all the changes in this branch, parse_event_for_tree always
returns None, which makes the "if event is not None" branch dead code.

This branch was the only place where add_to_tree() was called, therefore
remove this function.

This also makes self.pid and self.log unused. They'll be removed with
separate commits.
2019-05-09 17:15:35 +02:00
Christian Boltz
3b77d63556
ask_exec(): don't overwrite 'hat' in cx handling
Otherwise we'd have to reset 'hat' in the next round of the for loop.

Using 'exec_target' instead of 'hat' in the cx code is much easier.
2019-05-09 17:15:35 +02:00
Christian Boltz
d2663b148a
Transform handle_children() to ask_exec()
The only remaining job of handle_children() was to handle exec events.
(And recursively calling itsself if it hits nested log events, but
logparser.py never created such a log structure.)

Therefore:
- drop the dead code handling nested log (type != str)
- rename the remaining function to ask_exec()
- drop checks for typ = 'exec' (now done as part of the for loop
- drop the "else" branch for unknown event types
- change 'return' to 'continue' because ask_exec handles all exec events
  in a loop instead of being called multiple times
- oh, and of course switch over to using hashlog

Finally, change do_logprof_pass() and the tests to call ask_exec()
instead of handle_children().

While on it, update a comment in test-translations.py which held the
last reference to handle_children().
2019-05-09 17:15:35 +02:00
Christian Boltz
7297e2f6a8
parse_event_for_tree(): Move exec events to loghash
The 'hat' and 'prog' variables are no longer needed, drop them.

Also no longer include denied_mask in the event - operation='exec' means
an exec event, no need to additionally hand over 'x' permissions.

Note: This commit introduces a "brain split", which means exec handling
is temporarily broken. Later commits will fix this.
2019-05-03 23:25:55 +02:00
Christian Boltz
62adc8547c
handle_children(): drop using 'prog' and checking for non-empty to_name
parse_event_for_tree() always sets prog = 'HINT' and to_name = '' for
exec events.

The only exception is in the 'mandatory profile missing' case where
prog = aamode and to_name = target_profile, but I've never seen that in
practise.

This means the prog != 'HINT' branch in exec handling never gets used
and can be dropped.

Erroring out "if to_name:" also never gets used (to_name is always ''),
therefore drop it as well.
2019-05-03 23:01:21 +02:00
Christian Boltz
460d1fda93
handle_children(): get rid of 'domainchange'
"if domainchange == 'change':" is always true, therefore get rid of this
check and the domainchange variable.
2019-05-03 22:54:46 +02:00
Christian Boltz
13f67d45d0
ask_addhat: print warning only if we have change_hat events
Printing the warning whenever a child profile exists is pointless. It
only makes sense if there are change_hat events inside the child profile.
2019-05-03 22:54:46 +02:00
Christian Boltz
f0db04d2b7 Merge branch 'feature/aa-notify-new-features' into 'master'
Minor improvements to aa-notify

See merge request apparmor/apparmor!372

Acked-by: Christian Boltz <apparmor@cboltz.de>
2019-05-03 18:15:02 +00:00
Otto Kekäläinen
81d514d89a aa-notify: Always use aa.CONFDIR, don't assume "/etc/apparmor"
Also fix cosmetic comment.
2019-05-03 17:53:24 +03:00
Christian Boltz
1b7cdec70d
Fix and simplify ask_addhat()
- replace/merge 'uhat' with 'hat'
- adjust ProfileStorage comment to the new function name
- initialize default hat if it gets chosen and doesn't exist yet
- don't exit the function if "Deny" gets chosen. Instead, continue with
  the next hat to (possibly) add
2019-05-03 00:12:46 +02:00
Christian Boltz
560fb6fabe
Use hashlog for change_hat log events
Adjust logparser.py to store change_hat events in hashlog.

In aa.py,
- split off ask_addhat() from handle_children()
- change ask_addhat() to use hashlog
- call ask_addhat() from do_logprof_pass()

Also call ask_addhat() in test-libapparmor-test_multi.py to keep it in
sync with do_logprof_pass().
2019-05-03 00:12:46 +02:00
Christian Boltz
eeb70c4695
drop restriction on complain mode in change_hat handling
Also move/merge the remaining change_hat checks into the section
handling change_hat events.
2019-05-02 23:10:08 +02:00
Christian Boltz
49b8ca1e73
handle_children: don't initialize variables that get always set
All the variables initialized at the start of the function always get
overwritten in the loop, therefore it's superfluous to initialize them.

Also inline 'entries' to the only place that uses it.
2019-05-02 23:10:08 +02:00
Christian Boltz
a2870a71cb
Drop handling of operation="clone"
According to John, this isn't supported since 10 years.

In case you wonder why this commit removes the "fork" handling in
handle_children() - logparser.py names clone events "fork" on the event
stack.
2019-05-02 23:10:03 +02:00
Christian Boltz
d11ed33d16
Stop ignoring profile_set events
According to John, this is no longer needed.
2019-05-02 20:24:15 +02:00
Christian Boltz
8b1b10babd
Add tests for parse_event_for_tree() with invalid log lines
Also convert test-logparser.py to AATest.
2019-05-02 01:10:18 +02:00
Christian Boltz
a43c1da287
Remove superfluous code and checks in path log handling
In logparser parse_event_for_tree() path event handling, drop mapping
permissions for request_mask because request_mask never gets used.
Also drop the validate_log_mode() call because the function has its own,
more strict check since the last commit.

In aamode.py, drop the now unused validate_log_mode() and
hide_log_mode() functions and the LOG_MODE_RE regex.

Finally, drop the validate_log_mode() tests from test-aamode.py
2019-05-02 01:10:18 +02:00
Christian Boltz
3d3667f38b
move path log event handling to hashlog
In logparser.py parse_event_for_tree, convert path handling to hashlog.
While on it, include 'owner' as part of hashlog so that aa.py doesn't
need to guess.

Also switch to a simple for loop instead of using log_str_to_mode() from
aamode.py to convert denied_mask to hasher keys (which would have been
needed to allow merging of several log events for the same path anyway).
Note that the check for 'mrawlk' (intentionally without 'x') is more
strict than the validate_log_mode(), but it should still cover all file
permissions. (validate_log_mode() also allows things like 'Px', which
we'll never hit in a logfile.)

In aa.py collapse_log() update the handling of path events to match the
additional [owner] key in hashlog/prelog. This makes the owner detection
in collapse_log() superfluous.

In aa.py handle_children(), remove 'path' handling from the 'path' or
'exec' section, and add an 'if True:' to avoid lots of whitespace
changes.

In aamode.py, drop the now unused split_mode() function, and
AA_OTHER_REMOVE() that was only used by split_mode().

Finally, remove sample log events with null-* hats from the list of
known failures in test-libapparmor-test_multi.py (we no longer filter
out null-* hats), and fix whitespace in two expected profiles.
2019-05-02 01:10:18 +02:00
Christian Boltz
1a46de1892
drop check if 'inode_permission' event means exec
According to John, 'inode_permission' wasn't used for 10 years.

This little change also means that we now have a clear separation
between "exec" and "normal" (mrwlk) file events.

Also drop the now superfluous makes peek_at_next_log_entry() and
throw_away_next_log_entry() functions.
2019-05-02 01:10:13 +02:00