Bug 43503 - Ошибка в регулярке для проверки rsync url
Summary: Ошибка в регулярке для проверки rsync url
Status: CLOSED FIXED
Alias: None
Product: Sisyphus
Classification: Development
Component: alterator-mirror (show other bugs)
Version: unstable
Hardware: x86_64 Linux
: P5 normal
Assignee: manowar@altlinux.org
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-12 09:23 MSK by Anton Shevtsov
Modified: 2023-12-04 12:57 MSK (History)
2 users (show)

See Also:


Attachments
Ошибка rsync url (41.45 KB, image/png)
2022-08-12 09:23 MSK, Anton Shevtsov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.