mirror of https://gitlab.com/bashrc2/epicyon
Check for malformed ciphertext within incoming posts
parent
3024bd77d3
commit
6f2b02f369
|
@ -237,6 +237,7 @@ from categories import updateHashtagCategories
|
||||||
from languages import getActorLanguages
|
from languages import getActorLanguages
|
||||||
from languages import setActorLanguages
|
from languages import setActorLanguages
|
||||||
from like import updateLikesCollection
|
from like import updateLikesCollection
|
||||||
|
from utils import malformedCiphertext
|
||||||
from utils import hasActor
|
from utils import hasActor
|
||||||
from utils import setReplyIntervalHours
|
from utils import setReplyIntervalHours
|
||||||
from utils import canReplyTo
|
from utils import canReplyTo
|
||||||
|
@ -1490,10 +1491,15 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# save the json for later queue processing
|
# save the json for later queue processing
|
||||||
messageBytesDecoded = messageBytes.decode('utf-8')
|
messageBytesDecoded = messageBytes.decode('utf-8')
|
||||||
|
|
||||||
|
if malformedCiphertext(messageBytesDecoded):
|
||||||
|
print('WARN: post contains malformed ciphertext ' +
|
||||||
|
str(originalMessageJson))
|
||||||
|
return 4
|
||||||
|
|
||||||
if containsInvalidLocalLinks(messageBytesDecoded):
|
if containsInvalidLocalLinks(messageBytesDecoded):
|
||||||
print('WARN: post contains invalid local links ' +
|
print('WARN: post contains invalid local links ' +
|
||||||
str(originalMessageJson))
|
str(originalMessageJson))
|
||||||
return 4
|
return 5
|
||||||
|
|
||||||
self.server.blockedCacheLastUpdated = \
|
self.server.blockedCacheLastUpdated = \
|
||||||
updateBlockedCache(self.server.baseDir,
|
updateBlockedCache(self.server.baseDir,
|
||||||
|
|
10
utils.py
10
utils.py
|
@ -2537,6 +2537,16 @@ def isPGPEncrypted(content: str) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def malformedCiphertext(content: str) -> bool:
|
||||||
|
"""Returns true if the given content contains a malformed key
|
||||||
|
"""
|
||||||
|
if '----BEGIN ' in content or '----END ' in content:
|
||||||
|
if not containsPGPPublicKey(content) and \
|
||||||
|
not isPGPEncrypted(content):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def loadTranslationsFromFile(baseDir: str, language: str) -> ({}, str):
|
def loadTranslationsFromFile(baseDir: str, language: str) -> ({}, str):
|
||||||
"""Returns the translations dictionary
|
"""Returns the translations dictionary
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue