Custom Query (332 matches)
Results (136 - 138 of 332)
Ticket | Resolution | Summary | Owner | Reporter |
---|---|---|---|---|
#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:
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!
|
|||
#195 | fixed | Enhancement for ticket prefixes | bas | Konstantin Ryabitsev <icon@…> |
Description |
Some of the requests we receive need to be created with a closed status. It's kind of silly, but we need a record of the request for reference, but we don't want the ticket to be open because it's not an actionable item. This is easy to accomplish using projects and ticket prefixes, but the following patch was necessary to be able to set status and resolution. There's really no reason why resolution should be excluded from the list of fields -- it just limits someone's options. :) Same goes for status. |
|||
#214 | fixed | Permission to update the ticket, but not set properties | bas | Konstantin Ryabitsev <icon@…> |
Description |
Hello, me again: I like the new permissions system, but I would like to see it more fine-grained. I would like anyone to be able to update the ticket comments, but restrict setting properties (via subject line or inline properties) only to people who have permission to update the ticket. What do you think? |