From 7f1fd7e2c8ad5235af99ff3af9c5e5c94d16e5f8 Mon Sep 17 00:00:00 2001 From: Cecylia Bocovich Date: Wed, 18 Mar 2020 14:18:05 -0400 Subject: [PATCH 1/3] Update GetTor help message This restructures the GetTor help message. The message now includes: - instructions to reply to the message for links - available locales - a valid example links request --- gettor/services/email/sendmail.py | 22 +++++++++++++++++----- share/locale/en.json | 9 ++++++--- tests/test_email_service.py | 8 ++++++-- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/gettor/services/email/sendmail.py b/gettor/services/email/sendmail.py index 754fb5b..07d343b 100644 --- a/gettor/services/email/sendmail.py +++ b/gettor/services/email/sendmail.py @@ -98,11 +98,21 @@ class Sendmail(object): requireTransportSecurity=True ).addCallback(self.sendmail_callback).addErrback(self.sendmail_errback) - - def build_help_body_message(self): - body_msg = strings._("help_body_intro") - body_msg += strings._("help_body_paragraph") + def build_locale_string(self, locales): + locale_string = "" + for locale in locales: + locale_string += "\t" + locale[0] + "\n" + return locale_string + + def build_help_body_message(self, locale_string): + body_msg = strings._("body_intro") + body_msg += strings._("help_body_intro") body_msg += strings._("help_body_support") + body_msg += "\twindows\n\tlinux\n\tosx\n\n" + body_msg += strings._("help_body_respond") + body_msg += strings._("help_body_locale") + body_msg += locale_string + "\n" + body_msg += strings._("help_body_example").format("Windows", "Arabic", "windows ar") return body_msg @@ -176,8 +186,10 @@ class Sendmail(object): hid.hexdigest() ) ) + locales = yield self.conn.get_locales() + locale_string = self.build_locale_string(locales) - body_msg = self.build_help_body_message() + body_msg = self.build_help_body_message(locale_string) yield self.sendmail( email_addr=id, diff --git a/share/locale/en.json b/share/locale/en.json index dba3047..fd47984 100644 --- a/share/locale/en.json +++ b/share/locale/en.json @@ -1,4 +1,5 @@ { + "body_intro": "This is an automated email response from GetTor.\n\n", "links_body_platform": "You requested Tor Browser for {}.\n\n", "links_body_links": "You will need only one of the links below to download the bundle. If a link does not work for you, try the next one.\n\n{}\n\n", "links_body_archive": "Should you have issues with any of the links above you can access the following archives:\n\n", @@ -7,9 +8,11 @@ "links_body_download_filename": "Download the file: {}\n\n", "links_body_ending": "\n--\nGetTor", "links_subject": "[GetTor] Links for your request", - "help_body_intro": "This is how you can request a tor browser bundle link.\n\n", - "help_body_paragraph": "Send an email to: gettor@torproject.org\n\nIn the body of the email only write: .\n\n", - "help_body_support": "We only support windows, osx and linux as operating systems.\n\n", + "help_body_intro": "GetTor can send you download links for Tor Browser.\n", + "help_body_support": "Simply reply to this email and write the operating system you want to install Tor Browser on in your response. We support the following operating systems:\n\n", + "help_body_respond": "GetTor will then respond with download instructions.\n\n", + "help_body_locale": "If you want Tor Browser in a language other than English, mention one of the following language codes in your response:\n\n", + "help_body_example": "For example, if you want Tor Browser for {} in {} your email content will look like:\n\n\t{}\n\n", "help_subject": "[GetTor] Help Email", "help_debug": "Log application errors to stdout", "help_config": "Custom config file location (optional)", diff --git a/tests/test_email_service.py b/tests/test_email_service.py index 4326b9c..5c0ddfb 100644 --- a/tests/test_email_service.py +++ b/tests/test_email_service.py @@ -198,10 +198,14 @@ class EmailServiceTests(unittest.TestCase): body_msg = ep.build_body_message(link_msg, "osx", file) assert "You requested Tor Browser for osx" in body_msg + @pytest_twisted.inlineCallbacks def test_help_body_message(self): ep = self.sm_client - help_msg = ep.build_help_body_message() - assert "This is how you can request a tor browser bundle link" in help_msg + locales = yield ep.conn.get_locales() + locale_string = ep.build_locale_string(locales) + help_msg = ep.build_help_body_message(locale_string) + assert "This is an automated email response from GetTor." in help_msg + assert "\twindows\n\tlinux\n\tosx\n" in help_msg @pytest_twisted.inlineCallbacks def test_get_locales(self): -- GitLab From 36820cc1510db8dea1667af53bdbe6f2caf4cb6d Mon Sep 17 00:00:00 2001 From: Cecylia Bocovich Date: Wed, 18 Mar 2020 14:57:45 -0400 Subject: [PATCH 2/3] Update GetTor links message This makes the following changes to the links message: - Breaks user actions into steps - Simplifies wordings - Includes signature verification and bridge instructions --- gettor/services/email/sendmail.py | 21 +++++++++++---------- share/locale/en.json | 12 ++++++------ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/gettor/services/email/sendmail.py b/gettor/services/email/sendmail.py index 07d343b..22a5111 100644 --- a/gettor/services/email/sendmail.py +++ b/gettor/services/email/sendmail.py @@ -122,9 +122,10 @@ class Sendmail(object): Build the links strings """ - link_msg = None + link_msg = "" for link in links: + print(link) provider = link[5] version = link[4] arch = link[3] @@ -132,11 +133,9 @@ class Sendmail(object): file = link[7] sig_url = url + ".asc" - link_str = "Tor Browser {} for {}-{}-{} ({}): {}\n".format( - version, platform, locale, arch, provider, url - ) + link_str = "\t{}: {}\n".format(provider, url) - link_str += "Signature file: {}\n".format(sig_url) + link_str += "\tSignature file: {}\n".format(sig_url) link_msg = "{}\n{}".format(link_msg, link_str) @@ -144,13 +143,15 @@ class Sendmail(object): def build_body_message(self, link_msg, platform, file): - body_msg = strings._("links_body_platform").format(platform) - body_msg += strings._("links_body_links").format(link_msg) - body_msg += strings._("links_body_archive") + body_msg = strings._("body_intro") + body_msg += strings._("links_body_platform").format(platform) + body_msg += strings._("links_body_step1").format(link_msg) + body_msg += strings._("links_body_archive").format(file) body_msg += strings._("links_body_internet_archive") body_msg += strings._("links_body_google_drive") - body_msg += strings._("links_body_download_filename").format(file) - body_msg += strings._("links_body_ending") + body_msg += strings._("links_body_step2") + body_msg += strings._("links_body_step3") + print(body_msg) return body_msg diff --git a/share/locale/en.json b/share/locale/en.json index fd47984..9a97100 100644 --- a/share/locale/en.json +++ b/share/locale/en.json @@ -1,12 +1,12 @@ { "body_intro": "This is an automated email response from GetTor.\n\n", "links_body_platform": "You requested Tor Browser for {}.\n\n", - "links_body_links": "You will need only one of the links below to download the bundle. If a link does not work for you, try the next one.\n\n{}\n\n", - "links_body_archive": "Should you have issues with any of the links above you can access the following archives:\n\n", - "links_body_internet_archive": "- Internet Archive: https://archive.org/details/@gettor\n\n", - "links_body_google_drive": "- Google Drive folder: https://drive.google.com/open?id=13CADQTsCwrGsIID09YQbNz2DfRMUoxUU\n\n", - "links_body_download_filename": "Download the file: {}\n\n", - "links_body_ending": "\n--\nGetTor", + "links_body_step1": "Step 1: Download Tor Browser\n\n\tFirst, try downloading Tor Browser from either GitLab or GitHub:\n\n{}\n\n", + "links_body_archive": "\tIf you cannot download Tor Browser from GitLab or GitHub,\n\ttry downloading the file {}\n\tfrom the following archives:\n\n", + "links_body_internet_archive": "\tInternet Archive: https://archive.org/details/@gettor\n\n", + "links_body_google_drive": "\tGoogle Drive folder: https://drive.google.com/open?id=13CADQTsCwrGsIID09YQbNz2DfRMUoxUU\n\n", + "links_body_step2": "Step 2: Verify the signature (Optional)\n\n\tVerifying the signature ensures that a certain package was generated by its\n\tdevelopers, and has not been tampered with. This email provides links to signature\n\tfiles that have the same name as the Tor Browser file, but end with \".asc\" instead.\n\n", + "links_body_step3": "Step 3: Get Bridges (Optional)\n\n\tIf you believe that Tor is blocked where you are, you can use bridges to connect\n\tto Tor. Bridges are hidden Tor relays that can circumvent censorship.\n\tTor Browser includes a list of built-in bridges, which you should try first.\n\tYou can activate built-in bridges inside of Tor Browser's settings, under the\n\t\"Tor\" menu. If built-in bridges don't work, try requesting different bridges,\n\twhich you can also do in the \"Tor\" menu inside Tor Browser's settings.\n\n", "links_subject": "[GetTor] Links for your request", "help_body_intro": "GetTor can send you download links for Tor Browser.\n", "help_body_support": "Simply reply to this email and write the operating system you want to install Tor Browser on in your response. We support the following operating systems:\n\n", -- GitLab From 63559201e21331ded6da078108ba903ffeebb38d Mon Sep 17 00:00:00 2001 From: Cecylia Bocovich Date: Wed, 18 Mar 2020 16:12:10 -0400 Subject: [PATCH 3/3] Add signature verification instructions to email --- gettor/services/email/sendmail.py | 14 +++++++++-- share/locale/en.json | 4 +++ tests/test_email_service.py | 42 ++++++++++++++----------------- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/gettor/services/email/sendmail.py b/gettor/services/email/sendmail.py index 22a5111..4d908b3 100644 --- a/gettor/services/email/sendmail.py +++ b/gettor/services/email/sendmail.py @@ -125,7 +125,6 @@ class Sendmail(object): link_msg = "" for link in links: - print(link) provider = link[5] version = link[4] arch = link[3] @@ -143,6 +142,16 @@ class Sendmail(object): def build_body_message(self, link_msg, platform, file): + signature_strings = { + "windows":"links_body_windows", + "linux":"links_body_linux", + "osx":"links_body_osx" + } + signature_cmds = { + "windows":"gpgv --keyring .\\tor.keyring Downloads\\{0}.asc Downloads\\{0}", + "linux":"gpgv --keyring ./tor.keyring ~/Downloads/{}{{.asc,}}", + "osx":"gpgv --keyring ./tor.keyring ~/Downloads/{}{{.asc,}}" + } body_msg = strings._("body_intro") body_msg += strings._("links_body_platform").format(platform) body_msg += strings._("links_body_step1").format(link_msg) @@ -150,8 +159,9 @@ class Sendmail(object): body_msg += strings._("links_body_internet_archive") body_msg += strings._("links_body_google_drive") body_msg += strings._("links_body_step2") + body_msg += strings._(signature_strings[platform]) + body_msg += strings._("links_body_all").format(signature_cmds[platform].format(file)) body_msg += strings._("links_body_step3") - print(body_msg) return body_msg diff --git a/share/locale/en.json b/share/locale/en.json index 9a97100..8737d51 100644 --- a/share/locale/en.json +++ b/share/locale/en.json @@ -6,6 +6,10 @@ "links_body_internet_archive": "\tInternet Archive: https://archive.org/details/@gettor\n\n", "links_body_google_drive": "\tGoogle Drive folder: https://drive.google.com/open?id=13CADQTsCwrGsIID09YQbNz2DfRMUoxUU\n\n", "links_body_step2": "Step 2: Verify the signature (Optional)\n\n\tVerifying the signature ensures that a certain package was generated by its\n\tdevelopers, and has not been tampered with. This email provides links to signature\n\tfiles that have the same name as the Tor Browser file, but end with \".asc\" instead.\n\n", + "links_body_all":"\tThe Tor Browser team signs Tor Browser releases. Import the Tor Browser Developers\n\tsigning key (0xEF6E286DDA85EA2A4BA7DE684E2C6E8793298290):\n\n\t\tgpg --auto-key-locate nodefault,wkd --locate-keys torbrowser@torproject.org\n\n\tThis should show you something like:\n\n\t\tgpg: key 4E2C6E8793298290: public key \"Tor Browser Developers (signing key) \" imported\n\t\tgpg: Total number processed: 1\n\t\tgpg: imported: 1\n\t\tpub rsa4096 2014-12-15 [C] [expires: 2020-08-24]\n\t\t EF6E286DDA85EA2A4BA7DE684E2C6E8793298290\n\t\tuid [ unknown] Tor Browser Developers (signing key) \n\t\tsub rsa4096 2018-05-26 [S] [expires: 2020-09-12]\n\n\tAfter importing the key, you can save it to a file (identifying it by fingerprint here):\n\n\t\tgpg --output ./tor.keyring --export 0xEF6E286DDA85EA2A4BA7DE684E2C6E8793298290\n\n\tNext, you will need to download the corresponding \".asc\" signature file and verify it\n\twith the command:\n\n\t\t{}\n\n\tThe result of the command should produce something like this:\n\n\t\tgpgv: Signature made 07/08/19 04:03:49 Pacific Daylight Time\n\t\tgpgv: using RSA key EB774491D9FF06E2\n\t\tgpgv: Good signature from \"Tor Browser Developers (signing key) \"\n\n", + "links_body_windows":"\tIf you run Windows, download Gpg4win and run its installer. In order to verify the\n\tsignature you will need to type a few commands in windows command-line, cmd.exe.\n\n", + "links_body_osx":"\tIf you are using macOS, you can install GPGTools. In order to verify the signature\n\tyou will need to type a few commands in the Terminal (under \"Applications\").\n\n", + "links_body_linux":"\tIf you are using GNU/Linux, then you probably already have GnuPG in your system,\n\tas most GNU/Linux distributions come with it preinstalled. In order to verify the\n\tsignature you will need to type a few commands in a terminal window.\n\n", "links_body_step3": "Step 3: Get Bridges (Optional)\n\n\tIf you believe that Tor is blocked where you are, you can use bridges to connect\n\tto Tor. Bridges are hidden Tor relays that can circumvent censorship.\n\tTor Browser includes a list of built-in bridges, which you should try first.\n\tYou can activate built-in bridges inside of Tor Browser's settings, under the\n\t\"Tor\" menu. If built-in bridges don't work, try requesting different bridges,\n\twhich you can also do in the \"Tor\" menu inside Tor Browser's settings.\n\n", "links_subject": "[GetTor] Links for your request", "help_body_intro": "GetTor can send you download links for Tor Browser.\n", diff --git a/tests/test_email_service.py b/tests/test_email_service.py index 5c0ddfb..3803e79 100644 --- a/tests/test_email_service.py +++ b/tests/test_email_service.py @@ -17,18 +17,6 @@ class EmailServiceTests(unittest.TestCase): self.settings = conftests.options.parse_settings("en","tests/test.conf.json") self.sm_client = conftests.Sendmail(self.settings) self.locales = conftests.strings.get_locales() - self.links = [ - [ - "https://gitlab.com/thetorproject/gettorbrowser/raw/torbrowser-releases/TorBrowser-9.0.3-osx64_en-US.dmg", - "osx", - "en-US", - "64", - "9.0.3", - "gitlab", - "ACTIVE", - "TorBrowser-9.0.3-osx64_en-US.dmg" - ] - ] def tearDown(self): print("tearDown()") @@ -182,22 +170,30 @@ class EmailServiceTests(unittest.TestCase): self.assertEqual(request["language"], "es-AR") del ep + @pytest_twisted.inlineCallbacks def test_sent_links_message(self): ep = self.sm_client - links = self.links - link_msg, file = ep.build_link_strings(links, "osx", "en") - assert "https://gitlab.com/thetorproject/gettorbrowser/raw/torbrowser-releases/TorBrowser-9.0.3-osx64_en-US.dmg" in link_msg - assert "osx" in link_msg - - self.assertEqual("TorBrowser-9.0.3-osx64_en-US.dmg", file) - - def test_sent_body_message(self): - ep = self.sm_client - links = self.links - link_msg, file = ep.build_link_strings(links, "osx", "en") + links = yield ep.conn.get_links( + platform="osx", language="en-US", status="ACTIVE" + ) + link_msg, file = ep.build_link_strings(links, "osx", "en-US") body_msg = ep.build_body_message(link_msg, "osx", file) assert "You requested Tor Browser for osx" in body_msg + links = yield ep.conn.get_links( + platform="windows", language="en-US", status="ACTIVE" + ) + link_msg, file = ep.build_link_strings(links, "windows", "en-US") + body_msg = ep.build_body_message(link_msg, "windows", file) + assert "You requested Tor Browser for windows" in body_msg + + links = yield ep.conn.get_links( + platform="linux", language="en-US", status="ACTIVE" + ) + link_msg, file = ep.build_link_strings(links, "linux", "en-US") + body_msg = ep.build_body_message(link_msg, "linux", file) + assert "You requested Tor Browser for linux" in body_msg + @pytest_twisted.inlineCallbacks def test_help_body_message(self): ep = self.sm_client -- GitLab