2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 10:07:12 +00:00

13 Commits

Author SHA1 Message Date
Maxime Bélair
380dbb84b8 utils: Fix priority checking for is_covered
MR !1735 mistakenly assumed that x.is_covered(y) means "x is covered by
y" when the opposite is true

Fix the logic of is_covered and associated tests.

Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2025-07-17 11:00:24 +02:00
Maxime Bélair
f78aa36547 Add tests for priority is_covered/is_equal fix
Signed-off-by: Maxime Bélair <maxime.belair@canonical.com>
2025-07-16 12:13:41 +00:00
Christian Boltz
a833528f36
Split test classes
Create separate classes for tests not fitting under *TestParseInvalid
2025-07-15 20:34:33 +02:00
Christian Boltz
66cb0af47c
*TestParseInvalid: move tests not matching regex into tests array 2025-06-29 18:26:10 +02:00
Christian Boltz
2a37040415
Introduce AATest.parseInvalidRule()
... and change all *TestParseInvalid classes to use it, instead of
having (nearly) the same function in every test-*.py.

While at it, enable the tests for abi and include rules.
2025-06-29 17:35:48 +02:00
Christian Boltz
a13d8cfffb
utils: move tests for invalid priority to test-*
... instead of having them in test-modifiers.py for all rule types

Also add a few additional tests while on it.
2025-06-24 18:11:14 +02:00
John Johansen
c0fcd1698b utils: add support for priority rule prefix
Add basic support for the priority rules prefix. This patch does not
allow the utils to set or suggest priorities. It allows parsing and
retaining of the priority prefix if it already exists on rules and
checking if it's in the supported range.

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2025-05-05 14:54:22 -03:00
Georgia Garcia
8c84b36b32 utils: fix unix qualifier clean rule generation
The wrong clean rule is generated when unix rules contain qualifiers,
with the order inverted with the rule name.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/511
Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2025-04-17 20:39:58 -03:00
Christian Boltz
1ff9306c93
UnixRule: allow comma as separator in peer=
... and add some tests for it
2025-03-13 17:22:24 +01:00
Christian Boltz
b53d15896e
Fix handling of quoted peers in UnixRule (and others)
In UnixRule (and probably also in other rules that use
print_dict_values()` and `initialize_cond_dict()`), the handling of
peers with a value that is quoted and/or needs to be quoted was broken
because

- quotes didn't get stripped in `initialize_cond_dict()`
- `print_dict_values()` didn't use `quote_if_needed()`

Note: print_dict_values also handles integers (like network ports).
Convert them to a string so that `if ' ' in data` in `quote_if_needed()`
doesn't explode.

Also enable the test that uncovered this bug.
2024-06-19 14:01:15 +02:00
Christian Boltz
d8360dc765
UnixRule: Fix handling of peers with a ?
`?` is a valid AARE char, add it to the regexes that match the AARE.

Also add some tests to ensure this is really fixed, and make the error
output of the tests more useful/verbose.

Note: One of the added tests (with a space in the peer name) uncovered a
bug in quote handling. This will be fixed in the next commit.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/404
2024-06-19 13:28:24 +02:00
Georgia Garcia
cec9ae6dff utils: fix coding style to match PEP8
Annotate exceptions with '  # noqa: ERROR'

Signed-off-by: Georgia Garcia <georgia.garcia@canonical.com>
2024-05-20 13:56:37 -03:00
Maxime Bélair
34821d16ce Adding userspace support for unix mediation 2024-03-29 13:09:06 +00:00