testing/check_fc_files: allow @ character in file context patterns

Some systemd units use @ in their names.

Fixes: https://github.com/SELinuxProject/refpolicy/issues/131

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
Nicolas Iooss 2019-12-22 16:53:05 +01:00
parent 17f06cf1fe
commit 8e612038de
No known key found for this signature in database
GPG Key ID: C191415F340DAAA0
1 changed files with 2 additions and 2 deletions

View File

@ -152,7 +152,7 @@ def analyze_fc_file(fc_path):
reduced_path = reduced_path.replace("include`'(", 'include(')
# Check the character set of the path
invalid_characters = set(re.findall(r'[^-0-9A-Za-z_./()?+*%{}\[\]^|:~\\]', reduced_path))
invalid_characters = set(re.findall(r'[^-0-9A-Za-z_@./()?+*%{}\[\]^|:~\\]', reduced_path))
if invalid_characters:
print(f"{prefix}unexpected characters {' '.join(sorted(invalid_characters))} in {path}")
retval = False
@ -271,7 +271,7 @@ def analyze_fc_file(fc_path):
# Check the remaining symbols in the reduced path.
# Only show a warning if no other ones were reported, in order to reduce the probability of false-positive.
invalid_symbols = set(re.findall(r'[^-0-9A-Za-z_~:ᠰ/]', reduced_path))
invalid_symbols = set(re.findall(r'[^-0-9A-Za-z_@~:ᠰ/]', reduced_path))
if retval and invalid_symbols:
print(f"{prefix}unexpected symbols {' '.join(sorted(invalid_symbols))} in {path} after being reduced to {reduced_path}. This could be due to an error in the pattern or a missing reduction rule in the checker") # noqa
retval = False