From 4999ed7b1cb631ba64f9b0b31892dacdbf6f2f25 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Fri, 22 Dec 2023 07:21:37 -0800 Subject: [PATCH] Fixed Q003 (avoidable-escaped-quote): Change outer quotes to avoid escaping inner quotes --- management/email_administrator.py | 2 +- management/web_update.py | 4 ++-- tests/fail2ban.py | 4 ++-- tests/test_dns.py | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/management/email_administrator.py b/management/email_administrator.py index bd4d62d5..e5307e32 100755 --- a/management/email_administrator.py +++ b/management/email_administrator.py @@ -37,7 +37,7 @@ msg = MIMEMultipart('alternative') # In Python 3.6: #msg = Message() -msg['From'] = "\"{}\" <{}>".format(env['PRIMARY_HOSTNAME'], admin_addr) +msg['From'] = '"{}" <{}>'.format(env['PRIMARY_HOSTNAME'], admin_addr) msg['To'] = admin_addr msg['Subject'] = "[{}] {}".format(env['PRIMARY_HOSTNAME'], subject) diff --git a/management/web_update.py b/management/web_update.py index 6747a5b8..0a652b22 100644 --- a/management/web_update.py +++ b/management/web_update.py @@ -202,9 +202,9 @@ def make_domain_config(domain, templates, ssl_certificates, env): # Add the HSTS header. if hsts == "yes": - nginx_conf_extra += "\tadd_header Strict-Transport-Security \"max-age=15768000\" always;\n" + nginx_conf_extra += '\tadd_header Strict-Transport-Security "max-age=15768000" always;\n' elif hsts == "preload": - nginx_conf_extra += "\tadd_header Strict-Transport-Security \"max-age=15768000; includeSubDomains; preload\" always;\n" + nginx_conf_extra += '\tadd_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload" always;\n' # Add in any user customizations in the includes/ folder. nginx_conf_custom_include = os.path.join(env["STORAGE_ROOT"], "www", safe_domain_name(domain) + ".conf") diff --git a/tests/fail2ban.py b/tests/fail2ban.py index 23f9c298..04eabacc 100644 --- a/tests/fail2ban.py +++ b/tests/fail2ban.py @@ -11,7 +11,7 @@ import sys, os, time # parse command line if len(sys.argv) != 4: - print("Usage: tests/fail2ban.py \"ssh user@hostname\" hostname owncloud_user") + print('Usage: tests/fail2ban.py "ssh user@hostname" hostname owncloud_user') sys.exit(1) ssh_command, hostname, owncloud_user = sys.argv[1:4] @@ -153,7 +153,7 @@ def restart_fail2ban_service(final=False): if not final: # Stop recidive jails during testing. command += " && sudo fail2ban-client stop recidive" - os.system("{} \"{}\"".format(ssh_command, command)) + os.system('{} "{}"'.format(ssh_command, command)) def testfunc_runner(i, testfunc, *args): print(i+1, end=" ", flush=True) diff --git a/tests/test_dns.py b/tests/test_dns.py index 11f6d2ed..eac0ce1b 100755 --- a/tests/test_dns.py +++ b/tests/test_dns.py @@ -27,10 +27,10 @@ def test(server, description): ("ns2." + primary_hostname, "A", ipaddr), ("www." + hostname, "A", ipaddr), (hostname, "MX", "10 " + primary_hostname + "."), - (hostname, "TXT", "\"v=spf1 mx -all\""), - ("mail._domainkey." + hostname, "TXT", "\"v=DKIM1; k=rsa; s=email; \" \"p=__KEY__\""), + (hostname, "TXT", '"v=spf1 mx -all"'), + ("mail._domainkey." + hostname, "TXT", '"v=DKIM1; k=rsa; s=email; " "p=__KEY__"'), #("_adsp._domainkey." + hostname, "TXT", "\"dkim=all\""), - ("_dmarc." + hostname, "TXT", "\"v=DMARC1; p=quarantine;\""), + ("_dmarc." + hostname, "TXT", '"v=DMARC1; p=quarantine;"'), ] return test2(tests, server, description) @@ -59,7 +59,7 @@ def test2(tests, server, description): response = ["[no value]"] response = ";".join(str(r) for r in response) response = re.sub(r"(\"p=).*(\")", r"\1__KEY__\2", response) # normalize DKIM key - response = response.replace("\"\" ", "") # normalize TXT records (DNSSEC signing inserts empty text string components) + response = response.replace('"" ', "") # normalize TXT records (DNSSEC signing inserts empty text string components) # is it right? if response == expected_answer: