@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.

Prevent Repository local path edit from the web UI

Summary:
Ref T4039. This fixes an issue where a user with the ability to create repositories could view repositories he is otherwise not permitted to see, by following these steps:

- Suppose you want to see repository "A".
- Create a repository with the same VCS, called "B".
- Edit the local path, changing "/var/repo/B" to "/var/repo/A".
- Now it points at a working copy of a repository you can't see.
- Although you won't be able to make it through discovery (the pull will fail with the wrong credentials), you can read some information out of the repository directly through the Diffusion UI, probably?

I'm not sure this was really practical to execute since there are a bunch of sanity checks along most/all of the major pathways, but lock it down since normal users shouldn't be editing it anyway. In the best case, this would make a mess.

Test Plan: {F81391}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4039

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

+8 -40
+8 -40
src/applications/diffusion/controller/DiffusionRepositoryEditLocalController.php
··· 26 26 $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/'); 27 27 28 28 $v_local = $repository->getHumanReadableDetail('local-path'); 29 - $e_local = true; 30 29 $errors = array(); 31 30 32 - if ($request->isFormPost()) { 33 - $v_local = $request->getStr('local'); 34 - 35 - if (!strlen($v_local)) { 36 - $e_local = pht('Required'); 37 - $errors[] = pht('You must specify a local path.'); 38 - } 39 - 40 - if (!$errors) { 41 - $xactions = array(); 42 - $template = id(new PhabricatorRepositoryTransaction()); 43 - 44 - $type_local = PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH; 45 - 46 - $xactions[] = id(clone $template) 47 - ->setTransactionType($type_local) 48 - ->setNewValue($v_local); 49 - 50 - try { 51 - id(new PhabricatorRepositoryEditor()) 52 - ->setContinueOnNoEffect(true) 53 - ->setContentSourceFromRequest($request) 54 - ->setActor($user) 55 - ->applyTransactions($repository, $xactions); 56 - 57 - return id(new AphrontRedirectResponse())->setURI($edit_uri); 58 - } catch (Exception $ex) { 59 - $errors[] = $ex->getMessage(); 60 - } 61 - } 62 - } 63 - 64 31 $crumbs = $this->buildApplicationCrumbs(); 65 32 $crumbs->addCrumb( 66 33 id(new PhabricatorCrumbView()) ··· 79 46 ->setUser($user) 80 47 ->appendRemarkupInstructions( 81 48 pht( 82 - 'You can adjust the local path for this repository here. This is '. 83 - 'an advanced setting and you usually should not change it.')) 49 + "You can not adjust the local path for this repository from the ". 50 + "web interface. To edit it, run this command:\n\n". 51 + " phabricator/ $ ./bin/repository edit %s --as %s --local-path ...", 52 + $repository->getCallsign(), 53 + $user->getUsername())) 84 54 ->appendChild( 85 - id(new AphrontFormTextControl()) 55 + id(new AphrontFormMarkupControl()) 86 56 ->setName('local') 87 57 ->setLabel(pht('Local Path')) 88 - ->setValue($v_local) 89 - ->setError($e_local)) 58 + ->setValue($v_local)) 90 59 ->appendChild( 91 60 id(new AphrontFormSubmitControl()) 92 - ->setValue(pht('Save Local')) 93 - ->addCancelButton($edit_uri)); 61 + ->addCancelButton($edit_uri, pht('Done'))); 94 62 95 63 $object_box = id(new PHUIObjectBoxView()) 96 64 ->setHeaderText($title)