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

Merge simplify mount_condition_pattern

The whole pattern already has `(...)*`, therefore there's no need to
make option_pattern optional.

Before this change, mount_condition_pattern could have matched
- on empty strings (it still can, thanks to the trailing `*` which can
  also mean "zero matches") or
- whitespace-only strings (which is covered by the two regexes using
  mount_condition_pattern - they both have `\s*` and/or `\s+` around it)

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1709
Approved-by: Georgia Garcia <georgia.garcia@canonical.com>
Merged-by: Christian Boltz <apparmor@cboltz.de>
This commit is contained in:
Christian Boltz 2025-06-04 19:35:58 +00:00
commit 9a9f290099

View File

@ -58,7 +58,7 @@ option_pattern = r'\s*(\boption(s?)\b\s*(?P<options_equals_or_in>=|in)\s*'\
# allow any order of fstype and options
# Note: also matches if multiple fstype= or options= are given to keep the regex simpler
mount_condition_pattern = rf'({fs_type_pattern}\s*|{option_pattern}?\s*)*'
mount_condition_pattern = rf'({fs_type_pattern}\s*|{option_pattern}\s*)*'
# Source can either be
# - A path : /foo