From 3a9f1e845c8b835e210bcc4d8affb326e22b7583 Mon Sep 17 00:00:00 2001 From: Marcus Hoffmann Date: Sat, 13 Jun 2020 02:59:39 +0200 Subject: [PATCH] scanner: fix wrong path being passed to function Also make rename the parameter in safe_path to make it clear that this is just a relative path. Closes fdroid/fdroidserver#791. --- fdroidserver/scanner.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fdroidserver/scanner.py b/fdroidserver/scanner.py index ad33de13..c28d2a83 100644 --- a/fdroidserver/scanner.py +++ b/fdroidserver/scanner.py @@ -200,12 +200,14 @@ def scan_source(build_dir, build=metadata.Build()): ] ] - def safe_path(path): - for sp in safe_paths: - if sp.match(path): - return True + def is_image_file(path): if imghdr.what(path) is not None: return True + + def safe_path(path_in_build_dir): + for sp in safe_paths: + if sp.match(path_in_build_dir): + return True return False gradle_compile_commands = get_gradle_compile_commands(build) @@ -289,7 +291,7 @@ def scan_source(build_dir, build=metadata.Build()): count += handleproblem('binary', path_in_build_dir, filepath) elif is_executable(filepath): - if is_binary(filepath) and not safe_path(path_in_build_dir): + if is_binary(filepath) and not (safe_path(path_in_build_dir) or is_image_file(filepath)): warnproblem(_('executable binary, possibly code'), path_in_build_dir) for p in scanignore: