[tor-commits] [ooni-probe/master] Loosen up the oonib regexp to support the timestamp report format

art at torproject.org art at torproject.org
Wed Nov 21 15:36:20 UTC 2012


commit 3af0b5a12a5af750155cd06750d5a911f5c1900e
Author: Arturo Filastò <art at fuffa.org>
Date:   Wed Nov 21 16:00:02 2012 +0100

    Loosen up the oonib regexp to support the timestamp report format
---
 oonib/README.md     |    1 +
 oonib/models.py     |    9 +++++++--
 oonib/report/api.py |    9 +++++++--
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/oonib/README.md b/oonib/README.md
index 8136b06..f70c6db 100644
--- a/oonib/README.md
+++ b/oonib/README.md
@@ -15,3 +15,4 @@ The extra dependencies necessary to run OONIB are:
     openssl x509 -req -days 365 -in server.csr -signkey private.key -out certificate.crt
     rm private.key.org
 
+
diff --git a/oonib/models.py b/oonib/models.py
index 5784673..22567ad 100644
--- a/oonib/models.py
+++ b/oonib/models.py
@@ -2,11 +2,16 @@ __all__ = ['Report', 'TestHelperTMP']
 from storm.twisted.transact import transact
 from storm.locals import *
 
+from ooni.utils import randomStr
 from oonib import transactor
 
 def generateReportID():
-    size = 100
-    report_id = ''.join(random.choice(string.ascii_letters) for x in range(size))
+    """
+    Generates a report ID for usage in the database backed oonib collector.
+
+    XXX note how this function is different from the one in report/api.py
+    """
+    report_id = randomStr(100)
     return report_id
 
 class OModel(object):
diff --git a/oonib/report/api.py b/oonib/report/api.py
index 708de37..5668857 100644
--- a/oonib/report/api.py
+++ b/oonib/report/api.py
@@ -59,7 +59,10 @@ def parseUpdateReportRequest(request):
     # XXX this and the function above can probably be refactored into something
     # more compact. There is quite a bit of code duplication going on here.
 
-    report_id_regexp = re.compile("[a-zA-Z0-9]+$")
+    #db_report_id_regexp = re.compile("[a-zA-Z0-9]+$")
+
+    # this is the regexp for the reports that include the timestamp
+    report_id_regexp = re.compile("[a-zA-Z0-9_-]+$")
 
     # XXX here we are actually parsing a json object that could be quite big.
     # If we want this to scale properly we only want to look at the test_id
@@ -121,12 +124,14 @@ class NewReportHandlerFile(web.RequestHandler):
 
         report_id = generateReportID()
 
-        #report_filename = '_'.join((report_id, 
+        #report_filename = '_'.join((report_id,
         #    report_data['software_name'],
         #    report_data['software_version'],
         #    report_data['test_name'],
         #    report_data['test_version']))
 
+        # The report filename contains the timestamp of the report plus a
+        # random nonce
         report_filename = os.path.join(config.main.report_dir, report_id)
         report_filename += '.yamloo'
 



More information about the tor-commits mailing list