Commit de9f5e91ac6aaf6fdefba89e29a607931cc91e06
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 | 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 30 | 30 | # POSSIBILITY OF SUCH DAMAGE. |
| 31 | 31 | |
| 32 | -#------------------------------------------------------------------------------ | |
| 32 | +# ----------------------------------------------------------------------------- | |
| 33 | 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 | 37 | # TODO: |
| 38 | +# - provide stuff from ppt_parser as well and replace it | |
| 38 | 39 | |
| 39 | 40 | # ----------------------------------------------------------------------------- |
| 40 | 41 | # REFERENCES: |
| ... | ... | @@ -166,7 +167,7 @@ class PptFile(record_base.OleRecordFile): |
| 166 | 167 | """ Record-based view on a PowerPoint ppt file """ |
| 167 | 168 | |
| 168 | 169 | @classmethod |
| 169 | - def stream_class_for_name(self, stream_name): | |
| 170 | + def stream_class_for_name(cls, stream_name): | |
| 170 | 171 | return PptStream |
| 171 | 172 | |
| 172 | 173 | |
| ... | ... | @@ -231,7 +232,7 @@ class PptRecord(record_base.OleRecordBase): |
| 231 | 232 | if self.INSTANCE is not None and self.INSTANCE != instance: |
| 232 | 233 | raise ValueError('invalid instance {0} for {1}' |
| 233 | 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 | 236 | try: |
| 236 | 237 | min_val, max_val = INSTANCE_EXCEPTIONS[self.type] |
| 237 | 238 | is_ok = (min_val <= instance <= max_val) |
| ... | ... | @@ -252,7 +253,7 @@ class PptRecord(record_base.OleRecordBase): |
| 252 | 253 | if not is_ok: |
| 253 | 254 | logging.warning('unexpected version {0} for {1}' |
| 254 | 255 | .format(version, self)) |
| 255 | - self.version = version | |
| 256 | + self.version = version | |
| 256 | 257 | |
| 257 | 258 | def _type_str(self): |
| 258 | 259 | """ helper for __str__, base implementation """ |
| ... | ... | @@ -360,6 +361,7 @@ class PptRecordCurrentUser(PptRecord): |
| 360 | 361 | .format(self.size - offset)) |
| 361 | 362 | |
| 362 | 363 | def is_document_encrypted(self): |
| 364 | + """determine from header_token whether document stream is encrypted""" | |
| 363 | 365 | if self.header_token is None: |
| 364 | 366 | raise ValueError('unknown') |
| 365 | 367 | return self.header_token == 0xF3D1C4DF |
| ... | ... | @@ -376,7 +378,7 @@ class PptRecordCurrentUser(PptRecord): |
| 376 | 378 | logging.debug('found unicode user name BEHIND current user atom') |
| 377 | 379 | else: |
| 378 | 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 | 384 | class PptRecordExOleObjAtom(PptRecord): |
| ... | ... | @@ -564,12 +566,13 @@ class PptRecordExOleVbaActiveXAtom(PptRecord): |
| 564 | 566 | |
| 565 | 567 | whether this is an OLE object or ActiveX control or a VBA Storage, need to |
| 566 | 568 | find the corresponding PptRecordExOleObjAtom |
| 569 | + TODO: do that! | |
| 567 | 570 | """ |
| 568 | 571 | |
| 569 | - | |
| 570 | 572 | TYPE = 0x1011 |
| 571 | 573 | |
| 572 | 574 | def is_compressed(self): |
| 575 | + """ determine whether data is compressed or uncompressed """ | |
| 573 | 576 | return self.instance == 1 |
| 574 | 577 | |
| 575 | 578 | def get_uncompressed_size(self): |
| ... | ... | @@ -685,4 +688,5 @@ if __name__ == '__main__': |
| 685 | 688 | def do_per_record(record): |
| 686 | 689 | print_records(record, logging.info, 2, False) |
| 687 | 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)) | ... | ... |