Bug 43503

Summary: Ошибка в регулярке для проверки rsync url
Product: Sisyphus Reporter: Anton Shevtsov <shevtsov.anton>
Component: alterator-mirrorAssignee: manowar <manowar>
Status: CLOSED FIXED QA Contact: qa-sisyphus
Severity: normal    
Priority: P5 CC: cas, manowar
Version: unstable   
Hardware: x86_64   
OS: Linux   
Attachments:
Description Flags
Ошибка rsync url none

Description Anton Shevtsov 2022-08-12 09:23:08 MSK
Created attachment 11317 [details]
Ошибка rsync url

При указании пользовательского urlа, и отметке что будет локальное зеркало - возникает ошибка неверного url

Я посмотрел код и нашел, что в /usr/lib/alterator/backend3/mirror регулярка rsync_url_re не содержит ошибку.

Предлагаю заменить
--- mirror.old  2022-08-12 11:17:22.908873911 +0500
+++ mirror      2022-08-12 11:15:47.895057333 +0500
@@ -13,7 +13,8 @@
 alterator_api_version=1
 
 url_re='^\(ftp://\|http://\|rsync://\|file:/\)[a-zA-Z0-9._/:@-]\+$'
-rsync_url_re='^rsync://[a-zA-Z0-9._/-:@]\+$'
+#rsync_url_re='^rsync://[a-zA-Z0-9._/-:@]\+$'
+rsync_url_re='^rsync://[\/\-\d\w:@.]+$'
 
 . alterator-sh-functions
 . avahi-sh-functions
@@ -400,7 +401,7 @@
                                    elif ! echo "$in_custom_url"|grep -qs "$url_re";then
                                        write_error "`_ "Invalid or unsupported protocol. Should be http,ftp or rsync"`"
                                        return
-                                   elif [ -n "$in_local" ] && ! echo "$in_custom_url"|grep -qs "$rsync_url_re";then
+                                   elif [ -n "$in_local" ] && ! echo "$in_custom_url"|grep -qsP "$rsync_url_re";then
                                        write_error "`_ "Can mirror only from sources with rsync procotol"`"
                                        return
                                    fi


Тест проходит
#!/bin/bash

#old
#rsync_url_re='^rsync://[a-zA-Z0-9._/-:@]\+$'
rsync_url_re='^rsync://[\/\-\d\w:@.]+$'
in_custom_url='rsync://user:pass@adm-alt-update/path/'
in_local=1

#if [ -n "$in_local" ] && ! echo "$in_custom_url"|grep -qs "$rsync_url_re" ;then
if  ! echo "$in_custom_url"|grep -qsP "$rsync_url_re" ;then
                                        echo  "Can mirror only from sources with rsync procotol"
                                else
                                        echo 'Rsync url valid'
fi
Comment 1 Anton Shevtsov 2022-08-12 09:23:42 MSK
не содержит ошибку = содержит ошибку
Comment 2 Repository Robot 2023-12-04 12:57:13 MSK
alterator-mirror-0.4.10-alt1 -> sisyphus:

 Mon Dec 04 2023 Andrey Cherepanov <cas@altlinux> 0.4.10-alt1
 - Supported allowed repo names in /etc/alterator/mirror/allowed.
 - Fixed regexp for custom url (ALT #43503).
 - Added alterator-mirror-allowed package with allowed repositories.