1. 19 Apr, 2021 1 commit
    • Hans-Christoph Steiner's avatar
      mark apps/builds with ga_trackingId set with Tracking Anti-Feature · 32826c83
      Hans-Christoph Steiner authored
      Google Firebase Analytics is configured using an XML file, and it seems to
      require that an value with the key `ga_trackingId` is included:
      That means that any app that is setting `ga_trackingId` is most likely
      configuring Google Firebase Analytics.  If not, then that file/key should
      be removed entirely. It can easily be moved to a flavor also.
      This was detected by running this script across the whole archive:
      import os
      import sys
      import zipfile
      from androguard.core.bytecodes.axml import AXMLPrinter
          import defusedxml.ElementTree as XMLElementTree
      except ImportError:
          import xml.etree.ElementTree as XMLElementTree  # nosec this is a fallback only
      if len(sys.argv) > 1:
          search_dirs = sys.argv[1:]
          search_dirs = ['.']
      print('search_dirs', search_dirs)
      for d in search_dirs:
          for root, dirs, files in os.walk(d):
              for f in files:
                  path = os.path.join(root, f)
                      with zipfile.ZipFile(path) as apk:
                          for info in apk.infolist():
                              if info.file_size < 10:
                              name = info.filename
                              if name.startswith('res/') and name.endswith('.xml'):
                                  with apk.open(name) as binary_xml:
                                      axml = AXMLPrinter(binary_xml.read())
                                      resources = XMLElementTree.fromstring(axml.get_xml())
                                      for item in resources:
                                          if 'ga_trackingId' == (item.get('name')):
                                              print(path, name, item.get('name'))
                  except (zipfile.BadZipFile, AssertionError, TypeError, ValueError) as e:
                      #print(path, e)
      Then applied using this script:
      import os
      import yaml
      from fdroidserver import metadata
      apps = dict()
      with open('ga_trackingId-finds.txt') as fp:
          for line in fp:
              apk, xml, _ = line.split()
              apk = apk.split('/')[1]
              appid = apk[:apk.rindex('_')]
              versionCode = int(apk[:-4][apk.rindex('_') + 1:])
              if appid not in apps:
                  apps[appid] = []
      for appid, versionCodes in apps.items():
          metadatapath = 'metadata/%s.yml' % appid
          with open(metadatapath) as fp:
              app = yaml.load(fp)
          print(appid, app.get('Repo', '///').split('/')[3], sep='\t')
          for build in app['Builds']:
              if build.get('gradle') is True or build.get('gradle') == 'true':
                  build['gradle'] = ['yes']
              if build['versionCode'] in versionCodes:
                  build['antifeatures'] = ['Tracking']
          metadata.write_metadata(metadatapath, metadata.App(app))
          os.system("sed -i 's,^      - true,      - yes,' " + metadatapath)
  2. 09 Dec, 2020 1 commit
    • Hans-Christoph Steiner's avatar
      convert all MediaWiki links to HTML links · cf4e8a40
      Hans-Christoph Steiner authored
      import yaml, glob, re, os
      from fdroidserver import metadata
      pat = re.compile(r'\[(https?://[^ \]]+)\s+([^\]]+)\]')
      for f in glob.glob('metadata/*.yml'):
          with open(f) as fp:
              data = yaml.load(fp)
          description = data.get('Description', '')
          for m in pat.finditer(data.get('Description', '')):
              link = m.group(1)
              text = m.group(2)
              print(f, link, text, flush=True)
              description = description.replace(m.group(), '<a href="%s">%s</a>' % (link, text))
          data['Description'] = description
          app = metadata.App(data)
          metadata.write_metadata(f, app)
      sed -i 's,^      - true,      - yes,' metadata/*.yml
      sed -i 's,^      - false,      - no,' metadata/*.yml
      closes fdroid-website#510
  3. 30 Jul, 2019 1 commit
  4. 27 Jul, 2019 2 commits