Skip to content

Commit 7fc8313

Browse files
authored
Merge pull request #498 from cibere/plugin-download-url-validation
Validate download url in `validator.py`
2 parents 62b9660 + e78574d commit 7fc8313

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

ci/src/_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
# If adding a third-party library here, check CI workflows Python files
99
# that are dependant on this and require pip install.
1010

11+
github_download_url_regex = re.compile(
12+
r"https://github\.com/(?P<author>[a-zA-Z0-9-]+)/(?P<repo>[a-zA-Z0-9\.\-\_]*)/releases/download/(?P<version>[a-zA-Z\.0-9]+)/(?P<filename>.*)\.zip"
13+
)
14+
1115
# path
1216
utils_path = Path(__file__).resolve()
1317

ci/src/updater.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
from _utils import *
1515
from discord import update_hook
1616

17-
github_download_url_regex = re.compile(
18-
r"https://github\.com/(?P<author>[a-zA-Z0-9-]+)/(?P<repo>[a-zA-Z0-9\.\-\_]*)/releases/download/(?P<version>[a-zA-Z\.0-9]+)/(?P<filename>.*)\.zip"
19-
)
20-
21-
2217
async def batch_github_plugin_info(
2318
info: P, tags: ETagsType, github_token=None, webhook_url: str | None = None
2419
) -> P:

ci/src/validator.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import uuid
33

44
from _utils import (check_url, clean, get_new_plugin_submission_ids, get_plugin_file_paths, get_plugin_filenames,
5-
icon_path, id_name, language_list, language_name, plugin_reader)
5+
icon_path, id_name, language_list, language_name, plugin_reader, github_download_url_regex, url_download)
66

77
plugin_infos = plugin_reader()
88

@@ -52,3 +52,7 @@ def test_submitted_plugin_id_is_valid_uuid():
5252
outcome = False
5353

5454
assert outcome is True, f"The submission plugin ID {id} is not a valid v4 UUID"
55+
56+
def test_valid_download_url():
57+
for info in plugin_infos:
58+
assert github_download_url_regex.fullmatch(info[url_download]), f" The plugin {info['Name']}-{info['ID']} does not have a valid download url: {info[url_download]}"

0 commit comments

Comments
 (0)