chiark / gitweb /
upload release apk to virustotal
authorthez3ro <io@thezero.org>
Fri, 3 Mar 2017 12:44:55 +0000 (13:44 +0100)
committerthez3ro <io@thezero.org>
Fri, 3 Mar 2017 12:44:55 +0000 (13:44 +0100)
examples/config.py
fdroidserver/server.py

index ca4e79b66aaf8569384a962a43a40020c8873812..eac1b995a7b057265983f63b2b174f1fd99acb89 100644 (file)
@@ -225,6 +225,12 @@ The repository of older versions of applications from the main demo repository.
 # uploadto_androidobservatory = False
 
 
+# If you want to upload the release apk file to virustotal.com
+# You have to enter your profile apikey to enable the upload.
+#
+# virustotal_apikey = "virustotal_apikey"
+
+
 # The build logs can be posted to a mediawiki instance, like on f-droid.org.
 # wiki_protocol = "http"
 # wiki_server = "server"
index e795004888d91505f8a99223a1809e3bfe89dfd5..2213d788ae76e809471ce36e4b1ee423550e81db 100644 (file)
@@ -261,6 +261,24 @@ def upload_to_android_observatory(repo_section):
             logging.info(message)
 
 
+def upload_to_virustotal(repo_section, vt_apikey):
+    import requests
+
+    if repo_section == 'repo':
+        for f in glob.glob(os.path.join(repo_section, '*.apk')):
+            fpath = f
+            fname = os.path.basename(f)
+            logging.info('Uploading ' + fname + ' to virustotal.com')
+
+            # upload the file with a post request
+            params = {'apikey': vt_apikey}
+            files = {'file': (fname, open(fpath, 'rb'))}
+            r = requests.post('https://www.virustotal.com/vtapi/v2/file/scan', files=files, params=params)
+            response = r.json()
+
+            logging.info(response['verbose_msg'] + " " + response['permalink'])
+
+
 def main():
     global config, options
 
@@ -341,9 +359,10 @@ def main():
             and not config.get('serverwebroot') \
             and not config.get('servergitmirrors') \
             and not config.get('uploadto_androidobservatory') \
+            and not config.get('virustotal_apikey') \
             and local_copy_dir is None:
-        logging.warn('No serverwebroot, servergitmirrors, local_copy_dir, awsbucket, or uploadto_androidobservatory set! '
-                     + 'Edit your config.py to set at least one.')
+        logging.warn('No option set! Edit your config.py to set at least one among:\n'
+                     + 'serverwebroot, servergitmirrors, local_copy_dir, awsbucket, virustotal_apikey or uploadto_androidobservatory')
         sys.exit(1)
 
     repo_sections = ['repo']
@@ -393,6 +412,8 @@ def main():
                 update_awsbucket(repo_section)
             if config.get('uploadto_androidobservatory'):
                 upload_to_android_observatory(repo_section)
+            if config.get('virustotal_apikey'):
+                upload_to_virustotal(repo_section, config.get('virustotal_apikey'))
     sys.exit(0)