From ccf74a7d0c9f7061473480644ed8a5b9dfdbe1f8 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Sun, 15 Jun 2025 23:23:03 +0200 Subject: [PATCH] Unify get_directory_contents(), and delete unused copy Copy the optimized version from common.py to easyprof.py (shouldn't change the behaviour). Since get_directory_contents() is only used in easyprof.py, delete the unused copy from common.py. --- utils/apparmor/common.py | 9 --------- utils/apparmor/easyprof.py | 7 +------ 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/utils/apparmor/common.py b/utils/apparmor/common.py index 3152a986e..73d1c6fe3 100644 --- a/utils/apparmor/common.py +++ b/utils/apparmor/common.py @@ -10,7 +10,6 @@ # ------------------------------------------------------------------ import collections -import glob import logging import os import re @@ -169,14 +168,6 @@ def valid_path(path): return True -def get_directory_contents(path): - """Find contents of the given directory""" - if not valid_path(path): - return None - - return sorted(glob.glob(path + "/*")) - - def is_skippable_file(path): """Returns True if filename matches something to be skipped (rpm or dpkg backup files, hidden files etc.) The list of skippable files needs to be synced with apparmor initscript and libapparmor _aa_is_blacklisted() diff --git a/utils/apparmor/easyprof.py b/utils/apparmor/easyprof.py index 1a4293085..18c056f45 100644 --- a/utils/apparmor/easyprof.py +++ b/utils/apparmor/easyprof.py @@ -200,12 +200,7 @@ def get_directory_contents(path): if not valid_path(path): return None - files = [] - for f in glob.glob(path + "/*"): - files.append(f) - - files.sort() - return files + return sorted(glob.glob(path + "/*")) def verify_policy(policy, exe, base=None, include=None):