mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-01-24 12:47:05 +00:00
Fixed RUF039 (unraw-re-pattern)
This commit is contained in:
parent
daf6d70073
commit
2021c6d501
@ -635,7 +635,7 @@ def load_pem(pem):
|
|||||||
from cryptography.x509 import load_pem_x509_certificate
|
from cryptography.x509 import load_pem_x509_certificate
|
||||||
from cryptography.hazmat.primitives import serialization
|
from cryptography.hazmat.primitives import serialization
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
pem_type = re.match(b"-+BEGIN (.*?)-+[\r\n]", pem)
|
pem_type = re.match(br"-+BEGIN (.*?)-+[\r\n]", pem)
|
||||||
if pem_type is None:
|
if pem_type is None:
|
||||||
msg = "File is not a valid PEM-formatted file."
|
msg = "File is not a valid PEM-formatted file."
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
|
@ -947,7 +947,7 @@ def get_latest_miab_version():
|
|||||||
from urllib.request import urlopen, HTTPError, URLError
|
from urllib.request import urlopen, HTTPError, URLError
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return re.search(b'TAG=(.*)', urlopen("https://mailinabox.email/setup.sh?ping=1", timeout=5).read()).group(1).decode("utf8")
|
return re.search(br'TAG=(.*)', urlopen("https://mailinabox.email/setup.sh?ping=1", timeout=5).read()).group(1).decode("utf8")
|
||||||
except (TimeoutError, HTTPError, URLError):
|
except (TimeoutError, HTTPError, URLError):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -1074,7 +1074,7 @@ class FileOutput:
|
|||||||
|
|
||||||
def print_block(self, message, first_line=" "):
|
def print_block(self, message, first_line=" "):
|
||||||
print(first_line, end='', file=self.buf)
|
print(first_line, end='', file=self.buf)
|
||||||
message = re.sub("\n\\s*", " ", message)
|
message = re.sub(r"\n\s*", " ", message)
|
||||||
words = re.split(r"(\s+)", message)
|
words = re.split(r"(\s+)", message)
|
||||||
linelen = 0
|
linelen = 0
|
||||||
for w in words:
|
for w in words:
|
||||||
|
@ -223,7 +223,7 @@ def make_domain_config(domain, templates, ssl_certificates, env):
|
|||||||
# of the previous template.
|
# of the previous template.
|
||||||
nginx_conf = "# ADDITIONAL DIRECTIVES HERE\n"
|
nginx_conf = "# ADDITIONAL DIRECTIVES HERE\n"
|
||||||
for t in [*templates, nginx_conf_extra]:
|
for t in [*templates, nginx_conf_extra]:
|
||||||
nginx_conf = re.sub("[ \t]*# ADDITIONAL DIRECTIVES HERE *\n", t, nginx_conf)
|
nginx_conf = re.sub(r"[ \t]*# ADDITIONAL DIRECTIVES HERE *\n", t, nginx_conf)
|
||||||
|
|
||||||
# Replace substitution strings in the template & return.
|
# Replace substitution strings in the template & return.
|
||||||
nginx_conf = nginx_conf.replace("$STORAGE_ROOT", env['STORAGE_ROOT'])
|
nginx_conf = nginx_conf.replace("$STORAGE_ROOT", env['STORAGE_ROOT'])
|
||||||
|
@ -94,8 +94,8 @@ def sslyze(opts, port, ok_ciphers):
|
|||||||
# Trim output to make better for storing in git.
|
# Trim output to make better for storing in git.
|
||||||
if "SCAN RESULTS FOR" not in out:
|
if "SCAN RESULTS FOR" not in out:
|
||||||
# Failed. Just output the error.
|
# Failed. Just output the error.
|
||||||
out = re.sub("[\\w\\W]*CHECKING HOST\\(S\\) AVAILABILITY\n\\s*-+\n", "", out) # chop off header that shows the host we queried
|
out = re.sub(r"[\w\W]*CHECKING HOST\(S\) AVAILABILITY\n\s*-+\n", "", out) # chop off header that shows the host we queried
|
||||||
out = re.sub("[\\w\\W]*SCAN RESULTS FOR.*\n\\s*-+\n", "", out) # chop off header that shows the host we queried
|
out = re.sub(r"[\w\W]*SCAN RESULTS FOR.*\n\s*-+\n", "", out) # chop off header that shows the host we queried
|
||||||
out = re.sub(r"SCAN COMPLETED IN .*", "", out)
|
out = re.sub(r"SCAN COMPLETED IN .*", "", out)
|
||||||
out = out.rstrip(" \n-") + "\n"
|
out = out.rstrip(" \n-") + "\n"
|
||||||
|
|
||||||
@ -105,8 +105,8 @@ def sslyze(opts, port, ok_ciphers):
|
|||||||
# Pull out the accepted ciphers list for each SSL/TLS protocol
|
# Pull out the accepted ciphers list for each SSL/TLS protocol
|
||||||
# version outputted.
|
# version outputted.
|
||||||
accepted_ciphers = set()
|
accepted_ciphers = set()
|
||||||
for ciphers in re.findall(" Accepted:([\\w\\W]*?)\n *\n", out):
|
for ciphers in re.findall(r" Accepted:([\w\W]*?)\n *\n", out):
|
||||||
accepted_ciphers |= set(re.findall("\n\\s*(\\S*)", ciphers))
|
accepted_ciphers |= set(re.findall(r"\n\s*(\S*)", ciphers))
|
||||||
|
|
||||||
# Compare to what Mozilla recommends, for a given modernness-level.
|
# Compare to what Mozilla recommends, for a given modernness-level.
|
||||||
print(" Should Not Offer: " + (", ".join(sorted(accepted_ciphers-set(ok_ciphers))) or "(none -- good)"))
|
print(" Should Not Offer: " + (", ".join(sorted(accepted_ciphers-set(ok_ciphers))) or "(none -- good)"))
|
||||||
|
@ -363,9 +363,9 @@ def quasitokenize(bashscript):
|
|||||||
newscript += c
|
newscript += c
|
||||||
|
|
||||||
# "<< EOF" escaping.
|
# "<< EOF" escaping.
|
||||||
if quote_mode is None and re.search("<<\\s*EOF\n$", newscript):
|
if quote_mode is None and re.search(r"<<\s*EOF\n$", newscript):
|
||||||
quote_mode = "EOF"
|
quote_mode = "EOF"
|
||||||
elif quote_mode == "EOF" and re.search("\nEOF\n$", newscript):
|
elif quote_mode == "EOF" and re.search(r"\nEOF\n$", newscript):
|
||||||
quote_mode = None
|
quote_mode = None
|
||||||
|
|
||||||
return newscript
|
return newscript
|
||||||
@ -405,8 +405,8 @@ class BashScript(Grammar):
|
|||||||
string = f.read()
|
string = f.read()
|
||||||
|
|
||||||
# tokenize
|
# tokenize
|
||||||
string = re.sub(".* #NODOC\n", "", string)
|
string = re.sub(r".* #NODOC\n", "", string)
|
||||||
string = re.sub("\n\\s*if .*then.*|\n\\s*fi|\n\\s*else|\n\\s*elif .*", "", string)
|
string = re.sub(r"\n\s*if .*then.*|\n\s*fi|\n\s*else|\n\s*elif .*", "", string)
|
||||||
string = quasitokenize(string)
|
string = quasitokenize(string)
|
||||||
string = string.replace("hide_output ", "")
|
string = string.replace("hide_output ", "")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user