Custom Query (332 matches)

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (196 - 198 of 332)

Ticket Resolution Summary Owner Reporter
#218 fixed Problem when multiple trac accounts match email address bas Konstantin Ryabitsev <icon@…>
Description

I came across a problem when enabling "ticket_permission_system: trac". If there is more than one account that matches the same email address (e.g. for me it was both "konstantin" and "tracadmin" accounts), then the user lookup fails and email2trac treats emails from me as coming from a non-trac user. This tweak fixes the problem.

  • (a) email2trac.py.in vs. (b) -

    a b  
    339339                users = [ (u,n,e) for (u, n, e) in self.env.get_known_users(self.db)
    340340                        if e and (e.lower() == self.email_addr.lower()) ]
    341341
    342                 if len(users) == 1:
     342                if len(users) >= 1:
    343343                        self.email_from = users[0][0]
    344344                        self.author = users[0][0]
    345345
#203 fixed [PATCH]: Allow restricting ticket updates to ticket participants bas kris@…
Description

USE CASE: I use email2trac to integrate an internal instance of Trac with traditional user support ticketing via email. This is great, because it keeps both internal and external issues under the same roof. Users simply send in their support requests via e-mail and email2trac + Trac notifications handle the rest while keeping Trac itself restricted. [ Parenthetically, by use of tags and an outgoing filter in the MTA, external tickets can also have internal comments allowing us to define which updates are to be sent out externally. This would of course be better to implement in the Trac layer, but it does the job. ]

PROBLEM: With ticket_update on, email2trac allows any ticket to be updated by just changing the ticket number in the Subject. While great for an open Trac, it opens a security hole when Trac is used for private ticketing. Example:

1) mike@… has a ticket #453: Someone hijacked my account

2) steve@… sends a random email with the same ticket number, eg. #453: Sneak me in which appends his comment to a ticket he should have no access to. If always_notify_updater is on, it will also add him to the notification list. The sender anomaly is easy to miss and scanning for it a needless mental burden. Obviously, the intent may not even be malicious, eg. Steve may have corrupted the Subject line by accident.

PATCHED BEHAVIOR: by turning on ticket_update_restricted_to_participants, a ticket update is allowed only if 1) the updater is the reporter, 2) the updater is in the CC or 3) the updater matches a Trac username (i.e. is staff). If the update is denied, a new ticket will be generated instead as to not loose the issue (NOTE: the current trunk will drop any e-mail that has a ticket number which does not match a ticket; this patch also fixes that as a side-effect).

Index: email2trac.py.in
===================================================================
--- email2trac.py.in    (revision 375)
+++ email2trac.py.in    (working copy)
@@ -197,6 +197,11 @@
                else:
                        self.TICKET_UPDATE = 0

+               if parameters.has_key('ticket_update_restricted_to_participants'):
+                       self.TICKET_UPDATE_RESTRICTED_TO_PARTICIPANTS = int(parameters['ticket_update_restricted_to_participants'])
+               else:
+                       self.TICKET_UPDATE_RESTRICTED_TO_PARTICIPANTS = 0
+
                if parameters.has_key('ticket_update_by_subject'):
                        self.TICKET_UPDATE_BY_SUBJECT = int(parameters['ticket_update_by_subject'])
                else:
@@ -762,6 +767,42 @@
                        self.id = None
                        return False

+
+               if self.TICKET_UPDATE_RESTRICTED_TO_PARTICIPANTS:
+
+                       # Is the updater the reporter?
+                       # Since all Trac users are allowed to update, it does
+                       # not matter if any of our fields contain usernames
+                       # instead of emails.
+                       #
+                       if tkt['reporter'] and self.email_addr.lower() == tkt['reporter'].lower():
+                               if self.DEBUG:
+                                       print 'Restricted update: ALLOW, %s is the ticket reporter' %(self.email_addr)
+
+                       # Is the updater in the CC?
+                       elif tkt['cc'] and self.email_addr.lower() in tkt['cc'].lower().replace(' ', '').split(','):  # assuming space is fragile, hence replace()
+                               if self.DEBUG:
+                                       print 'Restricted update: ALLOW, %s is in the CC' %(self.email_addr)
+
+                       else:
+                               tkt_allow_update = False
+
+                               # Is the update a Trac user?
+                               for username, name, email in self.env.get_known_users():
+                                       if email and email.lower() == self.email_addr.lower():
+                                               tkt_allow_update = True
+                                               if self.DEBUG:
+                                                       print 'Restricted update: ALLOW, %s matches username %s' %(self.email_addr, username)
+                                               break
+
+                               # No luck? Fail the update.
+                               if not tkt_allow_update:
+                                       if self.DEBUG:
+                                               print 'Restricted update: DENIED, %s does not match a username nor is it the reporter or in the CC' %(self.email_addr)
+                                       self.id = None
+                                       return False
+
+
                # How many changes has this ticket
                cnum = len(tkt.get_changelog())

@@ -1486,7 +1527,11 @@
                        #
                        if result.group('reply') and self.TICKET_UPDATE:
                                self.system = 'ticket'
-                               self.ticket_update(m, result.group('reply'), spam_msg)
+                               result = self.ticket_update(m, result.group('reply'), spam_msg)
+
+                               # If the ticket was not found, create a new one instead of loosing it
+                               if not result:
+                                       self.new_ticket(m, subject, spam_msg)

                        # New ticket + fields
                        #

Looking forward to seeing whether you think this is something that should go into the release. The patch itself is rather verbose due to the debugging. FWIW this was also my first foray into Python, apologies if the patch is not very Pythonic. :)

Thanks a lot for your efforts, keep up the great work!

-Kris

#364 fixed notify_sender doesn't work, probably since r633 bas kroseneg@…
Description

Error message:

Failure sending notification on creation of ticket #22212: global name 'sender_email' is not defined

sender_email was used globally for self.email_addr, now tn.email2trac_notify_reporter is used.

This patch fixes the problem:

--- email2trac.py.in	(revision 660)
+++ email2trac.py.in	(working copy)
@@ -2486,7 +2486,7 @@
 
                 if self.email2trac_notify_reporter:
                     if not self.email2trac_notify_reporter in torcpts:
-                        torcpts.append(sender_email)
+                        torcpts.append(self.email2trac_notify_reporter)
 
                 if self.email2trac_replyto:
                     # use to rewrite reply to
Note: See TracQuery for help on using queries.