chiark / gitweb /
Merge branch 'error_on_jars' into 'master'
authorHans-Christoph Steiner <hans@guardianproject.info>
Thu, 12 Oct 2017 11:46:59 +0000 (11:46 +0000)
committerHans-Christoph Steiner <hans@guardianproject.info>
Thu, 12 Oct 2017 11:46:59 +0000 (11:46 +0000)
RFC: Error on jars

See merge request fdroid/fdroidserver!325

1  2 
fdroidserver/scanner.py

diff --combined fdroidserver/scanner.py
index 446091dc38b857e371d42d08be3ba7b2f8d66f53,de58b9d41f9c9be5f908a5e5f968aae70acf6615..0b622bcdbc208fd0b87585112fc11a6e58804469
@@@ -22,7 -22,6 +22,7 @@@ import tracebac
  from argparse import ArgumentParser
  import logging
  
 +from . import _
  from . import common
  from . import metadata
  from .exception import BuildException, VCSException
@@@ -166,20 -165,20 +166,20 @@@ def scan_source(build_dir, build)
          return any(command.match(line) for command in gradle_compile_commands)
  
      # Iterate through all files in the source code
 -    for dirpath, dirnames, filenames in os.walk(build_dir, topdown=True):
 +    for root, dirs, files in os.walk(build_dir, topdown=True):
  
          # It's topdown, so checking the basename is enough
          for ignoredir in ('.hg', '.git', '.svn', '.bzr'):
 -            if ignoredir in dirnames:
 -                dirnames.remove(ignoredir)
 +            if ignoredir in dirs:
 +                dirs.remove(ignoredir)
  
 -        for curfile in filenames:
 +        for curfile in files:
  
              if curfile in ['.DS_Store']:
                  continue
  
              # Path (relative) to the file
 -            filepath = os.path.join(dirpath, curfile)
 +            filepath = os.path.join(root, curfile)
  
              if os.path.islink(filepath):
                  continue
              elif ext == 'jar':
                  for name in suspects_found(curfile):
                      count += handleproblem('usual supect \'%s\'' % name, path_in_build_dir, filepath)
-                 warnproblem('JAR file', path_in_build_dir)
+                 if curfile == 'gradle-wrapper.jar':
+                     removeproblem('gradle-wrapper.jar', path_in_build_dir, filepath)
+                 else:
+                     count += handleproblem('JAR file', path_in_build_dir, filepath)
  
              elif ext == 'aar':
-                 warnproblem('AAR file', path_in_build_dir)
+                 count += handleproblem('AAR file', path_in_build_dir, filepath)
  
              elif ext == 'java':
                  if not os.path.isfile(filepath):
@@@ -257,7 -259,7 +260,7 @@@ def main()
      # Parse command line...
      parser = ArgumentParser(usage="%(prog)s [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]")
      common.setup_global_opts(parser)
 -    parser.add_argument("appid", nargs='*', help="app-id with optional versionCode in the form APPID[:VERCODE]")
 +    parser.add_argument("appid", nargs='*', help=_("applicationId with optional versionCode in the form APPID[:VERCODE]"))
      metadata.add_metadata_arguments(parser)
      options = parser.parse_args()
      metadata.warnings_action = options.W
      for appid, app in apps.items():
  
          if app.Disabled:
 -            logging.info("Skipping %s: disabled" % appid)
 +            logging.info(_("Skipping {appid}: disabled").format(appid=appid))
              continue
          if not app.builds:
 -            logging.info("Skipping %s: no builds specified" % appid)
 +            logging.info(_("Skipping {appid}: no builds specified").format(appid=appid))
              continue
  
 -        logging.info("Processing " + appid)
 +        logging.info(_("Processing {appid}").format(appid=appid))
  
          try:
  
                  appid, traceback.format_exc()))
              probcount += 1
  
 -    logging.info("Finished:")
 -    print("%d problems found" % probcount)
 +    logging.info(_("Finished"))
 +    print(_("%d problems found") % probcount)
  
  
  if __name__ == "__main__":