Zhang Huangbin avatar Zhang Huangbin committed 7273b0e

Fix bypassing whitelisted sender issue in plugin: block_amavisd_blacklisted_senders. Thanks HoHo for his report.

Comments (0)

Files changed (4)

+iRedAPD-1.3.2:
+    * Fix bypassing whitelisted sender issue in plugin:
+      block_amavisd_blacklisted_senders. Thanks HoHo for his report.
+
 iRedAPD-1.3.1:
     * Fix defective sender address list in plugin:
       block_amavisd_blacklisted_senders.

src/iredapd-rr.py

 import logging
 import daemon
 
-__version__ = "1.3.1"
+__version__ = "1.3.2"
 
 sys.path.append(os.path.abspath(os.path.dirname(__file__)) + '/plugins-rr')
 
 import logging
 import daemon
 
-__version__ = "1.3.1"
+__version__ = "1.3.2"
 
 sys.path.append(os.path.abspath(os.path.dirname(__file__)) + '/plugins')
 

src/plugins/block_amavisd_blacklisted_senders.py

         list_senders += ['@.' + '.'.join(splited_sender_domain)]
         splited_sender_domain.pop(0)
 
-    # Get value of amavisBlacklistedSender.
+    # Get list of amavisBlacklistedSender.
     blSenders = [v.lower() for v in ldapRecipientLdif.get('amavisBlacklistSender', [])]
 
+    # Get list of amavisWhitelistSender.
+    wlSenders = [v.lower() for v in ldapRecipientLdif.get('amavisWhitelistSender', [])]
+
+    #
+    # Process whitelisted senders first.
+    #
+
+    # Bypass whitelisted senders.
+    if len(set(list_senders) & set(wlSenders)) > 0:
+        return 'DUNNO'
+
+    # Reject blacklisted senders.
     if len(set(list_senders) & set(blSenders)) > 0:
-        # Reject blacklisted senders.
         return 'REJECT Not Authorized'
-    else:
-        return 'DUNNO'
+
+    # Neither blacklisted nor whitelisted.
+    return 'DUNNO'
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.