Bug 10624 - Ability to set patch metadata from a mail
Summary: Ability to set patch metadata from a mail
Status: RESOLVED FIXED
Alias: None
Product: Patchwork/Patchtest
Classification: Yocto Project Subprojects
Component: Patchwork (show other bugs)
Version: unspecified
Hardware: All Multiple
: Medium+ enhancement
Target Milestone: 2.3 M3
Assignee: Jose Lamego
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks: 11027
  Show dependency tree
 
Reported: 2016-11-08 16:32 UTC by Ross Burton
Modified: 2017-12-06 17:15 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ross Burton 2016-11-08 16:32:01 UTC
If I reply to a patch in my mailer to say "OH MY GOD THIS IS THE WORST THING EVER", I don't want to also have to go into patchworks to set the patch status to rejected.

Some sort of magic in-line metadata such as putting "Patchworks-Status: Rejected" on a newline would be awesome.

(also useful for "I sent a v2 of this but forgot to tag it as such, Patchwork-Status: Superseded).
Comment 1 Jose Lamego 2017-01-17 18:17:23 UTC
I've developed a patch for parsemail.py to parse a comment's content and identify the presence of a defined string to trigger a patch status change.

It was successfully tested in a patchwork test instance, however, I'd like to collect some feedback before testing this change in OE's staging patchwork:

Currently, only the original patch submitter and the project maintainers (when logged as such) are able to change a patch status. Enabling the status-changing from an email does bypass patchwork's user authentication, unless we also include metadata to identify the user in the email (not sure of feasibility). From other requests, we concluded that this type of additional authentication would involve a complexity level that may not be worth the effort (to maintain security at least).

One approach that I may suggest would be to only allow for certain statuses to be available for email-changing, for example:

Under Review, RFC, Not Applicable, Changes Requested, Awaiting, Upstream, Superseded, Deferred

and leave Accepted and Rejected as they currently are: to only be set either by authorized users from the Patchwork UI, or when a patch is merged. 

Let me know if we should include someone else in this discussion.
Comment 2 Paul Eggleton 2017-01-19 18:46:07 UTC
Jose and I discussed this and I think this is a reasonable feature to have. We can check if the email comes from the submitter or a person with an account in patchwork with sufficient permissions simply by looking at the from address. Regarding security concerns, when I analyse risks I consider likelihood and consequences:

* Likelihood - it seems rather unlikely that someone would spoof the email of someone else on the list; as far as I can recall it's never happened within our project and there would be little benefit to doing so.

* Consequences - patchwork doesn't directly control any other process, so this can't result in any malicious patch getting merged; the worst that could happen is a bunch of patches have their status changed which could easily be reverted.

Furthermore, it's highly unlikely that this would go unnoticed - the email would have to go onto the public mailing list, where the person who'd been spoofed (and everyone else) would be able to see it.

We would want to try to ensure it wasn't accidentally triggered, though. For example, we shouldn't be looking inside the body of patches - if the email is solely a patch, just the commit message (and text after ---).
Comment 3 Ross Burton 2017-01-24 15:16:34 UTC
I'd like the ability to set Rejected from a mail to be honest, so I can review with comments on the list and set the rejected flag without having to open a web browser.  Changes Requested covers "you've made a typo" but doesn't cover "no, you're doing this wrong, don't do this".
Comment 4 Jose Lamego 2017-01-24 18:30:04 UTC
I've sent a patch to allow patch state to be changed if the string "Patchwork-Status: <new-state>" is found in the message body and only if the comment author is recognized as a project maintainer:
https://lists.yoctoproject.org/pipermail/yocto/2017-January/034143.html

This has been successfully tested in a testing instance and is currently implemented in patchwork-staging:
https://patchwork-staging.openembedded.org/
Comment 5 Jose Lamego 2017-01-24 20:10:43 UTC
Ross: You can test this feature now by replying to a patch thread and including anywhere in the reply body a new line with the string (including square brackets):
[Patchwork-Status: <the desired status>]

where the desired status can be any of the existing ones, excepting Accepted.

You will see no change at production, but at patchwork-staging the patch status will be updated.
Comment 6 Ross Burton 2017-01-24 20:53:10 UTC
It worked!

What level of filtering does it do - if user A sets status Foo, user B sets status Bar, and then A replies to their original mail will the hook notice the quoted [Patchwork-Status] line and change the status again?
Comment 7 Jose Lamego 2017-01-24 21:00:56 UTC
The script looks for all string matches, but reply lines (starting with any character other than "[" or a space/tab) are ignored.
If there are multiple matches, the script uses the last found.
Comment 8 Ross Burton 2017-01-24 21:02:21 UTC
Sounds good, thanks.
Comment 9 Jose Lamego 2017-01-24 22:32:04 UTC
This change is implemented in OE-patchwork. Project maintainers can update a patch status by replying to a patch thread and including in the email message a new line with the string (no leading spaces or tabs):

[Patchwork-Status: <new-status>]

where <new-status> can be any of 
  Under Review
  Rejected
  Not Applicable
  Changes Requested
  Awaiting Upstream
  Superseded
  Deferred

this feature is only available for emails submitted by project maintainers recognized as such in OE-patchwork.