@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

Add an edge between Passphrase credentials and objects which use them

Summary: Ref T4122. Add an edge to keep track of where a credential is used, and show it in the UI.

Test Plan:
See "Used By":

{F84099}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4122

Differential Revision: https://secure.phabricator.com/D7628

+39 -1
+15
resources/sql/patches/20131121.passphraseedge.sql
··· 1 + CREATE TABLE {$NAMESPACE}_passphrase.edge ( 2 + src VARCHAR(64) NOT NULL COLLATE utf8_bin, 3 + type VARCHAR(64) NOT NULL COLLATE utf8_bin, 4 + dst VARCHAR(64) NOT NULL COLLATE utf8_bin, 5 + dateCreated INT UNSIGNED NOT NULL, 6 + seq INT UNSIGNED NOT NULL, 7 + dataID INT UNSIGNED, 8 + PRIMARY KEY (src, type, dst), 9 + KEY (src, type, dateCreated, seq) 10 + ) ENGINE=InnoDB, COLLATE utf8_general_ci; 11 + 12 + CREATE TABLE {$NAMESPACE}_passphrase.edgedata ( 13 + id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, 14 + data LONGTEXT NOT NULL COLLATE utf8_bin 15 + ) ENGINE=InnoDB, COLLATE utf8_general_ci;
+11
src/applications/passphrase/controller/PassphraseCredentialViewController.php
··· 151 151 pht('Username'), 152 152 $credential->getUsername()); 153 153 154 + $used_by_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( 155 + $credential->getPHID(), 156 + PhabricatorEdgeConfig::TYPE_CREDENTIAL_USED_BY_OBJECT); 157 + 158 + if ($used_by_phids) { 159 + $this->loadHandles($used_by_phids); 160 + $properties->addProperty( 161 + pht('Used By'), 162 + $this->renderHandlesForPHIDs($used_by_phids)); 163 + } 164 + 154 165 $description = $credential->getDescription(); 155 166 if (strlen($description)) { 156 167 $properties->addSectionHeader(
+1
src/applications/passphrase/storage/PassphraseCredential.php
··· 19 19 return id(new PassphraseCredential()) 20 20 ->setName('') 21 21 ->setUsername('') 22 + ->setDescription('') 22 23 ->setIsDestroyed(0) 23 24 ->setViewPolicy($actor->getPHID()) 24 25 ->setEditPolicy($actor->getPHID());
+8 -1
src/infrastructure/edges/constants/PhabricatorEdgeConfig.php
··· 60 60 const TYPE_MOCK_HAS_TASK = 37; 61 61 const TYPE_TASK_HAS_MOCK = 38; 62 62 63 + const TYPE_OBJECT_USES_CREDENTIAL = 39; 64 + const TYPE_CREDENTIAL_USED_BY_OBJECT = 40; 65 + 63 66 const TYPE_TEST_NO_CYCLE = 9000; 64 67 65 68 const TYPE_PHOB_HAS_ASANATASK = 80001; ··· 70 73 71 74 const TYPE_PHOB_HAS_JIRAISSUE = 80004; 72 75 const TYPE_JIRAISSUE_HAS_PHOB = 80005; 76 + 73 77 74 78 public static function getInverse($edge_type) { 75 79 static $map = array( ··· 134 138 self::TYPE_REVIEWER_FOR_DREV => self::TYPE_DREV_HAS_REVIEWER, 135 139 136 140 self::TYPE_PHOB_HAS_JIRAISSUE => self::TYPE_JIRAISSUE_HAS_PHOB, 137 - self:: TYPE_JIRAISSUE_HAS_PHOB => self::TYPE_PHOB_HAS_JIRAISSUE 141 + self::TYPE_JIRAISSUE_HAS_PHOB => self::TYPE_PHOB_HAS_JIRAISSUE, 142 + 143 + self::TYPE_OBJECT_USES_CREDENTIAL => self::TYPE_CREDENTIAL_USED_BY_OBJECT, 144 + self::TYPE_CREDENTIAL_USED_BY_OBJECT => self::TYPE_OBJECT_USES_CREDENTIAL, 138 145 ); 139 146 140 147 return idx($map, $edge_type);
+4
src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
··· 1772 1772 'type' => 'sql', 1773 1773 'name' => $this->getPatchPath('20131120.nuancesourcetype.sql'), 1774 1774 ), 1775 + '20131121.passphraseedge.sql' => array( 1776 + 'type' => 'sql', 1777 + 'name' => $this->getPatchPath('20131121.passphraseedge.sql'), 1778 + ), 1775 1779 ); 1776 1780 } 1777 1781 }