private function isCommitDoneOnWhitelistElement(Project $project, $path)
 {
     $whitelist = $this->handler->getAllowedTagsFromWhiteList($project);
     if (!$whitelist) {
         return false;
     }
     array_walk($whitelist, 'preg_quote');
     $allowed_tags = implode('|', $whitelist);
     $pattern = "%^\n            A\\s+tags/(?:{$allowed_tags})/[^/]+/?\$ # A  tags/moduleA/v1/   (allowed)\n                                                # A  tags/moduleA/toto  (allowed)\n                                                # A  tags/moduleA/v1/toto (forbidden)\n            %x";
     return preg_match($pattern, $path);
 }
Example #2
0
 private function isCommitDoneOnWhitelistElement(Project $project, $path)
 {
     $whitelist = $this->handler->getAllowedTagsFromWhiteList($project);
     if (!$whitelist) {
         return false;
     }
     $whitelist_regexp = array();
     foreach ($whitelist as $whitelist_path) {
         $whitelist_regexp[] = $this->getWellFormedRegexImmutablePath($whitelist_path);
     }
     $allowed_tags = implode('|', $whitelist_regexp);
     $pattern = "%^\n            A\\s+(?:{$allowed_tags})/[^/]+/?\$  # A  tags/moduleA/v1/   (allowed)\n                                            # A  tags/moduleA/toto  (allowed)\n                                            # A  tags/moduleA/v1/toto (forbidden)\n            %x";
     return preg_match($pattern, $path);
 }
Example #3
0
 *
 * Tuleap is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Tuleap is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tuleap; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
$immutable_tags_handler = new SVN_Immutable_Tags_Handler(new SVN_Immutable_Tags_DAO());
$request->valid(new Valid_String('post_changes'));
$request->valid(new Valid_String('SUBMIT'));
if ($request->isPost() && $request->existAndNonEmpty('post_changes')) {
    $vImmutableTagsWhitelist = new Valid_Text('immutable-tags-whitelist');
    $vImmutableTagsPath = new Valid_Text('immutable-tags-path');
    if ($request->valid($vImmutableTagsWhitelist) && $request->valid($vImmutableTagsPath)) {
        $immutable_tags_whitelist = trim($request->get('immutable-tags-whitelist'));
        $immutable_tags_path = trim($request->get('immutable-tags-path'));
        $immutable_tags_handler->saveImmutableTagsForProject($group_id, $immutable_tags_whitelist, $immutable_tags_path);
    } else {
        $GLOBALS['Response']->addFeedback('error', $Language->getText('svn_admin_general_settings', 'upd_fail'));
    }
    $GLOBALS['Response']->redirect('/svn/admin/?func=immutable_tags&group_id=' . $group_id);
}
// Display the form
 *
 * Tuleap is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tuleap; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
// CAUTION!!
// Make the changes before calling svn_header_admin because
// svn_header_admin caches the project object in memory and
// the form values are therefore not updated.
//
$immutable_tags_handler = new SVN_Immutable_Tags_Handler(new SVN_Immutable_Tags_DAO());
$request->valid(new Valid_String('post_changes'));
$request->valid(new Valid_String('SUBMIT'));
if ($request->isPost() && $request->existAndNonEmpty('post_changes')) {
    $vTracked = new Valid_WhiteList('form_tracked', array('0', '1'));
    $vTracked->required();
    $vMandatoryRef = new Valid_WhiteList('form_mandatory_ref', array('0', '1'));
    $vMandatoryRef->required();
    $vPreamble = new Valid_Text('form_preamble');
    $vCanChangeSVNLog = new Valid_WhiteList('form_can_change_svn_log', array('0', '1'));
    $vCanChangeSVNLog->required();
    $vAllowedImmutableTags = new Valid_WhiteList('form_tag_immutable', array('0', '1', '2'));
    $vAllowedImmutableTags->required();
    $vImmutableTagsWhitelist = new Valid_Text('immutable-tags-whitelist');
    if ($request->valid($vTracked) && $request->valid($vPreamble) && $request->valid($vMandatoryRef) && $request->valid($vCanChangeSVNLog) && $request->valid($vAllowedImmutableTags) && $request->valid($vImmutableTagsWhitelist)) {
        // group_id was validated in index.