Skip to content

Commit

Permalink
Merge pull request #11 from ninoseki/improve-oleid
Browse files Browse the repository at this point in the history
refactor: enforce "is None" checking
  • Loading branch information
ninoseki committed Jun 30, 2020
2 parents 9f6ce8f + cf14ec9 commit 93f2202
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/services/oleid.py
@@ -1,22 +1,35 @@
from typing import Optional

import oletools.oleid
from olefile import OleFileIO, isOleFile


class OleID:
def __init__(self, data: bytes):
self.oid: Optional[oletools.oleid.OleID] = None

if isOleFile(data):
ole_file = OleFileIO(data)
self.oid = oletools.oleid.OleID(ole_file)
self.oid.check()

def is_encrypted(self) -> bool:
if self.oid is None:
return False

encrypted = self.oid.get_indicator("encrypted")
return encrypted is not None and encrypted.value is True

def has_vba_macros(self) -> bool:
if self.oid is None:
return False

macros = self.oid.get_indicator("vba_macros")
return macros is not None and macros.value is True

def has_flash_objects(self) -> bool:
if self.oid is None:
return False

flash = self.oid.get_indicator("flash")
return flash is not None and flash.value > 0

0 comments on commit 93f2202

Please sign in to comment.