From: Philipp Spitzer Date: Tue, 29 May 2012 21:09:39 +0000 (+0200) Subject: Introduced a whitelist (as python list). X-Git-Url: https://git.toastfreeware.priv.at/toast/findwwwritable.git/commitdiff_plain/657132d1a6639d8e1bc7816416fdc3add2271b9c?hp=8f792630977e480145ec7201d28502544810619b;ds=inline Introduced a whitelist (as python list). --- diff --git a/findwwwritable.py b/findwwwritable.py index 4ecc4b7..b525c3c 100755 --- a/findwwwritable.py +++ b/findwwwritable.py @@ -56,6 +56,16 @@ def summarize_dirs(writable_dirs): return writable_dirs +def apply_whitelist(writable_dirs, whitelist): + """Removes all directories that are contained in the list whitelist from the list writable_dirs. + It returns the modified writable_dirs. + + :param writable_dirs: List of directories + :param whitelist: List of directories that should be removed from writable_dirs. + :return: list of writable directories.""" + return sorted(list(set(writable_dirs).difference(whitelist))) + + if __name__ == '__main__': @@ -63,10 +73,12 @@ if __name__ == '__main__': uids = [33] # user ids of the user whos write permissions should be found gids = [33, 42, 121, 127] # group ids of the user whos write permissions should be found rootdir = '/home' # directory where the seach is started + whitelist = [] # list of directories that are known to be writable and that should not be reported. # collect and summarize writable directories writable_dirs = collect_writable_dirs(rootdir, uids, gids) writable_dirs = summarize_dirs(writable_dirs) + writable_dirs = apply_whitelist(writable_dirs, whitelist) # print writable directories for d in writable_dirs: