Commit f309ee6819d1479a41c9114d93029be55c7c383a

Authored by Christian Herdtweck
1 parent 3af250c3

Update silencing of wrong pylint warnings

Pylint is just wrong in a few cases (admittedly: those are hard), so can
safely ignore these warnings.

Also ignore errors in thirdparty, this is not really our code.

Also remove a few old "pylint silencers" ("# pylint: disable=...") that
are not used any more in v3.10 of pylint
oletools/common/io_encoding.py
... ... @@ -58,7 +58,7 @@ PY3 = sys.version_info.major >= 3
58 58 if PY3:
59 59 from builtins import open as builtin_open
60 60 else:
61   - from __builtin__ import open as builtin_open
  61 + from __builtin__ import open as builtin_open # pylint: disable=import-error
62 62  
63 63 # -- CONSTANTS ----------------------------------------------------------------
64 64 #: encoding to use for redirection if no good encoding can be found
... ...
oletools/mraptor_milter.py
... ... @@ -69,7 +69,7 @@ __version__ = '0.51'
69 69  
70 70 # --- IMPORTS ----------------------------------------------------------------
71 71  
72   -import Milter
  72 +import Milter # not part of requirements, therefore: # pylint: disable=import-error
73 73 import io
74 74 import time
75 75 import email
... ... @@ -78,7 +78,7 @@ import os
78 78 import logging
79 79 import logging.handlers
80 80 import datetime
81   -import StringIO
  81 +import StringIO # not part of requirements, therefore: # pylint: disable=import-error
82 82  
83 83 from socket import AF_INET6
84 84  
... ... @@ -96,7 +96,7 @@ if not _parent_dir in sys.path:
96 96  
97 97 from oletools import olevba, mraptor
98 98  
99   -from Milter.utils import parse_addr
  99 +from Milter.utils import parse_addr # not part of requirements, therefore: # pylint: disable=import-error
100 100  
101 101 from zipfile import is_zipfile
102 102  
... ... @@ -389,7 +389,7 @@ if __name__ == "__main__":
389 389  
390 390 # Using daemonize:
391 391 # See http://daemonize.readthedocs.io/en/latest/
392   - from daemonize import Daemonize
  392 + from daemonize import Daemonize # not part of requirements, therefore: # pylint: disable=import-error
393 393 daemon = Daemonize(app="mraptor_milter", pid=PIDFILE, action=main)
394 394 daemon.start()
395 395  
... ...
oletools/msodde.py
... ... @@ -149,69 +149,69 @@ LOCATIONS = ('word/document.xml', 'word/endnotes.xml', 'word/footnotes.xml',
149 149 # switches_with_args, switches_without_args, format_switches)
150 150 FIELD_BLACKLIST = (
151 151 # date and time:
152   - ('CREATEDATE', 0, 0, '', 'hs', 'datetime'), # pylint: disable=bad-whitespace
153   - ('DATE', 0, 0, '', 'hls', 'datetime'), # pylint: disable=bad-whitespace
154   - ('EDITTIME', 0, 0, '', '', 'numeric'), # pylint: disable=bad-whitespace
155   - ('PRINTDATE', 0, 0, '', 'hs', 'datetime'), # pylint: disable=bad-whitespace
156   - ('SAVEDATE', 0, 0, '', 'hs', 'datetime'), # pylint: disable=bad-whitespace
157   - ('TIME', 0, 0, '', '', 'datetime'), # pylint: disable=bad-whitespace
  152 + ('CREATEDATE', 0, 0, '', 'hs', 'datetime'),
  153 + ('DATE', 0, 0, '', 'hls', 'datetime'),
  154 + ('EDITTIME', 0, 0, '', '', 'numeric'),
  155 + ('PRINTDATE', 0, 0, '', 'hs', 'datetime'),
  156 + ('SAVEDATE', 0, 0, '', 'hs', 'datetime'),
  157 + ('TIME', 0, 0, '', '', 'datetime'),
158 158 # exclude document automation (we hate the "auto" in "automation")
159 159 # (COMPARE, DOCVARIABLE, GOTOBUTTON, IF, MACROBUTTON, PRINT)
160 160 # document information
161   - ('AUTHOR', 0, 1, '', '', 'string'), # pylint: disable=bad-whitespace
162   - ('COMMENTS', 0, 1, '', '', 'string'), # pylint: disable=bad-whitespace
163   - ('DOCPROPERTY', 1, 0, '', '', 'string/numeric/datetime'), # pylint: disable=bad-whitespace
164   - ('FILENAME', 0, 0, '', 'p', 'string'), # pylint: disable=bad-whitespace
165   - ('FILESIZE', 0, 0, '', 'km', 'numeric'), # pylint: disable=bad-whitespace
166   - ('KEYWORDS', 0, 1, '', '', 'string'), # pylint: disable=bad-whitespace
167   - ('LASTSAVEDBY', 0, 0, '', '', 'string'), # pylint: disable=bad-whitespace
168   - ('NUMCHARS', 0, 0, '', '', 'numeric'), # pylint: disable=bad-whitespace
169   - ('NUMPAGES', 0, 0, '', '', 'numeric'), # pylint: disable=bad-whitespace
170   - ('NUMWORDS', 0, 0, '', '', 'numeric'), # pylint: disable=bad-whitespace
171   - ('SUBJECT', 0, 1, '', '', 'string'), # pylint: disable=bad-whitespace
172   - ('TEMPLATE', 0, 0, '', 'p', 'string'), # pylint: disable=bad-whitespace
173   - ('TITLE', 0, 1, '', '', 'string'), # pylint: disable=bad-whitespace
  161 + ('AUTHOR', 0, 1, '', '', 'string'),
  162 + ('COMMENTS', 0, 1, '', '', 'string'),
  163 + ('DOCPROPERTY', 1, 0, '', '', 'string/numeric/datetime'),
  164 + ('FILENAME', 0, 0, '', 'p', 'string'),
  165 + ('FILESIZE', 0, 0, '', 'km', 'numeric'),
  166 + ('KEYWORDS', 0, 1, '', '', 'string'),
  167 + ('LASTSAVEDBY', 0, 0, '', '', 'string'),
  168 + ('NUMCHARS', 0, 0, '', '', 'numeric'),
  169 + ('NUMPAGES', 0, 0, '', '', 'numeric'),
  170 + ('NUMWORDS', 0, 0, '', '', 'numeric'),
  171 + ('SUBJECT', 0, 1, '', '', 'string'),
  172 + ('TEMPLATE', 0, 0, '', 'p', 'string'),
  173 + ('TITLE', 0, 1, '', '', 'string'),
174 174 # equations and formulas
175 175 # exlude '=' formulae because they have different syntax (and can be bad)
176   - ('ADVANCE', 0, 0, 'dlruxy', '', ''), # pylint: disable=bad-whitespace
177   - ('SYMBOL', 1, 0, 'fs', 'ahju', ''), # pylint: disable=bad-whitespace
  176 + ('ADVANCE', 0, 0, 'dlruxy', '', ''),
  177 + ('SYMBOL', 1, 0, 'fs', 'ahju', ''),
178 178 # form fields
179   - ('FORMCHECKBOX', 0, 0, '', '', ''), # pylint: disable=bad-whitespace
180   - ('FORMDROPDOWN', 0, 0, '', '', ''), # pylint: disable=bad-whitespace
181   - ('FORMTEXT', 0, 0, '', '', ''), # pylint: disable=bad-whitespace
  179 + ('FORMCHECKBOX', 0, 0, '', '', ''),
  180 + ('FORMDROPDOWN', 0, 0, '', '', ''),
  181 + ('FORMTEXT', 0, 0, '', '', ''),
182 182 # index and tables
183   - ('INDEX', 0, 0, 'bcdefghklpsz', 'ry', ''), # pylint: disable=bad-whitespace
  183 + ('INDEX', 0, 0, 'bcdefghklpsz', 'ry', ''),
184 184 # exlude RD since that imports data from other files
185   - ('TA', 0, 0, 'clrs', 'bi', ''), # pylint: disable=bad-whitespace
186   - ('TC', 1, 0, 'fl', 'n', ''), # pylint: disable=bad-whitespace
187   - ('TOA', 0, 0, 'bcdegls', 'fhp', ''), # pylint: disable=bad-whitespace
188   - ('TOC', 0, 0, 'abcdflnopst', 'huwxz', ''), # pylint: disable=bad-whitespace
189   - ('XE', 1, 0, 'frty', 'bi', ''), # pylint: disable=bad-whitespace
  185 + ('TA', 0, 0, 'clrs', 'bi', ''),
  186 + ('TC', 1, 0, 'fl', 'n', ''),
  187 + ('TOA', 0, 0, 'bcdegls', 'fhp', ''),
  188 + ('TOC', 0, 0, 'abcdflnopst', 'huwxz', ''),
  189 + ('XE', 1, 0, 'frty', 'bi', ''),
190 190 # links and references
191 191 # exclude AUTOTEXT and AUTOTEXTLIST since we do not like stuff with 'AUTO'
192   - ('BIBLIOGRAPHY', 0, 0, 'lfm', '', ''), # pylint: disable=bad-whitespace
193   - ('CITATION', 1, 0, 'lfspvm', 'nty', ''), # pylint: disable=bad-whitespace
  192 + ('BIBLIOGRAPHY', 0, 0, 'lfm', '', ''),
  193 + ('CITATION', 1, 0, 'lfspvm', 'nty', ''),
194 194 # exclude HYPERLINK since we are allergic to URLs
195 195 # exclude INCLUDEPICTURE and INCLUDETEXT (other file or maybe even URL?)
196 196 # exclude LINK and REF (could reference other files)
197   - ('NOTEREF', 1, 0, '', 'fhp', ''), # pylint: disable=bad-whitespace
198   - ('PAGEREF', 1, 0, '', 'hp', ''), # pylint: disable=bad-whitespace
199   - ('QUOTE', 1, 0, '', '', 'datetime'), # pylint: disable=bad-whitespace
200   - ('STYLEREF', 1, 0, '', 'lnprtw', ''), # pylint: disable=bad-whitespace
  197 + ('NOTEREF', 1, 0, '', 'fhp', ''),
  198 + ('PAGEREF', 1, 0, '', 'hp', ''),
  199 + ('QUOTE', 1, 0, '', '', 'datetime'),
  200 + ('STYLEREF', 1, 0, '', 'lnprtw', ''),
201 201 # exclude all Mail Merge commands since they import data from other files
202 202 # (ADDRESSBLOCK, ASK, COMPARE, DATABASE, FILLIN, GREETINGLINE, IF,
203 203 # MERGEFIELD, MERGEREC, MERGESEQ, NEXT, NEXTIF, SET, SKIPIF)
204 204 # Numbering
205   - ('LISTNUM', 0, 1, 'ls', '', ''), # pylint: disable=bad-whitespace
206   - ('PAGE', 0, 0, '', '', 'numeric'), # pylint: disable=bad-whitespace
207   - ('REVNUM', 0, 0, '', '', ''), # pylint: disable=bad-whitespace
208   - ('SECTION', 0, 0, '', '', 'numeric'), # pylint: disable=bad-whitespace
209   - ('SECTIONPAGES', 0, 0, '', '', 'numeric'), # pylint: disable=bad-whitespace
210   - ('SEQ', 1, 1, 'rs', 'chn', 'numeric'), # pylint: disable=bad-whitespace
211   - # user information # pylint: disable=bad-whitespace
212   - ('USERADDRESS', 0, 1, '', '', 'string'), # pylint: disable=bad-whitespace
213   - ('USERINITIALS', 0, 1, '', '', 'string'), # pylint: disable=bad-whitespace
214   - ('USERNAME', 0, 1, '', '', 'string'), # pylint: disable=bad-whitespace
  205 + ('LISTNUM', 0, 1, 'ls', '', ''),
  206 + ('PAGE', 0, 0, '', '', 'numeric'),
  207 + ('REVNUM', 0, 0, '', '', ''),
  208 + ('SECTION', 0, 0, '', '', 'numeric'),
  209 + ('SECTIONPAGES', 0, 0, '', '', 'numeric'),
  210 + ('SEQ', 1, 1, 'rs', 'chn', 'numeric'),
  211 + # user information
  212 + ('USERADDRESS', 0, 1, '', '', 'string'),
  213 + ('USERINITIALS', 0, 1, '', '', 'string'),
  214 + ('USERNAME', 0, 1, '', '', 'string'),
215 215 )
216 216  
217 217 FIELD_DDE_REGEX = re.compile(r'^\s*dde(auto)?\s+', re.I)
... ...
oletools/oleobj.py
... ... @@ -180,7 +180,7 @@ if sys.version_info[0] <= 2:
180 180 NULL_CHAR = '\x00'
181 181 else:
182 182 # Python 3.x
183   - NULL_CHAR = 0 # pylint: disable=redefined-variable-type
  183 + NULL_CHAR = 0
184 184 xrange = range # pylint: disable=redefined-builtin, invalid-name
185 185  
186 186 OOXML_RELATIONSHIP_TAG = '{http://schemas.openxmlformats.org/package/2006/relationships}Relationship'
... ...
oletools/olevba.py
... ... @@ -3087,7 +3087,7 @@ class VBA_Parser(object):
3087 3087 log.info('Check whether OLE file is PPT')
3088 3088 try:
3089 3089 ppt = ppt_parser.PptParser(self.ole_file, fast_fail=True)
3090   - for vba_data in ppt.iter_vba_data():
  3090 + for vba_data in ppt.iter_vba_data(): # pylint: disable=no-value-for-parameter
3091 3091 self.append_subfile(None, vba_data, container='PptParser')
3092 3092 log.info('File is PPT')
3093 3093 self.ole_file.close() # just in case
... ...
oletools/ooxml.py
... ... @@ -160,7 +160,7 @@ def debug_str(elem):
160 160 def isstr(some_var):
161 161 """ version-independent test for isinstance(some_var, (str, unicode)) """
162 162 if sys.version_info.major == 2:
163   - return isinstance(some_var, basestring) # true for str and unicode
  163 + return isinstance(some_var, basestring) # true for str and unicode # pylint: disable=undefined-variable
164 164 return isinstance(some_var, str) # there is no unicode
165 165  
166 166  
... ...
oletools/ppt_parser.py
... ... @@ -1377,7 +1377,7 @@ class PptParser(object):
1377 1377 # first identified in step 3 of Part 1, that is, the UserEditAtom
1378 1378 # record closest to the end of the stream.
1379 1379 if self.persist_object_directory is None:
1380   - self.parse_persist_object_directory()
  1380 + self.parse_persist_object_directory() # pylint: disable=no-value-for-parameter
1381 1381  
1382 1382 # Step 2: Lookup the value of the docPersistIdRef field in the persist
1383 1383 # object directory constructed in step 8 of Part 1 to find the stream
... ... @@ -1462,7 +1462,7 @@ class PptParser(object):
1462 1462 rec_len=VBAInfoAtom.RECORD_LENGTH)
1463 1463  
1464 1464 # try parse
1465   - for idx in self.search_pattern(pattern):
  1465 + for idx in self.search_pattern(pattern): # pylint: disable=no-value-for-parameter
1466 1466 # assume that in stream at idx there is a VBAInfoContainer
1467 1467 stream.seek(idx)
1468 1468 log.debug('extracting at idx {0}'.format(idx))
... ... @@ -1515,7 +1515,7 @@ class PptParser(object):
1515 1515 pattern = obj_type.generate_pattern()
1516 1516  
1517 1517 # try parse
1518   - for idx in self.search_pattern(pattern):
  1518 + for idx in self.search_pattern(pattern): # pylint: disable=no-value-for-parameter
1519 1519 # assume a ExternalObjectStorage in stream at idx
1520 1520 stream.seek(idx)
1521 1521 log.debug('extracting at idx {0}'.format(idx))
... ... @@ -1589,7 +1589,7 @@ class PptParser(object):
1589 1589  
1590 1590 n_infos = 0
1591 1591 n_macros = 0
1592   - for info in self.search_vba_info():
  1592 + for info in self.search_vba_info(stream):
1593 1593 n_infos += 1
1594 1594 if info.vba_info_atom.f_has_macros > 0:
1595 1595 n_macros += 1
... ... @@ -1597,13 +1597,13 @@ class PptParser(object):
1597 1597 # --> no vba-info, so all storages probably ActiveX or other OLE
1598 1598 n_storages = 0
1599 1599 n_compressed = 0
1600   - for storage in self.search_vba_storage():
  1600 + for storage in self.search_vba_storage(): # pylint: disable=no-value-for-parameter
1601 1601 n_storages += 1
1602 1602 if storage.is_compressed:
1603 1603 n_compressed += 1
1604   - yield self.decompress_vba_storage(storage)
  1604 + yield self.decompress_vba_storage(storage) # pylint: disable=no-value-for-parameter
1605 1605 else:
1606   - yield self.read_vba_storage_data(storage)
  1606 + yield self.read_vba_storage_data(storage) # pylint: disable=no-value-for-parameter
1607 1607  
1608 1608 log.info('found {0} infos ({1} with macros) and {2} storages '
1609 1609 '({3} compressed)'
... ...
oletools/rtfobj.py
... ... @@ -337,7 +337,7 @@ if sys.version_info[0] <= 2:
337 337 BACKSLASH = '\\'
338 338 BRACE_OPEN = '{'
339 339 BRACE_CLOSE = '}'
340   - UNICODE_TYPE = unicode
  340 + UNICODE_TYPE = unicode # pylint: disable=undefined-variable
341 341 else:
342 342 # Python 3.x - Integers
343 343 BACKSLASH = ord('\\')
... ...
oletools/xls_parser.py
... ... @@ -229,46 +229,46 @@ class XlsbStream(record_base.OleRecordStream):
229 229  
230 230 # records that appear often but do not need their own XlsRecord subclass (yet)
231 231 FREQUENT_RECORDS = dict([
232   - ( 156, 'BuiltInFnGroupCount'), # pylint: disable=bad-whitespace
233   - (2147, 'BookExt'), # pylint: disable=bad-whitespace
234   - ( 442, 'CodeName'), # pylint: disable=bad-whitespace
235   - ( 66, 'CodePage'), # pylint: disable=bad-whitespace
236   - (4195, 'Dat'), # pylint: disable=bad-whitespace
237   - (2154, 'DataLabExt'), # pylint: disable=bad-whitespace
238   - (2155, 'DataLabExtContents'), # pylint: disable=bad-whitespace
239   - ( 215, 'DBCell'), # pylint: disable=bad-whitespace
240   - ( 220, 'DbOrParmQry'), # pylint: disable=bad-whitespace
241   - (2051, 'DBQueryExt'), # pylint: disable=bad-whitespace
242   - (2166, 'DConn'), # pylint: disable=bad-whitespace
243   - ( 35, 'ExternName'), # pylint: disable=bad-whitespace
244   - ( 23, 'ExternSheet'), # pylint: disable=bad-whitespace
245   - ( 255, 'ExtSST'), # pylint: disable=bad-whitespace
246   - (2052, 'ExtString'), # pylint: disable=bad-whitespace
247   - (2151, 'FeatHdr'), # pylint: disable=bad-whitespace
248   - ( 91, 'FileSharing'), # pylint: disable=bad-whitespace
249   - (1054, 'Format'), # pylint: disable=bad-whitespace
250   - ( 49, 'Font'), # pylint: disable=bad-whitespace
251   - (2199, 'GUIDTypeLib'), # pylint: disable=bad-whitespace
252   - ( 440, 'HLink'), # pylint: disable=bad-whitespace
253   - ( 225, 'InterfaceHdr'), # pylint: disable=bad-whitespace
254   - ( 226, 'InterfaceEnd'), # pylint: disable=bad-whitespace
255   - ( 523, 'Index'), # pylint: disable=bad-whitespace
256   - ( 24, 'Lbl'), # pylint: disable=bad-whitespace
257   - ( 193, 'Mms'), # pylint: disable=bad-whitespace
258   - ( 93, 'Obj'), # pylint: disable=bad-whitespace
259   - (4135, 'ObjectLink'), # pylint: disable=bad-whitespace
260   - (2058, 'OleDbConn'), # pylint: disable=bad-whitespace
261   - ( 222, 'OleObjectSize'), # pylint: disable=bad-whitespace
262   - (2214, 'RichTextStream'), # pylint: disable=bad-whitespace
263   - (2146, 'SheetExt'), # pylint: disable=bad-whitespace
264   - (1212, 'ShrFmla'), # pylint: disable=bad-whitespace
265   - (2060, 'SxViewExt'), # pylint: disable=bad-whitespace
266   - (2136, 'SxViewLink'), # pylint: disable=bad-whitespace
267   - (2049, 'WebPub'), # pylint: disable=bad-whitespace
268   - ( 224, 'XF (formatting)'), # pylint: disable=bad-whitespace
269   - (2173, 'XFExt (formatting)'), # pylint: disable=bad-whitespace
270   - ( 659, 'Style'), # pylint: disable=bad-whitespace
271   - (2194, 'StyleExt') # pylint: disable=bad-whitespace
  232 + ( 156, 'BuiltInFnGroupCount'),
  233 + (2147, 'BookExt'),
  234 + ( 442, 'CodeName'),
  235 + ( 66, 'CodePage'),
  236 + (4195, 'Dat'),
  237 + (2154, 'DataLabExt'),
  238 + (2155, 'DataLabExtContents'),
  239 + ( 215, 'DBCell'),
  240 + ( 220, 'DbOrParmQry'),
  241 + (2051, 'DBQueryExt'),
  242 + (2166, 'DConn'),
  243 + ( 35, 'ExternName'),
  244 + ( 23, 'ExternSheet'),
  245 + ( 255, 'ExtSST'),
  246 + (2052, 'ExtString'),
  247 + (2151, 'FeatHdr'),
  248 + ( 91, 'FileSharing'),
  249 + (1054, 'Format'),
  250 + ( 49, 'Font'),
  251 + (2199, 'GUIDTypeLib'),
  252 + ( 440, 'HLink'),
  253 + ( 225, 'InterfaceHdr'),
  254 + ( 226, 'InterfaceEnd'),
  255 + ( 523, 'Index'),
  256 + ( 24, 'Lbl'),
  257 + ( 193, 'Mms'),
  258 + ( 93, 'Obj'),
  259 + (4135, 'ObjectLink'),
  260 + (2058, 'OleDbConn'),
  261 + ( 222, 'OleObjectSize'),
  262 + (2214, 'RichTextStream'),
  263 + (2146, 'SheetExt'),
  264 + (1212, 'ShrFmla'),
  265 + (2060, 'SxViewExt'),
  266 + (2136, 'SxViewLink'),
  267 + (2049, 'WebPub'),
  268 + ( 224, 'XF (formatting)'),
  269 + (2173, 'XFExt (formatting)'),
  270 + ( 659, 'Style'),
  271 + (2194, 'StyleExt')
272 272 ])
273 273  
274 274 #: records found in xlsb binary parts
... ...
tests/ooxml/test_zip_sub_file.py
... ... @@ -111,8 +111,8 @@ class TestZipSubFile(unittest.TestCase):
111 111 self.assertEqual(self.subfile.tell(), self.compare.tell())
112 112  
113 113 # seek backward (only implemented case: back to start)
114   - self.subfile.seek(-self.subfile.tell(), os.SEEK_CUR)
115   - self.compare.seek(-self.compare.tell(), os.SEEK_CUR)
  114 + self.subfile.seek(-1 * self.subfile.tell(), os.SEEK_CUR)
  115 + self.compare.seek(-1 * self.compare.tell(), os.SEEK_CUR)
116 116 self.assertEqual(self.subfile.read(1), self.compare.read(1))
117 117 self.assertEqual(self.subfile.tell(), self.compare.tell())
118 118  
... ...