Commit Graph

823 Commits

Author SHA1 Message Date
Cecylia Bocovich
fc9e1ed212 Treat all email sending exceptions the same
In the previous commit, we forgot to remove requests that trigger
exceptions other than SMTPClientError.
2021-03-07 19:15:21 -05:00
Cecylia Bocovich
80371ae66a Remove all requests that cause exceptions from db
This solves gettor#77 where a non-ascii email address was causing our
SMTP client to throw an error. We need to remove the request from the
database in order to move on and process the rest of the requests.
2021-03-07 19:09:06 -05:00
hanneloresx
ae30ca5e22 Redact email addr from error msgs
Addresses issue #34058 to scrub logs of personal info.
2021-01-25 10:57:17 -05:00
hanneloresx
dd2818ee27 fix minor spelling error 2021-01-23 17:46:20 -05:00
Cecylia Bocovich
6a95ed9e0b Only parse email subject and body
Closes issue #75 where the headers were being parsed for locale
instead of the message body.
2021-01-12 14:00:11 -05:00
Cecylia Bocovich
3b1b0190d4 Fix typo in new gitlab links 2020-06-12 11:45:35 -04:00
Cecylia Bocovich
4ed0f9ae02 Remove logging of successful db query 2020-06-05 13:59:36 -04:00
Philipp Winter
b3de2e35ea
Don't assume that request has "command" key.
If GetTor deals with an autoresponder, it returns an empty request,
which is then passed to parse_callback, which raises a KeyError because
of request["command"]:

2020-05-29 19:04:43+0000 [email parser] Error while parsing email content: [Failure instance: Traceback: <class 'KeyError'>: 'command'
	/usr/lib/python3/dist-packages/twisted/internet/defer.py:311:addCallbacks
	/usr/lib/python3/dist-packages/twisted/internet/defer.py:654:_runCallbacks
	/usr/lib/python3/dist-packages/twisted/internet/defer.py:1613:unwindGenerator
	/usr/lib/python3/dist-packages/twisted/internet/defer.py:1529:_cancellableInlineCallbacks
	--- <exception caught here> ---
	/usr/lib/python3/dist-packages/twisted/internet/defer.py:1418:_inlineCallbacks
	/srv/gettor.torproject.org/home/gettor/gettor/parse/email.py:256:parse_callback
	].

This is a fixup of: <https://bugs.torproject.org/34286>
2020-05-29 16:23:19 -07:00
Cecylia Bocovich
012ef1a402 Check to see if email is from an autoresponder
This checks to see if an incoming request is from a known autoresponder.
GetTor can get into infinite loops with itself or postmaster addresses
(Bug #34286)
2020-05-29 15:01:07 -04:00
Cecylia Bocovich
b78bc3ff92 Ignore emails from Mail Delivery System
This ignores emails with the username "MAILER-DAEMON", a common email
for mail delivery systems. The goal of this is to avoid getting into a
loop with mail delivery system autoresponders after a bounced email.
2020-05-22 16:36:36 -04:00
Cecylia Bocovich
3670e782fd Change levels at which service messages are logged
A lot of these are debug messages and don't need to be logged by
default.
2020-05-04 15:08:55 -04:00
Cecylia Bocovich
b8d228adc2 Set default log level for gettor to "info" 2020-05-04 15:08:55 -04:00
Cecylia Bocovich
21645db1a3 Delete service instance during shutdown
Before we were calling a non-existent shutdown function. These instances
already have __del__ functions so we can just call those instead.
2020-04-29 14:46:58 -04:00
Cecylia Bocovich
390120a0f9 Refactor to dry out sendmail
Instead of processing link and help requests separately, we can process
them together and use the command to determine the different subject and
body messages.

Removed unused code and simplified database command.
2020-04-29 11:22:37 -04:00
Cecylia Bocovich
3a878213ba Check SMTP error code and remove request from db
This adds an extra check on SMTP errors to see if it's due to a bad
recipient address and then removes the request from the database. This
prevents one bad request from hanging up the processing of other
requests (see https://bugs.torproject.org/34027).
2020-04-27 14:57:46 -04:00
Cecylia Bocovich
1f2080412c Remove old mirror API
This isn't called by any other code and hasn't worked for a long time.
2020-04-13 16:44:53 -04:00
Cecylia Bocovich
138c915228 Remove old upload documentation 2020-04-13 16:44:39 -04:00
Cecylia Bocovich
a85474e3e3 Update license 2020-04-13 16:40:54 -04:00
Cecylia Bocovich
d33a70a47e Remove accidental files
These files are empty or were accidentially added to the repository
2020-04-13 16:38:51 -04:00
Cecylia Bocovich
e96087d745 Remove GetTor website mirror code
This used to be the location of the code for gettor.torproject.org, but
that has been moved into a separate repository. While this old code is
suitable for GetTor mirror sites, it is very out of date and unclear
whether we want to support this going forward.
2020-04-13 16:31:03 -04:00
Cecylia Bocovich
880912bb2c Remove all old upload scripts
These have been replaced by newer scripts located in the top-level
scripts/ directory.
2020-04-13 16:28:24 -04:00
Cecylia Bocovich
63559201e2 Add signature verification instructions to email 2020-03-18 16:12:10 -04:00
Cecylia Bocovich
36820cc151 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
2020-03-18 14:57:45 -04:00
Cecylia Bocovich
7f1fd7e2c8 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
2020-03-18 14:36:23 -04:00
Cecylia Bocovich
bd227cfc75 Update setup.py and requirements.txt 2020-03-18 13:33:25 -04:00
Cecylia Bocovich
829fa9fbaa Make locale parsing less eager
This will make the locale parsing more restrictive so that, for example,
sending "i like fries" will not result in the locale "fr".
2020-03-12 13:13:08 -04:00
Cecylia Bocovich
c8e385babe Add more test cases for different email styles
teor mentioned in ticket #23225 that some clients will top-post replies
without quoting the the text. This commit adds a test case for that.
Since the command detector is greedy, gettor parses the reply first.

Also added a test for bottom-posting.
2020-03-12 13:13:08 -04:00
Cecylia Bocovich
0cd6443cdd Ensure replies to the help message will work
This commit makes some changes and adds some tests to ensure that
valid replies to the gettor help message will contain links.
Non-valid replies should still return the GetTor help message.
2020-03-12 13:13:00 -04:00
Cecylia Bocovich
0297dbcddb Change gitlab repository name to include version
This fixes an issue caused by gitlab repositories soft-delete for 7 days
before they are fully deleted. If we remove a repository in order
to upload new binaries, we need to be able to create a new one right
away. See https://bugs.torproject.org/33034
2020-03-11 12:46:50 -04:00
Cecylia Bocovich
61afa2c544 Always reply to gettor emails
This fixes a bug where improperly formatted emails were not receiving
gettor replies. We should always reply to emails and default to sending
a help message if the request was invalid.

This also prioritizes sending links if both a valid links request and
the word help were sent. Several tests were added.
2020-03-06 14:07:45 -05:00
Cecylia Bocovich
64df8b27b3 Expand tests for database functions in gettor 2020-02-19 14:40:28 -05:00
Cecylia Bocovich
c413a8ebda Add method to close dbpool and call it
We were leaving connections to the database open, which causes some
calls to hang. This adds destructors to the SQLite3 class and the
classes that use it, and refactors some code to make one database
connection per class object. This also makes sure that the destructors
for objects that use databases are actually called.
2020-02-19 14:40:28 -05:00
Cecylia Bocovich
c6cfd91241 Add database tests 2020-02-19 14:40:28 -05:00
Cecylia Bocovich
dac0ab6263 Revert to using twisted for sqlite3 db 2020-02-19 14:36:56 -05:00
Cecylia Bocovich
3d6fb34e71 Add tests for database functions 2020-02-13 15:01:00 -05:00
Cecylia Bocovich
e4f6d98fb9 Switch from twisted adbapi to sqlite3 package
The rest of GetTor uses the python sqlite3 package, and it's much
simpler to use and to test.
2020-02-07 19:15:38 -05:00
Cecylia Bocovich
40589f08d6 Removed unused imports 2020-02-07 19:15:38 -05:00
Cecylia Bocovich
c2930fe339 Remove completed gettor requests from database
This will remove gettor requests from the requests database when they
are completed (rather than changing the status to 'SENT'). There's no
need to keep this information around, and we don't want to store
hashed email addresses as identifiers long term.
2020-02-07 19:12:31 -05:00
Cecylia Bocovich
3dfc2fdbaa Update help message to allow locales
The only help message urged users to only specify 'en' as a locale. We
now support all locales for tor browser binaries.
2020-01-31 11:52:23 -05:00
Cecylia Bocovich
56399f5a71 Update send mail to get user requested locale
This updates sendmail to get links and save stats for the user requested
locale. Right now all body translations default to english since we
haven't translated it yet.
2020-01-31 09:53:32 -05:00
Cecylia Bocovich
277ba71b46 Make locale parser more robust
This change expands the locale parse to have the following properties:
- if only the language code is given, choses the regionalization that
occurs first in the locale list (e.g., "en" --> "en-US"
- if regionalization for the language is *not* present, choses the
generalized language or a different regionalization (e.g. "pt-PT" -->
"pt-BR")
- parses both the subject and body looking for the most specific
regionalization
- defaults to en-US if no available language is found
2020-01-27 10:17:29 -05:00
Cecylia Bocovich
4fa4d6368c Refactor email keyword parser
This commit refactors build_request to prevent duplicate code. It
also moves the platforms definition to the parser constructor.
2020-01-27 09:58:26 -05:00
Cecylia Bocovich
187e27da76 Modified email parser to get locales from db
Before we were conflating the locales for the tor browser binaries with
the available locale for gettor email body localizations. This patch
checks our links database for available locales.
2020-01-27 09:48:23 -05:00
Cecylia Bocovich
4005315b36 Slight changes to README for tests 2020-01-23 13:32:56 -05:00
Cecylia Bocovich
9bbda2ab50 Change es string test to match json file
We haven't translated any es or pt strings, so use the English
translation for now until we update those files.
2020-01-23 13:32:56 -05:00
Cecylia Bocovich
3517e54ca7 Remove twitter test that requires auth
Removes tests that require access to secrets.
2020-01-23 13:32:56 -05:00
Cecylia Bocovich
c1672a3f8d Create a test database with gettor links 2020-01-23 13:32:56 -05:00
Cecylia Bocovich
2ef6773bec Update tests to load a test config 2020-01-23 13:32:56 -05:00
Cecylia Bocovich
34e912bbb3 Fix edge case where config file never declared
This commit fixes an edge case in which the config filename is never
declared if the config is set but the file does not exist on disk.
2020-01-23 13:32:56 -05:00
Cecylia Bocovich
4c8dd8568a Make gitlab repositories public
Created projects default to private, we need to set the visibility in
the script to make them public.
2020-01-23 09:26:50 -05:00