1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-01 08:40:11 +02:00

Merge branch 'scanner-allow-non-zero-exit' into 'master'

feat(scanner): Allow non-zero-exit code if problems were found

See merge request fdroid/fdroidserver!1342
This commit is contained in:
Hans-Christoph Steiner 2023-05-23 08:35:18 +00:00
commit 6e62ea3614

View File

@ -32,6 +32,7 @@ from tempfile import TemporaryDirectory
from pathlib import Path from pathlib import Path
from datetime import datetime, timedelta from datetime import datetime, timedelta
from dataclasses import dataclass, field, fields from dataclasses import dataclass, field, fields
from enum import IntEnum
from . import _ from . import _
from . import common from . import common
@ -56,6 +57,10 @@ MAVEN_URL_REGEX = re.compile(r"""\smaven\s*(?:{.*?(?:setUrl|url)|\((?:url)?)\s*=
SCANNER_CACHE_VERSION = 1 SCANNER_CACHE_VERSION = 1
class ExitCode(IntEnum):
NONFREE_CODE = 1
def get_gradle_compile_commands(build): def get_gradle_compile_commands(build):
compileCommands = ['compile', compileCommands = ['compile',
'provided', 'provided',
@ -781,6 +786,8 @@ def main():
help=_("Output JSON to stdout.")) help=_("Output JSON to stdout."))
parser.add_argument("--refresh", "-r", action="store_true", default=False, parser.add_argument("--refresh", "-r", action="store_true", default=False,
help=_("fetch the latest version of signatures from the web")) help=_("fetch the latest version of signatures from the web"))
parser.add_argument("--exit-code", "-e", action="store_true", default=False,
help=_("Exit with a non-zero code if problems were found"))
metadata.add_metadata_arguments(parser) metadata.add_metadata_arguments(parser)
options = parser.parse_args() options = parser.parse_args()
metadata.warnings_action = options.W metadata.warnings_action = options.W
@ -815,6 +822,8 @@ def main():
appids.append(apk) appids.append(apk)
if not appids: if not appids:
if options.exit_code and probcount > 0:
sys.exit(ExitCode.NONFREE_CODE)
return return
# Read all app and srclib metadata # Read all app and srclib metadata