diff --git a/fdroidserver/lint.py b/fdroidserver/lint.py index 86246d36..1dfc00fa 100644 --- a/fdroidserver/lint.py +++ b/fdroidserver/lint.py @@ -33,7 +33,7 @@ options = None def enforce_https(domain): - return (re.compile(r'^[^h][^t][^t][^p][^s]://[^/]*' + re.escape(domain) + r'(/.*)?', re.IGNORECASE), + return (re.compile(r'^http://([^/]*\.)?' + re.escape(domain) + r'(/.*)?', re.IGNORECASE), domain + " URLs should always use https://") @@ -120,9 +120,11 @@ http_url_shorteners = [ ] http_checks = https_enforcings + http_url_shorteners + [ - (re.compile(r'.*github\.com/[^/]+/[^/]+\.git'), + (re.compile(r'^(?!https?://)[^/]+'), + _("URL must start with https:// or http://")), + (re.compile(r'^https://(github|gitlab)\.com(/[^/]+){2,3}\.git'), _("Appending .git is not necessary")), - (re.compile(r'.*://[^/]*(github|gitlab|bitbucket|rawgit)[^/]*/([^/]+/){1,3}master'), + (re.compile(r'^https://[^/]*(github|gitlab|bitbucket|rawgit|githubusercontent)\.[a-zA-Z]+/([^/]+/){2,3}master/'), _("Use /HEAD instead of /master to point at a file in the default branch")), ] @@ -726,6 +728,7 @@ APPROVED_LICENSES = [ 'LiLiQ-Rplus-1.1', 'MIT', 'MIT-0', + 'MIT-CMU', 'MPL-1.0', 'MPL-1.1', 'MPL-2.0', diff --git a/jenkins-build-all b/jenkins-build-all index 2765ab63..34b6dfd7 100755 --- a/jenkins-build-all +++ b/jenkins-build-all @@ -82,6 +82,7 @@ else fi echo "build_server_always = True" > config.py +echo "deploy_process_logs = True" >> config.py # if the local mediawiki is available, then use it if nc -z -w1 localhost 32445; then wikiflag="--wiki" diff --git a/tests/lint.TestCase b/tests/lint.TestCase index f5dd2c30..54cfc365 100755 --- a/tests/lint.TestCase +++ b/tests/lint.TestCase @@ -70,6 +70,55 @@ class LintTest(unittest.TestCase): logging.debug(warn) self.assertTrue(anywarns) + def test_source_urls(self): + config = dict() + fdroidserver.common.fill_config_defaults(config) + fdroidserver.common.config = config + fdroidserver.lint.config = config + + app = { + 'Name': 'My App', + 'Summary': 'just a placeholder', + 'Description': 'This app does all sorts of useful stuff', + } + good_urls = [ + 'https://github.com/Matteljay/mastermindy-android', + 'https://gitlab.com/origin/master', + 'https://gitlab.com/group/subgroup/masterthing', + 'https://raw.githubusercontent.com/Seva-coder/Finder/HEAD/ChangeLog.txt', + 'https://github.com/scoutant/blokish/blob/HEAD/README.md#changelog', + 'https://git.ieval.ro/?p=fonbot.git;a=blob;f=Changes;hb=HEAD', + 'https://htmlpreview.github.io/?https://github.com/YasuakiHonda/Maxima-on-Android-AS/blob/HEAD/app/src/main/assets/About_MoA/index.html', + '', + ] + + anywarns = False + for url in good_urls: + app['SourceCode'] = url + for warn in fdroidserver.lint.check_regexes(app): + anywarns = True + logging.debug(warn) + self.assertFalse(anywarns) + + bad_urls = [ + 'github.com/my/proj', + 'http://github.com/not/secure', + 'https://github.com/foo/bar.git', + 'https://gitlab.com/group/subgroup/project.git', + 'https://raw.githubusercontent.com/Seva-coder/Finder/master/ChangeLog.txt', + 'https://github.com/scoutant/blokish/blob/master/README.md#changelog', + 'http://htmlpreview.github.io/?https://github.com/my/project/blob/HEAD/index.html', + 'http://fdroid.gitlab.io/fdroid-website', + ] + logging.debug('bad urls:') + for url in bad_urls: + anywarns = False + app['SourceCode'] = url + for warn in fdroidserver.lint.check_regexes(app): + anywarns = True + logging.debug(warn) + self.assertTrue(anywarns, url + " does not fail lint!") + def test_check_app_field_types(self): config = dict() fdroidserver.common.fill_config_defaults(config)