mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-05 18:50:09 +02:00
Merge branch 'whitelist-firebase' into 'master'
Whitelist some open-source firebase libs See merge request fdroid/fdroidserver!411
This commit is contained in:
commit
86c5598307
@ -69,9 +69,18 @@ def scan_source(build_dir, build):
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
whitelisted = [
|
||||||
|
'firebase-jobdispatcher', # https://github.com/firebase/firebase-jobdispatcher-android/blob/master/LICENSE
|
||||||
|
'com.firebaseui', # https://github.com/firebase/FirebaseUI-Android/blob/master/LICENSE
|
||||||
|
'geofire-android' # https://github.com/firebase/geofire-java/blob/master/LICENSE
|
||||||
|
]
|
||||||
|
|
||||||
|
def is_whitelisted(s):
|
||||||
|
return any(wl in s for wl in whitelisted)
|
||||||
|
|
||||||
def suspects_found(s):
|
def suspects_found(s):
|
||||||
for n, r in usual_suspects.items():
|
for n, r in usual_suspects.items():
|
||||||
if r.match(s):
|
if r.match(s) and not is_whitelisted(s):
|
||||||
yield n
|
yield n
|
||||||
|
|
||||||
gradle_mavenrepo = re.compile(r'maven *{ *(url)? *[\'"]?([^ \'"]*)[\'"]?')
|
gradle_mavenrepo = re.compile(r'maven *{ *(url)? *[\'"]?([^ \'"]*)[\'"]?')
|
||||||
@ -198,7 +207,7 @@ def scan_source(build_dir, build):
|
|||||||
|
|
||||||
elif ext == 'jar':
|
elif ext == 'jar':
|
||||||
for name in suspects_found(curfile):
|
for name in suspects_found(curfile):
|
||||||
count += handleproblem('usual supect \'%s\'' % name, path_in_build_dir, filepath)
|
count += handleproblem('usual suspect \'%s\'' % name, path_in_build_dir, filepath)
|
||||||
if curfile == 'gradle-wrapper.jar':
|
if curfile == 'gradle-wrapper.jar':
|
||||||
removeproblem('gradle-wrapper.jar', path_in_build_dir, filepath)
|
removeproblem('gradle-wrapper.jar', path_in_build_dir, filepath)
|
||||||
else:
|
else:
|
||||||
@ -224,7 +233,7 @@ def scan_source(build_dir, build):
|
|||||||
for i, line in enumerate(lines):
|
for i, line in enumerate(lines):
|
||||||
if is_used_by_gradle(line):
|
if is_used_by_gradle(line):
|
||||||
for name in suspects_found(line):
|
for name in suspects_found(line):
|
||||||
count += handleproblem('usual supect \'%s\' at line %d' % (name, i + 1), path_in_build_dir, filepath)
|
count += handleproblem('usual suspect \'%s\' at line %d' % (name, i + 1), path_in_build_dir, filepath)
|
||||||
noncomment_lines = [l for l in lines if not common.gradle_comment.match(l)]
|
noncomment_lines = [l for l in lines if not common.gradle_comment.match(l)]
|
||||||
joined = re.sub(r'[\n\r\s]+', ' ', ' '.join(noncomment_lines))
|
joined = re.sub(r'[\n\r\s]+', ' ', ' '.join(noncomment_lines))
|
||||||
for m in gradle_mavenrepo.finditer(joined):
|
for m in gradle_mavenrepo.finditer(joined):
|
||||||
|
33
tests/scanner.TestCase
Executable file
33
tests/scanner.TestCase
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import optparse
|
||||||
|
from pathlib import Path
|
||||||
|
from os.path import basename, dirname, realpath
|
||||||
|
|
||||||
|
from fdroidserver import scanner
|
||||||
|
from fdroidserver.metadata import Build
|
||||||
|
import fdroidserver.common
|
||||||
|
|
||||||
|
|
||||||
|
class ScannerTest(unittest.TestCase):
|
||||||
|
def test_scan_source_files(self):
|
||||||
|
source_files = Path(dirname(realpath(__file__)), 'source-files')
|
||||||
|
projects = {
|
||||||
|
'Zillode': 1,
|
||||||
|
'firebase-suspect': 1
|
||||||
|
}
|
||||||
|
for d in (str(p) for p in source_files.iterdir()):
|
||||||
|
fatal_problems = scanner.scan_source(d, Build())
|
||||||
|
self.assertEqual(projects.get(basename(d), 0), fatal_problems)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = optparse.OptionParser()
|
||||||
|
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||||
|
help="Spew out even more information than normal")
|
||||||
|
(fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
|
||||||
|
|
||||||
|
newSuite = unittest.TestSuite()
|
||||||
|
newSuite.addTest(unittest.makeSuite(ScannerTest))
|
||||||
|
unittest.main(failfast=False)
|
5
tests/source-files/firebase-suspect/app/build.gradle
Normal file
5
tests/source-files/firebase-suspect/app/build.gradle
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
dependencies {
|
||||||
|
compile 'com.google.firebase:firebase-core:11.6.2'
|
||||||
|
|
||||||
|
testCompile 'junit:junit:4.12'
|
||||||
|
}
|
11
tests/source-files/firebase-suspect/build.gradle
Normal file
11
tests/source-files/firebase-suspect/build.gradle
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:2.3.3'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
maven { url "https://maven.google.com" }
|
||||||
|
}
|
||||||
|
}
|
5
tests/source-files/firebase-whitelisted/app/build.gradle
Normal file
5
tests/source-files/firebase-whitelisted/app/build.gradle
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
dependencies {
|
||||||
|
compile 'com.firebase:firebase-jobdispatcher:0.8.4'
|
||||||
|
|
||||||
|
testCompile 'junit:junit:4.12'
|
||||||
|
}
|
14
tests/source-files/firebase-whitelisted/build.gradle
Normal file
14
tests/source-files/firebase-whitelisted/build.gradle
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:2.3.3'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user