XYZ File Manager
Current Path:
/opt/alt/python27/lib/python2.7/site-packages/postomaat/plugins
opt
/
alt
/
python27
/
lib
/
python2.7
/
site-packages
/
postomaat
/
plugins
/
📁
..
📄
__init__.py
(578 B)
📄
__init__.pyc
(162 B)
📄
blackwhitelist.py
(10.08 KB)
📄
blackwhitelist.pyc
(7.95 KB)
📄
call-ahead.py
(77.45 KB)
📄
call-ahead.pyc
(67.93 KB)
📄
complexrules.py
(14.59 KB)
📄
complexrules.pyc
(17.37 KB)
📄
dbwriter.py
(5.7 KB)
📄
dbwriter.pyc
(4.69 KB)
📄
ebl-lookup.py
(9.03 KB)
📄
ebl-lookup.pyc
(8.3 KB)
📄
enforcetls.py
(5.1 KB)
📄
enforcetls.pyc
(4.39 KB)
📄
fluentd_writer.py
(6.92 KB)
📄
fluentd_writer.pyc
(6.73 KB)
📄
geoip.py
(7.47 KB)
📄
geoip.pyc
(7.4 KB)
📄
helotld.py
(3.37 KB)
📄
helotld.pyc
(3.07 KB)
📄
killer.py
(1.15 KB)
📄
killer.pyc
(1.47 KB)
📄
messagesize.py
(3.86 KB)
📄
messagesize.pyc
(3.54 KB)
📄
originpolicy.py
(11.2 KB)
📄
originpolicy.pyc
(9.51 KB)
📁
ratelimit
📄
rdns.py
(4.42 KB)
📄
rdns.pyc
(4.82 KB)
📄
recipientrules.py
(11.64 KB)
📄
recipientrules.pyc
(10.1 KB)
📄
script.py
(5.55 KB)
📄
script.pyc
(6 KB)
📄
spfcheck.py
(15.57 KB)
📄
spfcheck.pyc
(11.36 KB)
📄
srs.py
(4.51 KB)
📄
srs.pyc
(3.85 KB)
📄
suspect_collect.py
(7.84 KB)
📄
suspect_collect.pyc
(8.42 KB)
Editing: enforcetls.py
# -*- coding: UTF-8 -*- # Copyright 2012-2018 Fumail Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # # from postomaat.shared import ScannerPlugin, DUNNO, strip_address, extract_domain, apply_template, FileList, \ string_to_actioncode, get_default_cache from postomaat.extensions.sql import SQL_EXTENSION_ENABLED, get_session, get_domain_setting import os class EnforceTLS(ScannerPlugin): def __init__(self,config,section=None): ScannerPlugin.__init__(self,config,section) self.logger=self._logger() self.selective_domain_loader = None self.requiredvars={ 'domainlist':{ 'default':'', 'description':""" if this is empty, all recipient domains will be forced to use TLS txt:<filename> - get from simple textfile which lists one domain per line sql:<statement> - get from sql database :domain will be replaced with the actual domain name. must return field enforce_inbound_tls """, }, 'dbconnection':{ 'default':"mysql://root@localhost/enforcetls?charset=utf8", 'description':'SQLAlchemy Connection string', }, 'action':{ 'default':'DEFER', 'description':'Action if connection is not TLS encrypted. set to DUNNO, DEFER, REJECT', }, 'messagetemplate':{ 'default':'Unencrypted connection. This recipient requires TLS' } } def enforce_domain(self, to_domain): dbconnection = self.config.get(self.section,'dbconnection').strip() domainlist = self.config.get(self.section,'domainlist') enforce = False if domainlist.strip() == '': enforce = True elif domainlist.startswith('txt:'): domainfile = domainlist[4:] if self.selective_domain_loader is None: self.selective_domain_loader=FileList(domainfile,lowercase=True) if to_domain in self.selective_domain_loader.get_list(): enforce = True elif domainlist.startswith('sql:') and dbconnection != '': cache = get_default_cache() sqlquery = domainlist[4:] enforce = get_domain_setting(to_domain, dbconnection, sqlquery, cache, self.section, False, self.logger) return enforce def examine(self, suspect): encryption_protocol = suspect.get_value('encryption_protocol') recipient=suspect.get_value('recipient') rcpt_email = strip_address(recipient) if rcpt_email=='' or rcpt_email is None: return DUNNO enforce = self.enforce_domain(extract_domain(rcpt_email)) action = DUNNO message = None if enforce and encryption_protocol == '': action=string_to_actioncode(self.config.get(self.section, 'action')) message = apply_template(self.config.get(self.section,'messagetemplate'),suspect) return action, message def lint(self): lint_ok = True if not self.checkConfig(): print('Error checking config') lint_ok = False if lint_ok: domainlist = self.config.get(self.section,'domainlist') if domainlist.strip() == '': print('Enforcing TLS for all domains') elif domainlist.startswith('txt:'): domainfile = domainlist[4:] if not os.path.exists(domainfile): print('Cannot find domain file %s' % domainfile) lint_ok = False elif domainlist.startswith('sql:'): sqlquery = domainlist[4:] if not sqlquery.lower().startswith('select '): lint_ok = False print('SQL statement must be a SELECT query') if not SQL_EXTENSION_ENABLED: print('SQLAlchemy not available, cannot use sql backend') if lint_ok: dbconnection = self.config.get(self.section, 'dbconnection') try: conn=get_session(dbconnection) conn.execute(sqlquery, {'domain':'example.com'}) except Exception as e: lint_ok = False print(str(e)) else: lint_ok = False print('Could not determine domain list backend type') return lint_ok def __str__(self): return "EnforceTLS"
Upload File
Create Folder