1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-07-04 16:30:12 +02:00

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

This commit is contained in:
Georg krause 2023-04-17 14:13:22 +02:00 committed by Georg Krause
parent 44513c23fd
commit 9af2efda2e

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