Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14096476
D17688.id42540.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D17688.id42540.diff
View Options
diff --git a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
--- a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
+++ b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
@@ -163,6 +163,8 @@
$author_phid,
id(new PhabricatorDiffusionApplication())->getPHID());
+ $acting_user = $this->loadActingUser($actor, $acting_as_phid);
+
$conn_w = id(new DifferentialRevision())->establishConnection('w');
// NOTE: The `differential_commit` table has a unique ID on `commitPHID`,
@@ -263,7 +265,8 @@
$acting_as_phid,
$repository,
$commit,
- $message);
+ $message,
+ $acting_user);
}
$data->save();
@@ -287,7 +290,22 @@
$acting_as,
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit,
- $message) {
+ $message,
+ PhabricatorUser $acting_user = null) {
+
+ // If we we were able to identify an author for the commit, we try to act
+ // as that user when loading tasks marked with "Fixes Txxx". This prevents
+ // mistakes where a user accidentally writes the wrong task IDs and affects
+ // tasks they can't see (and thus can't undo the status changes for).
+
+ // This is just a guard rail, not a security measure. An attacker can still
+ // forge another user's identity trivially by forging author or committer
+ // emails. We also let commits with unrecognized authors act on any task to
+ // make behavior less confusing for new installs.
+
+ if (!$acting_user) {
+ $acting_user = $actor;
+ }
$maniphest = 'PhabricatorManiphestApplication';
if (!PhabricatorApplication::isClassInstalled($maniphest)) {
@@ -321,9 +339,14 @@
}
$tasks = id(new ManiphestTaskQuery())
- ->setViewer($actor)
+ ->setViewer($acting_user)
->withIDs(array_keys($task_statuses))
->needProjectPHIDs(true)
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
->execute();
foreach ($tasks as $task_id => $task) {
@@ -369,4 +392,26 @@
}
}
+ private function loadActingUser(PhabricatorUser $viewer, $user_phid) {
+ if (!$user_phid) {
+ return null;
+ }
+
+ $user_type = PhabricatorPeopleUserPHIDType::TYPECONST;
+ if (phid_get_type($user_phid) != $user_type) {
+ return null;
+ }
+
+ $user = id(new PhabricatorPeopleQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($user_phid))
+ ->executeOne();
+ if (!$user) {
+ return null;
+ }
+
+ return $user;
+ }
+
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 3:40 AM (20 h, 47 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6791784
Default Alt Text
D17688.id42540.diff (2 KB)
Attached To
Mode
D17688: When closing tasks with "Fixes xxx", try to act more authentically as the acting user
Attached
Detach File
Event Timeline
Log In to Comment