fix lot's of pylint issues (not all of them though)
Hanno Böck

Hanno Böck commited on 2008-01-13 13:07:39
Zeige 1 geänderte Dateien mit 47 Einfügungen und 24 Löschungen.

... ...
@@ -26,7 +26,8 @@ import ConfigParser, os, glob, pprint, re, optparse, sys
26 26
 
27 27
 
28 28
 def versioncompare(safe_version, find_version):
29
-  if safe_version==[""]: return True
29
+    if safe_version == [""]:
30
+        return True
30 31
     for i in range(min(len(find_version), len(safe_version))):
31 32
         if int(find_version[i])<int(safe_version[i]):
32 33
             return True
... ...
@@ -34,9 +35,10 @@ def versioncompare(safe_version,find_version):
34 35
             return False
35 36
     return (len(find_version)<len(safe_version))
36 37
 
37
-def vulnprint(appname,version,safeversion,vuln,filename,subdir):
38
-  appdir='/'.join(os.path.abspath(filename).split('/')[:-1-subdir])
39
-  print "%(appname)s %(version)s (%(safeversion)s) %(vuln)s %(appdir)s" % vars()
38
+def vulnprint(appname, version, safeversion, vuln, vfilename, subdir):
39
+    appdir = '/'.join(os.path.abspath(vfilename).split('/')[:-1-subdir])
40
+    print "%(appname)s %(version)s (%(safeversion)s) %(vuln)s %(appdir)s" \
41
+          % vars()
40 42
 
41 43
 pp = pprint.PrettyPrinter(indent=4)
42 44
 
... ...
@@ -45,7 +47,8 @@ parser = optparse.OptionParser()
45 47
 parser.add_option("-a", "--all", action="store_true", dest="ALL",
46 48
                   help="Show all webapps found, not just vulnerable")
47 49
 parser.add_option("-d", "--debug", action="store_true", dest="DEBUG",
48
-                  help="Show lots of debugging output, mainly useful for development")
50
+                  help="Show lots of debugging output, mainly useful"+ \
51
+                  "for development")
49 52
 opts, args = parser.parse_args()
50 53
 
51 54
 # Parse vulnerability database
... ...
@@ -68,24 +71,32 @@ for sect in config.sections():
68 71
     # match magic
69 72
     item['variable'] = []
70 73
     for var in config.get(sect,'variable').split(","):
71
-        item['variable'].append(re.compile(re.escape(var)+r"[^0-9.]*[.]*([0-9.]*[0-9])[^0-9.]"))
74
+        item['variable'].append(re.compile(re.escape(var)+
75
+                                r"[^0-9.]*[.]*([0-9.]*[0-9])[^0-9.]"))
72 76
 
73 77
     # optional options
74
-  if config.has_option(sect,'extra_match'): item['extra_match']=config.get(sect,'extra_match')
75
-  else: item['extra_match']=False
76
-  if config.has_option(sect,'add_minor'): item['add_minor']=config.get(sect,'add_minor')
77
-  else: item['add_minor']=False
78
-  if config.has_option(sect,'old_safe'): item['old_safe']=config.get(sect,'old_safe').split(",")
79
-  else: item['old_safe']=[]
78
+    if config.has_option(sect,'extra_match'):
79
+        item['extra_match'] = config.get(sect,'extra_match')
80
+    else:
81
+        item['extra_match'] = False
82
+    if config.has_option(sect,'add_minor'):
83
+        item['add_minor'] = config.get(sect,'add_minor')
84
+    else:
85
+        item['add_minor'] = False
86
+    if config.has_option(sect,'old_safe'):
87
+        item['old_safe'] = config.get(sect,'old_safe').split(",")
88
+    else:
89
+        item['old_safe'] = []
80 90
 
81 91
     vdb.append(item)
82
-if opts.DEBUG: pp.pprint(vdb)
92
+if opts.DEBUG:
93
+    pp.pprint(vdb)
83 94
 
84 95
 
85 96
 # start the search
86 97
 
87
-for dir in args:
88
-  for root,NULL,files in os.walk(dir):
98
+for fdir in args:
99
+    for root, NULL, files in os.walk(fdir):
89 100
         for filename in files:
90 101
             for item in vdb:
91 102
                 if filename == item['file']:
... ...
@@ -94,8 +105,10 @@ for dir in args:
94 105
                     filestr = file.read()
95 106
                     file.close()
96 107
 
97
-          if item['extra_match']: ematch=(filestr.find(item['extra_match'])!=-1)
98
-          else: ematch=True
108
+                    if item['extra_match']:
109
+                        ematch = (filestr.find(item['extra_match']) != -1)
110
+                    else:
111
+                        ematch = True
99 112
 
100 113
                     findversion = []
101 114
                     for var in item['variable']:
... ...
@@ -112,16 +125,26 @@ for dir in args:
112 125
                         # Very ugly phpbb workaround
113 126
                         if item['add_minor']:
114 127
                             findversion = findversion.split('.')
115
-              findversion[-1]=str(int(findversion[-1])+int(item['add_minor']))
128
+                            findversion[-1] = str(int(findversion[-1])+
129
+                                            int(item['add_minor']))
116 130
                             findversion = '.'.join(findversion)
117 131
 
118
-            if not (versioncompare(item['safe'].split('.'),findversion.split('.'))) or item['old_safe'].count(findversion)>0:
132
+                        if not (versioncompare(item['safe'].split('.'), \
133
+                                findversion.split('.'))) or \
134
+                                item['old_safe'].count(findversion)>0:
119 135
                             if opts.ALL:
120
-                if opts.DEBUG: print "File "+mfile
121
-                vulnprint(item['name'],findversion,"ok","",mfile,item['subdir'])
136
+                                if opts.DEBUG:
137
+                                    print "File "+mfile
138
+                                vulnprint(item['name'], findversion, \
139
+                                          "ok", "", mfile, item['subdir'])
122 140
                         else:
123
-              if opts.DEBUG: print "File "+mfile
124
-              vulnprint (item['name'],findversion,item['safe'],item['vuln'],mfile,item['subdir'])
141
+                            if opts.DEBUG:
142
+                                print "File "+mfile
143
+                            vulnprint (item['name'], findversion, \
144
+                                       item['safe'], item['vuln'], \
145
+                                       mfile, item['subdir'])
125 146
 
126 147
                     else:
127
-            if opts.DEBUG: print "regexp failed for "+item['name']+" on "+mfile
148
+                        if opts.DEBUG:
149
+                            print "regexp failed for " + \
150
+                                  item['name'] + " on " + mfile
128 151