From 32826c833408d64d50ecd0870da1fed0e16fe8b8 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 15 Dec 2020 21:32:20 +0100 Subject: [PATCH] mark apps/builds with ga_trackingId set with Tracking Anti-Feature Google Firebase Analytics is configured using an XML file, and it seems to require that an value with the key `ga_trackingId` is included: https://developers.google.com/android/reference/com/google/android/gms/analytics/Tracker 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: https://gitlab.com/trackingthetrackers/scripts/-/blob/master/find-ga_trackingId.py ```python import os import sys import zipfile from androguard.core.bytecodes.axml import AXMLPrinter try: 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:] else: 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) try: with zipfile.ZipFile(path) as apk: for info in apk.infolist(): if info.file_size < 10: continue 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) pass ``` Then applied using this script: ```python 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] = [] apps[appid].append(versionCode) 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) ``` !7898 --- metadata/be.uhasselt.privacypolice.yml | 16 +++++ .../com.github.premnirmal.tickerwidget.yml | 16 +++++ metadata/com.oasisfeng.island.fdroid.yml | 2 + metadata/com.outdoordevs.ellaism.wallet.yml | 4 ++ metadata/com.rehanced.lunary.yml | 30 +++++++++ metadata/com.rubenroy.minimaltodo.yml | 2 + metadata/com.vuze.android.remote.yml | 8 +++ metadata/jwtc.android.chess.yml | 2 + metadata/net.olejon.mdapp.yml | 20 ++++++ metadata/org.nonononoki.hendroid.yml | 30 +++++++++ metadata/org.solovyev.android.calculator.yml | 4 ++ metadata/org.tasks.yml | 64 +++++++++++++++++++ ...inelabs.meditationassistant.opensource.yml | 60 +++++++++++++++++ 13 files changed, 258 insertions(+) diff --git a/metadata/be.uhasselt.privacypolice.yml b/metadata/be.uhasselt.privacypolice.yml index bebc282fb3..371db8cf75 100644 --- a/metadata/be.uhasselt.privacypolice.yml +++ b/metadata/be.uhasselt.privacypolice.yml @@ -28,6 +28,8 @@ Builds: gradle: - yes prebuild: sed -i -e 's@lista/string@lista