@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Don't show client IP in push logs unless viewer can edit the repository

Summary: This locks push logs down a little bit and makes them slightly more administrative. Primarily, don't show IPs to googlebot, etc.

Test Plan: Viewed push logs as edit and non-edit users.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

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

+39 -5
+39 -5
src/applications/diffusion/controller/DiffusionPushLogListController.php
··· 30 30 31 31 $this->loadHandles(mpull($logs, 'getPusherPHID')); 32 32 33 + // Figure out which repositories are editable. We only let you see remote 34 + // IPs if you have edit capability on a repository. 35 + $editable_repos = array(); 36 + if ($logs) { 37 + $editable_repos = id(new PhabricatorRepositoryQuery()) 38 + ->setViewer($viewer) 39 + ->requireCapabilities( 40 + array( 41 + PhabricatorPolicyCapability::CAN_VIEW, 42 + PhabricatorPolicyCapability::CAN_EDIT, 43 + )) 44 + ->withPHIDs(mpull($logs, 'getRepositoryPHID')) 45 + ->execute(); 46 + $editable_repos = mpull($editable_repos, null, 'getPHID'); 47 + } 48 + 33 49 $rows = array(); 34 50 foreach ($logs as $log) { 51 + 52 + // Reveal this if it's valid and the user can edit the repository. 53 + $remote_addr = '-'; 54 + if (isset($editable_repos[$log->getRepositoryPHID()])) { 55 + $remote_long = $log->getRemoteAddress(); 56 + if ($remote_long) { 57 + $remote_addr = long2ip($remote_long); 58 + } 59 + } 60 + 35 61 $callsign = $log->getRepository()->getCallsign(); 36 62 $rows[] = array( 37 63 phutil_tag( ··· 41 67 ), 42 68 $callsign), 43 69 $this->getHandle($log->getPusherPHID())->renderLink(), 44 - $log->getRemoteAddress() 45 - ? long2ip($log->getRemoteAddress()) 46 - : null, 70 + $remote_addr, 47 71 $log->getRemoteProtocol(), 48 72 $log->getRefType(), 49 73 $log->getRefName(), 50 - $log->getRefOldShort(), 51 - $log->getRefNewShort(), 74 + phutil_tag( 75 + 'a', 76 + array( 77 + 'href' => '/r'.$callsign.$log->getRefOld(), 78 + ), 79 + $log->getRefOldShort()), 80 + phutil_tag( 81 + 'a', 82 + array( 83 + 'href' => '/r'.$callsign.$log->getRefNew(), 84 + ), 85 + $log->getRefNewShort()), 52 86 phabricator_datetime($log->getEpoch(), $viewer), 53 87 ); 54 88 }