Check user agent domain against calling domain

main
Bob Mottram 2021-06-20 15:23:20 +01:00
parent 3f653dc90b
commit 4decc56a37
1 changed files with 9 additions and 7 deletions

View File

@ -473,14 +473,16 @@ class PubServer(BaseHTTPRequestHandler):
return None
return agentDomain
def _blockedUserAgent(self) -> bool:
def _blockedUserAgent(self, callingDomain: str) -> bool:
"""Should a GET or POST be blocked based upon its user agent?
"""
agentDomain = self._userAgentDomain()
blockedUA = False
if not agentDomain:
if self.server.userAgentDomainRequired:
return True
return False
return blockedUA
if not agentDomain.startswith(callingDomain):
blockedUA = isBlockedDomain(self.server.baseDir, agentDomain)
if blockedUA and self.server.debug:
print('Blocked User agent: ' + agentDomain)
@ -10628,7 +10630,7 @@ class PubServer(BaseHTTPRequestHandler):
self._400()
return
if self._blockedUserAgent():
if self._blockedUserAgent(callingDomain):
self._400()
return
@ -14130,7 +14132,7 @@ class PubServer(BaseHTTPRequestHandler):
self._400()
return
if self._blockedUserAgent():
if self._blockedUserAgent(callingDomain):
self._400()
return