2016-01-04 16:33:20 +01:00
|
|
|
#!/usr/bin/env python3
|
2012-01-03 16:37:29 +01:00
|
|
|
#
|
|
|
|
# scanner.py - part of the FDroid server tools
|
2013-10-31 16:37:39 +01:00
|
|
|
# Copyright (C) 2010-13, Ciaran Gultnieks, ciaran@ciarang.com
|
2012-01-03 16:37:29 +01:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import os
|
2015-08-29 04:20:39 +02:00
|
|
|
import re
|
2012-01-04 22:37:11 +01:00
|
|
|
import traceback
|
2015-09-04 11:37:05 +02:00
|
|
|
from argparse import ArgumentParser
|
2014-01-27 16:56:55 +01:00
|
|
|
import logging
|
2018-07-25 18:59:22 +02:00
|
|
|
import itertools
|
2014-01-27 16:56:55 +01:00
|
|
|
|
2017-09-13 18:03:57 +02:00
|
|
|
from . import _
|
2016-01-04 17:37:35 +01:00
|
|
|
from . import common
|
|
|
|
from . import metadata
|
2017-05-22 21:33:52 +02:00
|
|
|
from .exception import BuildException, VCSException
|
2012-01-03 16:37:29 +01:00
|
|
|
|
2013-11-01 12:10:57 +01:00
|
|
|
config = None
|
|
|
|
options = None
|
2013-10-31 16:37:39 +01:00
|
|
|
|
2014-05-02 05:39:33 +02:00
|
|
|
|
2015-11-28 17:55:27 +01:00
|
|
|
def get_gradle_compile_commands(build):
|
2018-03-08 13:55:07 +01:00
|
|
|
compileCommands = ['compile',
|
2018-07-25 18:05:04 +02:00
|
|
|
'provided',
|
|
|
|
'apk',
|
|
|
|
'implementation',
|
|
|
|
'api',
|
|
|
|
'compileOnly',
|
2018-07-25 18:59:22 +02:00
|
|
|
'runtimeOnly']
|
|
|
|
buildTypes = ['', 'release']
|
|
|
|
flavors = ['']
|
2015-11-28 17:55:27 +01:00
|
|
|
if build.gradle and build.gradle != ['yes']:
|
2018-07-25 18:59:22 +02:00
|
|
|
flavors += build.gradle
|
2015-09-18 17:22:34 +02:00
|
|
|
|
2018-07-25 18:59:22 +02:00
|
|
|
commands = [''.join(c) for c in itertools.product(flavors, buildTypes, compileCommands)]
|
|
|
|
return [re.compile(r'\s*' + c, re.IGNORECASE) for c in commands]
|
2015-09-18 17:22:34 +02:00
|
|
|
|
|
|
|
|
2018-01-23 21:55:37 +01:00
|
|
|
def scan_source(build_dir, build=metadata.Build()):
|
2017-04-13 12:30:04 +02:00
|
|
|
"""Scan the source code in the given directory (and all subdirectories)
|
|
|
|
and return the number of fatal problems encountered
|
|
|
|
"""
|
2015-08-29 04:20:39 +02:00
|
|
|
|
|
|
|
count = 0
|
|
|
|
|
|
|
|
# Common known non-free blobs (always lower case):
|
2015-09-17 02:13:54 +02:00
|
|
|
usual_suspects = {
|
|
|
|
exp: re.compile(r'.*' + exp, re.IGNORECASE) for exp in [
|
|
|
|
r'flurryagent',
|
|
|
|
r'paypal.*mpl',
|
|
|
|
r'google.*analytics',
|
|
|
|
r'admob.*sdk.*android',
|
|
|
|
r'google.*ad.*view',
|
|
|
|
r'google.*admob',
|
|
|
|
r'google.*play.*services',
|
|
|
|
r'crittercism',
|
|
|
|
r'heyzap',
|
|
|
|
r'jpct.*ae',
|
|
|
|
r'youtube.*android.*player.*api',
|
|
|
|
r'bugsense',
|
|
|
|
r'crashlytics',
|
|
|
|
r'ouya.*sdk',
|
|
|
|
r'libspen23',
|
2017-02-23 00:40:55 +01:00
|
|
|
r'firebase',
|
2018-07-27 18:01:01 +02:00
|
|
|
r'''["']com.facebook.android['":]''',
|
2019-02-07 10:26:03 +01:00
|
|
|
r'cloudrail',
|
2015-09-17 02:13:54 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2017-12-14 21:58:06 +01:00
|
|
|
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)
|
|
|
|
|
2015-09-17 02:13:54 +02:00
|
|
|
def suspects_found(s):
|
2016-01-04 17:02:28 +01:00
|
|
|
for n, r in usual_suspects.items():
|
2017-12-14 21:58:06 +01:00
|
|
|
if r.match(s) and not is_whitelisted(s):
|
2015-09-17 02:13:54 +02:00
|
|
|
yield n
|
2015-08-29 04:20:39 +02:00
|
|
|
|
2015-10-07 18:14:11 +02:00
|
|
|
gradle_mavenrepo = re.compile(r'maven *{ *(url)? *[\'"]?([^ \'"]*)[\'"]?')
|
|
|
|
|
2015-10-22 12:22:46 +02:00
|
|
|
allowed_repos = [re.compile(r'^https?://' + re.escape(repo) + r'/*') for repo in [
|
|
|
|
'repo1.maven.org/maven2', # mavenCentral()
|
|
|
|
'jcenter.bintray.com', # jcenter()
|
|
|
|
'jitpack.io',
|
2018-06-11 12:40:55 +02:00
|
|
|
'www.jitpack.io',
|
2015-10-31 09:59:38 +01:00
|
|
|
'repo.maven.apache.org/maven2',
|
2017-02-13 20:24:35 +01:00
|
|
|
'oss.jfrog.org/artifactory/oss-snapshot-local',
|
2015-10-22 12:22:46 +02:00
|
|
|
'oss.sonatype.org/content/repositories/snapshots',
|
|
|
|
'oss.sonatype.org/content/repositories/releases',
|
2015-10-22 12:23:57 +02:00
|
|
|
'oss.sonatype.org/content/groups/public',
|
2016-01-24 19:13:45 +01:00
|
|
|
'clojars.org/repo', # Clojure free software libs
|
2016-02-17 14:00:05 +01:00
|
|
|
's3.amazonaws.com/repo.commonsware.com', # CommonsWare
|
|
|
|
'plugins.gradle.org/m2', # Gradle plugin repo
|
2017-05-25 20:55:50 +02:00
|
|
|
'maven.google.com', # Google Maven Repo, https://developer.android.com/studio/build/dependencies.html#google-maven
|
2015-10-07 18:14:11 +02:00
|
|
|
]
|
|
|
|
]
|
|
|
|
|
2015-11-28 17:55:27 +01:00
|
|
|
scanignore = common.getpaths_map(build_dir, build.scanignore)
|
|
|
|
scandelete = common.getpaths_map(build_dir, build.scandelete)
|
2015-08-29 04:20:39 +02:00
|
|
|
|
|
|
|
scanignore_worked = set()
|
|
|
|
scandelete_worked = set()
|
|
|
|
|
2017-09-11 16:46:54 +02:00
|
|
|
def toignore(path_in_build_dir):
|
2016-01-04 17:02:28 +01:00
|
|
|
for k, paths in scanignore.items():
|
2015-10-04 02:00:22 +02:00
|
|
|
for p in paths:
|
2017-09-11 16:46:54 +02:00
|
|
|
if path_in_build_dir.startswith(p):
|
2015-10-04 02:00:22 +02:00
|
|
|
scanignore_worked.add(k)
|
|
|
|
return True
|
2015-08-29 04:20:39 +02:00
|
|
|
return False
|
|
|
|
|
2017-09-11 16:46:54 +02:00
|
|
|
def todelete(path_in_build_dir):
|
2016-01-04 17:02:28 +01:00
|
|
|
for k, paths in scandelete.items():
|
2015-10-04 02:00:22 +02:00
|
|
|
for p in paths:
|
2017-09-11 16:46:54 +02:00
|
|
|
if path_in_build_dir.startswith(p):
|
2015-10-04 02:00:22 +02:00
|
|
|
scandelete_worked.add(k)
|
|
|
|
return True
|
2015-08-29 04:20:39 +02:00
|
|
|
return False
|
|
|
|
|
2017-09-11 16:46:54 +02:00
|
|
|
def ignoreproblem(what, path_in_build_dir):
|
|
|
|
logging.info('Ignoring %s at %s' % (what, path_in_build_dir))
|
2015-08-29 04:20:39 +02:00
|
|
|
return 0
|
|
|
|
|
2017-09-11 16:46:54 +02:00
|
|
|
def removeproblem(what, path_in_build_dir, filepath):
|
|
|
|
logging.info('Removing %s at %s' % (what, path_in_build_dir))
|
|
|
|
os.remove(filepath)
|
2015-08-29 04:20:39 +02:00
|
|
|
return 0
|
|
|
|
|
2017-09-11 16:46:54 +02:00
|
|
|
def warnproblem(what, path_in_build_dir):
|
|
|
|
if toignore(path_in_build_dir):
|
2015-11-12 20:02:40 +01:00
|
|
|
return
|
2017-09-11 16:46:54 +02:00
|
|
|
logging.warn('Found %s at %s' % (what, path_in_build_dir))
|
|
|
|
|
|
|
|
def handleproblem(what, path_in_build_dir, filepath):
|
|
|
|
if toignore(path_in_build_dir):
|
|
|
|
return ignoreproblem(what, path_in_build_dir)
|
|
|
|
if todelete(path_in_build_dir):
|
|
|
|
return removeproblem(what, path_in_build_dir, filepath)
|
|
|
|
logging.error('Found %s at %s' % (what, path_in_build_dir))
|
2015-08-29 04:20:39 +02:00
|
|
|
return 1
|
|
|
|
|
2015-09-14 07:11:53 +02:00
|
|
|
def is_executable(path):
|
|
|
|
return os.path.exists(path) and os.access(path, os.X_OK)
|
|
|
|
|
|
|
|
textchars = bytearray({7, 8, 9, 10, 12, 13, 27} | set(range(0x20, 0x100)) - {0x7f})
|
|
|
|
|
|
|
|
def is_binary(path):
|
|
|
|
d = None
|
|
|
|
with open(path, 'rb') as f:
|
|
|
|
d = f.read(1024)
|
|
|
|
return bool(d.translate(None, textchars))
|
2015-08-29 04:20:39 +02:00
|
|
|
|
2015-11-10 21:59:54 +01:00
|
|
|
# False positives patterns for files that are binary and executable.
|
|
|
|
safe_paths = [re.compile(r) for r in [
|
|
|
|
r".*/drawable[^/]*/.*\.png$", # png drawables
|
|
|
|
r".*/mipmap[^/]*/.*\.png$", # png mipmaps
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
def safe_path(path):
|
|
|
|
for sp in safe_paths:
|
|
|
|
if sp.match(path):
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2015-11-28 17:55:27 +01:00
|
|
|
gradle_compile_commands = get_gradle_compile_commands(build)
|
2015-09-18 17:22:34 +02:00
|
|
|
|
|
|
|
def is_used_by_gradle(line):
|
|
|
|
return any(command.match(line) for command in gradle_compile_commands)
|
|
|
|
|
2015-08-29 04:20:39 +02:00
|
|
|
# Iterate through all files in the source code
|
2017-09-14 08:44:43 +02:00
|
|
|
for root, dirs, files in os.walk(build_dir, topdown=True):
|
2015-08-29 04:20:39 +02:00
|
|
|
|
|
|
|
# It's topdown, so checking the basename is enough
|
|
|
|
for ignoredir in ('.hg', '.git', '.svn', '.bzr'):
|
2017-09-14 08:44:43 +02:00
|
|
|
if ignoredir in dirs:
|
|
|
|
dirs.remove(ignoredir)
|
2015-08-29 04:20:39 +02:00
|
|
|
|
2017-09-14 08:44:43 +02:00
|
|
|
for curfile in files:
|
2015-08-29 04:20:39 +02:00
|
|
|
|
2015-11-10 21:49:46 +01:00
|
|
|
if curfile in ['.DS_Store']:
|
|
|
|
continue
|
|
|
|
|
2015-08-29 04:20:39 +02:00
|
|
|
# Path (relative) to the file
|
2017-09-14 08:44:43 +02:00
|
|
|
filepath = os.path.join(root, curfile)
|
2015-08-29 04:20:39 +02:00
|
|
|
|
2017-09-11 16:46:54 +02:00
|
|
|
if os.path.islink(filepath):
|
2015-09-22 22:03:42 +02:00
|
|
|
continue
|
|
|
|
|
2017-09-11 16:46:54 +02:00
|
|
|
path_in_build_dir = os.path.relpath(filepath, build_dir)
|
2017-10-24 16:48:42 +02:00
|
|
|
_ignored, ext = common.get_extension(path_in_build_dir)
|
2015-08-29 04:20:39 +02:00
|
|
|
|
2015-09-14 07:11:53 +02:00
|
|
|
if ext == 'so':
|
2017-09-11 16:46:54 +02:00
|
|
|
count += handleproblem('shared library', path_in_build_dir, filepath)
|
2015-09-14 07:11:53 +02:00
|
|
|
elif ext == 'a':
|
2017-09-11 16:46:54 +02:00
|
|
|
count += handleproblem('static library', path_in_build_dir, filepath)
|
2015-09-14 07:11:53 +02:00
|
|
|
elif ext == 'class':
|
2017-09-11 16:46:54 +02:00
|
|
|
count += handleproblem('Java compiled class', path_in_build_dir, filepath)
|
2015-09-14 07:11:53 +02:00
|
|
|
elif ext == 'apk':
|
2017-09-11 16:46:54 +02:00
|
|
|
removeproblem('APK file', path_in_build_dir, filepath)
|
2015-08-29 04:20:39 +02:00
|
|
|
|
2015-09-14 07:11:53 +02:00
|
|
|
elif ext == 'jar':
|
2015-09-17 02:13:54 +02:00
|
|
|
for name in suspects_found(curfile):
|
2017-12-14 21:58:06 +01:00
|
|
|
count += handleproblem('usual suspect \'%s\'' % name, path_in_build_dir, filepath)
|
2017-09-04 01:00:12 +02:00
|
|
|
if curfile == 'gradle-wrapper.jar':
|
|
|
|
removeproblem('gradle-wrapper.jar', path_in_build_dir, filepath)
|
|
|
|
else:
|
2017-10-25 22:39:31 +02:00
|
|
|
warnproblem('JAR file', path_in_build_dir)
|
2015-08-29 04:20:39 +02:00
|
|
|
|
2017-09-04 00:57:38 +02:00
|
|
|
elif ext == 'aar':
|
2017-10-25 22:39:31 +02:00
|
|
|
warnproblem('AAR file', path_in_build_dir)
|
2017-09-04 00:57:38 +02:00
|
|
|
|
2015-09-14 07:11:53 +02:00
|
|
|
elif ext == 'java':
|
2017-09-11 16:46:54 +02:00
|
|
|
if not os.path.isfile(filepath):
|
2015-08-29 04:20:39 +02:00
|
|
|
continue
|
2018-10-19 15:01:34 +02:00
|
|
|
with open(filepath, 'r', errors='replace') as f:
|
2016-01-04 17:59:47 +01:00
|
|
|
for line in f:
|
|
|
|
if 'DexClassLoader' in line:
|
2017-09-11 16:46:54 +02:00
|
|
|
count += handleproblem('DexClassLoader', path_in_build_dir, filepath)
|
2016-01-04 17:59:47 +01:00
|
|
|
break
|
2015-08-29 04:20:39 +02:00
|
|
|
|
2015-09-14 07:11:53 +02:00
|
|
|
elif ext == 'gradle':
|
2017-09-11 16:46:54 +02:00
|
|
|
if not os.path.isfile(filepath):
|
2015-08-29 04:20:39 +02:00
|
|
|
continue
|
2018-10-19 15:01:34 +02:00
|
|
|
with open(filepath, 'r', errors='replace') as f:
|
2015-10-07 18:14:11 +02:00
|
|
|
lines = f.readlines()
|
|
|
|
for i, line in enumerate(lines):
|
2015-09-18 17:22:34 +02:00
|
|
|
if is_used_by_gradle(line):
|
|
|
|
for name in suspects_found(line):
|
2017-12-14 21:58:06 +01:00
|
|
|
count += handleproblem('usual suspect \'%s\' at line %d' % (name, i + 1), path_in_build_dir, filepath)
|
2015-10-08 12:16:45 +02:00
|
|
|
noncomment_lines = [l for l in lines if not common.gradle_comment.match(l)]
|
|
|
|
joined = re.sub(r'[\n\r\s]+', ' ', ' '.join(noncomment_lines))
|
2015-10-07 18:14:11 +02:00
|
|
|
for m in gradle_mavenrepo.finditer(joined):
|
|
|
|
url = m.group(2)
|
|
|
|
if not any(r.match(url) for r in allowed_repos):
|
2017-09-11 16:46:54 +02:00
|
|
|
count += handleproblem('unknown maven repo \'%s\'' % url, path_in_build_dir, filepath)
|
2015-08-29 04:20:39 +02:00
|
|
|
|
2015-09-17 02:20:22 +02:00
|
|
|
elif ext in ['', 'bin', 'out', 'exe']:
|
2017-09-11 16:46:54 +02:00
|
|
|
if is_binary(filepath):
|
|
|
|
count += handleproblem('binary', path_in_build_dir, filepath)
|
2015-09-17 02:20:22 +02:00
|
|
|
|
2017-09-11 16:46:54 +02:00
|
|
|
elif is_executable(filepath):
|
|
|
|
if is_binary(filepath) and not safe_path(path_in_build_dir):
|
|
|
|
warnproblem('possible binary', path_in_build_dir)
|
2015-09-14 07:11:53 +02:00
|
|
|
|
2015-08-29 04:20:39 +02:00
|
|
|
for p in scanignore:
|
|
|
|
if p not in scanignore_worked:
|
|
|
|
logging.error('Unused scanignore path: %s' % p)
|
|
|
|
count += 1
|
|
|
|
|
|
|
|
for p in scandelete:
|
|
|
|
if p not in scandelete_worked:
|
|
|
|
logging.error('Unused scandelete path: %s' % p)
|
|
|
|
count += 1
|
|
|
|
|
|
|
|
return count
|
|
|
|
|
|
|
|
|
2012-02-26 15:18:58 +01:00
|
|
|
def main():
|
2012-01-03 16:37:29 +01:00
|
|
|
|
2013-11-01 12:10:57 +01:00
|
|
|
global config, options
|
2012-01-03 16:37:29 +01:00
|
|
|
|
2012-02-26 15:18:58 +01:00
|
|
|
# Parse command line...
|
2015-09-04 11:37:05 +02:00
|
|
|
parser = ArgumentParser(usage="%(prog)s [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]")
|
2015-09-12 08:42:50 +02:00
|
|
|
common.setup_global_opts(parser)
|
2017-09-15 11:41:39 +02:00
|
|
|
parser.add_argument("appid", nargs='*', help=_("applicationId with optional versionCode in the form APPID[:VERCODE]"))
|
2016-09-12 12:55:48 +02:00
|
|
|
metadata.add_metadata_arguments(parser)
|
2015-09-04 11:37:05 +02:00
|
|
|
options = parser.parse_args()
|
2016-09-12 12:55:48 +02:00
|
|
|
metadata.warnings_action = options.W
|
2012-01-03 16:37:29 +01:00
|
|
|
|
2013-11-01 12:10:57 +01:00
|
|
|
config = common.read_config(options)
|
|
|
|
|
2014-05-20 23:44:47 +02:00
|
|
|
# Read all app and srclib metadata
|
2013-12-19 23:06:57 +01:00
|
|
|
allapps = metadata.read_metadata()
|
2015-09-04 11:37:05 +02:00
|
|
|
apps = common.read_app_args(options.appid, allapps, True)
|
2012-03-11 22:59:25 +01:00
|
|
|
|
2015-01-10 13:49:54 +01:00
|
|
|
probcount = 0
|
2012-01-27 23:10:08 +01:00
|
|
|
|
2013-10-29 13:23:42 +01:00
|
|
|
build_dir = 'build'
|
|
|
|
if not os.path.isdir(build_dir):
|
2014-01-27 16:56:55 +01:00
|
|
|
logging.info("Creating build directory")
|
2013-10-29 13:23:42 +01:00
|
|
|
os.makedirs(build_dir)
|
|
|
|
srclib_dir = os.path.join(build_dir, 'srclib')
|
|
|
|
extlib_dir = os.path.join(build_dir, 'extlib')
|
2012-01-03 16:37:29 +01:00
|
|
|
|
2016-01-04 17:02:28 +01:00
|
|
|
for appid, app in apps.items():
|
2012-01-03 16:37:29 +01:00
|
|
|
|
2015-11-28 13:09:47 +01:00
|
|
|
if app.Disabled:
|
2017-09-15 23:20:29 +02:00
|
|
|
logging.info(_("Skipping {appid}: disabled").format(appid=appid))
|
2013-12-19 23:06:57 +01:00
|
|
|
continue
|
2012-01-03 16:37:29 +01:00
|
|
|
|
2013-12-19 23:06:57 +01:00
|
|
|
try:
|
2015-11-28 13:09:47 +01:00
|
|
|
if app.RepoType == 'srclib':
|
|
|
|
build_dir = os.path.join('build', 'srclib', app.Repo)
|
2015-09-14 07:05:41 +02:00
|
|
|
else:
|
|
|
|
build_dir = os.path.join('build', appid)
|
2012-01-03 16:37:29 +01:00
|
|
|
|
2018-01-23 21:55:37 +01:00
|
|
|
if app.builds:
|
|
|
|
logging.info(_("Processing {appid}").format(appid=appid))
|
|
|
|
else:
|
|
|
|
logging.info(_("{appid}: no builds specified, running on current source state")
|
|
|
|
.format(appid=appid))
|
|
|
|
count = scan_source(build_dir)
|
|
|
|
if count > 0:
|
|
|
|
logging.warn(_('Scanner found {count} problems in {appid}:')
|
|
|
|
.format(count=count, appid=appid))
|
|
|
|
probcount += count
|
|
|
|
continue
|
|
|
|
|
2013-12-19 23:06:57 +01:00
|
|
|
# Set up vcs interface and make sure we have the latest code...
|
2015-11-28 13:09:47 +01:00
|
|
|
vcs = common.getvcs(app.RepoType, app.Repo, build_dir)
|
2012-01-03 16:37:29 +01:00
|
|
|
|
2015-11-28 17:55:27 +01:00
|
|
|
for build in app.builds:
|
2012-01-03 22:39:30 +01:00
|
|
|
|
2015-11-28 17:55:27 +01:00
|
|
|
if build.disable:
|
2014-01-27 16:56:55 +01:00
|
|
|
logging.info("...skipping version %s - %s" % (
|
2016-11-23 17:52:04 +01:00
|
|
|
build.versionName, build.get('disable', build.commit[1:])))
|
2018-01-23 21:55:37 +01:00
|
|
|
continue
|
|
|
|
|
|
|
|
logging.info("...scanning version " + build.versionName)
|
|
|
|
# Prepare the source code...
|
|
|
|
common.prepare_source(vcs, app, build,
|
|
|
|
build_dir, srclib_dir,
|
|
|
|
extlib_dir, False)
|
|
|
|
|
|
|
|
count = scan_source(build_dir, build)
|
|
|
|
if count > 0:
|
|
|
|
logging.warn(_('Scanner found {count} problems in {appid}:{versionCode}:')
|
|
|
|
.format(count=count, appid=appid, versionCode=build.versionCode))
|
|
|
|
probcount += count
|
2012-01-03 16:37:29 +01:00
|
|
|
|
2013-12-19 23:06:57 +01:00
|
|
|
except BuildException as be:
|
2015-01-10 13:49:54 +01:00
|
|
|
logging.warn("Could not scan app %s due to BuildException: %s" % (
|
|
|
|
appid, be))
|
|
|
|
probcount += 1
|
2013-12-19 23:06:57 +01:00
|
|
|
except VCSException as vcse:
|
2015-01-10 13:49:54 +01:00
|
|
|
logging.warn("VCS error while scanning app %s: %s" % (appid, vcse))
|
|
|
|
probcount += 1
|
2013-12-19 23:06:57 +01:00
|
|
|
except Exception:
|
2015-01-10 13:49:54 +01:00
|
|
|
logging.warn("Could not scan app %s due to unknown error: %s" % (
|
|
|
|
appid, traceback.format_exc()))
|
|
|
|
probcount += 1
|
2012-02-26 15:18:58 +01:00
|
|
|
|
2017-09-13 18:03:57 +02:00
|
|
|
logging.info(_("Finished"))
|
|
|
|
print(_("%d problems found") % probcount)
|
2012-02-26 15:18:58 +01:00
|
|
|
|
2016-11-15 21:55:06 +01:00
|
|
|
|
2012-02-26 15:18:58 +01:00
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|