Commit de9f5e91ac6aaf6fdefba89e29a607931cc91e06

Authored by Christian Herdtweck
1 parent 79564711

ppt_record_parser: pylint, pep8; fix history, add todo

Showing 1 changed file with 13 additions and 9 deletions
oletools/ppt_record_parser.py
@@ -29,12 +29,13 @@ Alternative to ppt_parser.py that works on records @@ -29,12 +29,13 @@ Alternative to ppt_parser.py that works on records
29 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 # POSSIBILITY OF SUCH DAMAGE. 30 # POSSIBILITY OF SUCH DAMAGE.
31 31
32 -#------------------------------------------------------------------------------ 32 +# -----------------------------------------------------------------------------
33 # CHANGELOG: 33 # CHANGELOG:
34 -# 2017-11-30 v0.01 CH: - first version based on xls_parser 34 +# 2017-11-30 v0.01 CH: - first version, can be used in oledump
35 35
36 -#------------------------------------------------------------------------------ 36 +# -----------------------------------------------------------------------------
37 # TODO: 37 # TODO:
  38 +# - provide stuff from ppt_parser as well and replace it
38 39
39 # ----------------------------------------------------------------------------- 40 # -----------------------------------------------------------------------------
40 # REFERENCES: 41 # REFERENCES:
@@ -166,7 +167,7 @@ class PptFile(record_base.OleRecordFile): @@ -166,7 +167,7 @@ class PptFile(record_base.OleRecordFile):
166 """ Record-based view on a PowerPoint ppt file """ 167 """ Record-based view on a PowerPoint ppt file """
167 168
168 @classmethod 169 @classmethod
169 - def stream_class_for_name(self, stream_name): 170 + def stream_class_for_name(cls, stream_name):
170 return PptStream 171 return PptStream
171 172
172 173
@@ -231,7 +232,7 @@ class PptRecord(record_base.OleRecordBase): @@ -231,7 +232,7 @@ class PptRecord(record_base.OleRecordBase):
231 if self.INSTANCE is not None and self.INSTANCE != instance: 232 if self.INSTANCE is not None and self.INSTANCE != instance:
232 raise ValueError('invalid instance {0} for {1}' 233 raise ValueError('invalid instance {0} for {1}'
233 .format(instance, self)) 234 .format(instance, self))
234 - elif self.INSTANCE is not None and instance not in (0,1): 235 + elif self.INSTANCE is not None and instance not in (0, 1):
235 try: 236 try:
236 min_val, max_val = INSTANCE_EXCEPTIONS[self.type] 237 min_val, max_val = INSTANCE_EXCEPTIONS[self.type]
237 is_ok = (min_val <= instance <= max_val) 238 is_ok = (min_val <= instance <= max_val)
@@ -252,7 +253,7 @@ class PptRecord(record_base.OleRecordBase): @@ -252,7 +253,7 @@ class PptRecord(record_base.OleRecordBase):
252 if not is_ok: 253 if not is_ok:
253 logging.warning('unexpected version {0} for {1}' 254 logging.warning('unexpected version {0} for {1}'
254 .format(version, self)) 255 .format(version, self))
255 - self.version = version 256 + self.version = version
256 257
257 def _type_str(self): 258 def _type_str(self):
258 """ helper for __str__, base implementation """ 259 """ helper for __str__, base implementation """
@@ -360,6 +361,7 @@ class PptRecordCurrentUser(PptRecord): @@ -360,6 +361,7 @@ class PptRecordCurrentUser(PptRecord):
360 .format(self.size - offset)) 361 .format(self.size - offset))
361 362
362 def is_document_encrypted(self): 363 def is_document_encrypted(self):
  364 + """determine from header_token whether document stream is encrypted"""
363 if self.header_token is None: 365 if self.header_token is None:
364 raise ValueError('unknown') 366 raise ValueError('unknown')
365 return self.header_token == 0xF3D1C4DF 367 return self.header_token == 0xF3D1C4DF
@@ -376,7 +378,7 @@ class PptRecordCurrentUser(PptRecord): @@ -376,7 +378,7 @@ class PptRecordCurrentUser(PptRecord):
376 logging.debug('found unicode user name BEHIND current user atom') 378 logging.debug('found unicode user name BEHIND current user atom')
377 else: 379 else:
378 logging.warning('Unexplained data of size {0} in "Current User" ' 380 logging.warning('Unexplained data of size {0} in "Current User" '
379 - 'stream'.format(len(data))) 381 + 'stream'.format(len(more_data)))
380 382
381 383
382 class PptRecordExOleObjAtom(PptRecord): 384 class PptRecordExOleObjAtom(PptRecord):
@@ -564,12 +566,13 @@ class PptRecordExOleVbaActiveXAtom(PptRecord): @@ -564,12 +566,13 @@ class PptRecordExOleVbaActiveXAtom(PptRecord):
564 566
565 whether this is an OLE object or ActiveX control or a VBA Storage, need to 567 whether this is an OLE object or ActiveX control or a VBA Storage, need to
566 find the corresponding PptRecordExOleObjAtom 568 find the corresponding PptRecordExOleObjAtom
  569 + TODO: do that!
567 """ 570 """
568 571
569 -  
570 TYPE = 0x1011 572 TYPE = 0x1011
571 573
572 def is_compressed(self): 574 def is_compressed(self):
  575 + """ determine whether data is compressed or uncompressed """
573 return self.instance == 1 576 return self.instance == 1
574 577
575 def get_uncompressed_size(self): 578 def get_uncompressed_size(self):
@@ -685,4 +688,5 @@ if __name__ == &#39;__main__&#39;: @@ -685,4 +688,5 @@ if __name__ == &#39;__main__&#39;:
685 def do_per_record(record): 688 def do_per_record(record):
686 print_records(record, logging.info, 2, False) 689 print_records(record, logging.info, 2, False)
687 sys.exit(record_base.test(sys.argv[1:], PptFile, 690 sys.exit(record_base.test(sys.argv[1:], PptFile,
688 - do_per_record=do_per_record)) 691 + do_per_record=do_per_record,
  692 + verbose=False))