Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #484 from KaiRo-at/master

Bug 742735 - detect new Windows Flash versions correctly
  • Loading branch information...
commit ba283b1cc15dba06c22c6864e1986a58c574c562 2 parents 865dbe2 + fb18b23
Peter Bengtsson authored April 10, 2012
21  socorro/processor/externalProcessor.py
@@ -42,6 +42,7 @@ def __init__(self, config):
42 42
     tmp = toPythonRE.sub(r'%(\1)s',tmp)
43 43
     self.commandLine = tmp % config
44 44
 
  45
+
45 46
 #-----------------------------------------------------------------------------------------------------------------
46 47
   def invokeBreakpadStackdump(self, dumpfilePathname):
47 48
     """ This function invokes breakpad_stackdump as an external process capturing and returning
@@ -209,23 +210,27 @@ def analyzeHeader(self, reportId, dumpAnalysisLineIterator, databaseCursor, date
209 210
     return reportUpdateValues
210 211
 
211 212
 #-----------------------------------------------------------------------------------------------------------------
212  
-  flashRE = re.compile(r'NPSWF32\.dll|libflashplayer(.*)\.(.*)|Flash ?Player-?(.*)')
  213
+  flashRE = re.compile(r'NPSWF32_?(.*)\.dll|libflashplayer(.*)\.(.*)|Flash ?Player-?(.*)')
213 214
   def getVersionIfFlashModule(self,moduleData):
214 215
     """If (we recognize this module as Flash and figure out a version): Returns version; else (None or '')"""
215  
-    #logger.debug(" flash?  %s", moduleData)
  216
+    #logger.debug(" flash? %s", moduleData)
216 217
     try:
217 218
       module,filename,version,debugFilename,debugId = moduleData[:5]
218 219
     except ValueError:
219  
-      logger.debug("bad module line  %s", moduleData)
  220
+      logger.debug("bad module line %s", moduleData)
220 221
       return None
221 222
     m = ProcessorWithExternalBreakpad.flashRE.match(filename)
222 223
     if m:
223 224
       if not version:
224  
-        version = m.groups()[0]
225  
-      if not version:
226  
-        version = m.groups()[2]
227  
-      if not version and 'knownFlashDebugIdentifiers' in self.config:
228  
-        version = self.config.knownFlashDebugIdentifiers.get(debugId) # probably a miss
  225
+        groups = m.groups()
  226
+        if groups[0]:
  227
+          version = groups[0].replace('_', '.')
  228
+        elif groups[1]:
  229
+          version = groups[1]
  230
+        elif groups[3]:
  231
+          version = groups[3]
  232
+        elif 'knownFlashDebugIdentifiers' in self.config:
  233
+          version = self.config.knownFlashDebugIdentifiers.get(debugId) # probably a miss
229 234
     else:
230 235
       version = None
231 236
     return version
70  socorro/unittest/processor/testExternalProcessor.py
... ...
@@ -0,0 +1,70 @@
  1
+import unittest
  2
+from socorro.processor.externalProcessor import ProcessorWithExternalBreakpad
  3
+from socorro.lib.util import DotDict
  4
+
  5
+
  6
+class Abused_ProcessorWithExternalBreakpad(ProcessorWithExternalBreakpad):
  7
+
  8
+    def __init__(self, config):
  9
+        self.config = config
  10
+
  11
+
  12
+class TestProcessorWithExternalBreakpad(unittest.TestCase):
  13
+
  14
+    def test_getVersionIfFlashModule(self):
  15
+        config = DotDict()
  16
+        config.knownFlashDebugIdentifiers = {'yyy': '9.0'}
  17
+        proc = Abused_ProcessorWithExternalBreakpad(config)
  18
+
  19
+        # junk moduleData
  20
+        moduleData = []
  21
+        version = proc.getVersionIfFlashModule(moduleData)
  22
+        self.assertTrue(not version)
  23
+
  24
+        moduleData = ['xxx', 'doesntmatter', '0.0', 'xxx', 'xxx']
  25
+        version = proc.getVersionIfFlashModule(moduleData)
  26
+        self.assertEqual(version, None)
  27
+
  28
+        moduleData[1] = 'gobblygook'
  29
+        version = proc.getVersionIfFlashModule(moduleData)
  30
+        self.assertEqual(version, None)
  31
+
  32
+        moduleData[1] = 'Flash Player-10.4'
  33
+        version = proc.getVersionIfFlashModule(moduleData)
  34
+        self.assertEqual(version, '0.0')
  35
+
  36
+        moduleData[1] = 'Flash Player-10.4'
  37
+        moduleData[2] = ''
  38
+        version = proc.getVersionIfFlashModule(moduleData)
  39
+        self.assertEqual(version, '10.4')
  40
+
  41
+        moduleData[1] = 'libflashplayer2.1_3.so'
  42
+        moduleData[2] = '0.0'
  43
+        version = proc.getVersionIfFlashModule(moduleData)
  44
+        self.assertEqual(version, '0.0')  # matched but use the defaul
  45
+
  46
+        moduleData[1] = 'libflashplayer2.1_3.so'
  47
+        moduleData[2] = ''
  48
+        version = proc.getVersionIfFlashModule(moduleData)
  49
+        self.assertEqual(version, '2.1_3')
  50
+
  51
+        moduleData[1] = 'NPSWF32_11_2_202_228.dll'
  52
+        moduleData[2] = '11.2.444'
  53
+        version = proc.getVersionIfFlashModule(moduleData)
  54
+        self.assertEqual(version, '11.2.444')
  55
+
  56
+        moduleData[1] = 'NPSWF32_11_2_202_228.dll'
  57
+        moduleData[2] = ''
  58
+        version = proc.getVersionIfFlashModule(moduleData)
  59
+        self.assertEqual(version, '11.2.202.228')
  60
+
  61
+        # it's case sensitive
  62
+        moduleData[1] = 'NPSWF32_11_2_202_228.DLL'
  63
+        version = proc.getVersionIfFlashModule(moduleData)
  64
+        self.assertEqual(version, None)
  65
+
  66
+        moduleData[1] = 'NPSWF32.dll'  # filename
  67
+        moduleData[2] = ''  # version
  68
+        moduleData[4] = 'yyy'  # debugId (see above)
  69
+        version = proc.getVersionIfFlashModule(moduleData)
  70
+        self.assertEqual(version, '9.0')

0 notes on commit ba283b1

Please sign in to comment.
Something went wrong with that request. Please try again.