Introduced a whitelist (as python list).
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 29 May 2012 21:09:39 +0000 (23:09 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Tue, 29 May 2012 21:09:39 +0000 (23:09 +0200)
findwwwritable.py

index 4ecc4b77072f1b707383d0ea2da278efd718ef72..b525c3c00d032fd247f01ae351d040df7940edcd 100755 (executable)
@@ -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: