Commit 3a79ad1483be4cec72e69f2700bdb8c90b087c51
1 parent
27a69e14
move private function out of loop (all required variables are arguments)
Showing
1 changed file
with
9 additions
and
9 deletions
oletools/olevba.py
| ... | ... | @@ -2237,6 +2237,15 @@ class VBA_Parser(object): |
| 2237 | 2237 | # - The root/VBA storage MUST contain a _VBA_PROJECT stream and a dir stream |
| 2238 | 2238 | # - all names are case-insensitive |
| 2239 | 2239 | |
| 2240 | + def check_vba_stream(ole, vba_root, stream_path): | |
| 2241 | + full_path = vba_root + stream_path | |
| 2242 | + if ole.exists(full_path) and ole.get_type(full_path) == olefile.STGTY_STREAM: | |
| 2243 | + log.debug('Found %s stream: %s' % (stream_path, full_path)) | |
| 2244 | + return full_path | |
| 2245 | + else: | |
| 2246 | + log.debug('Missing %s stream, this is not a valid VBA project structure' % stream_path) | |
| 2247 | + return False | |
| 2248 | + | |
| 2240 | 2249 | # start with an empty list: |
| 2241 | 2250 | self.vba_projects = [] |
| 2242 | 2251 | # Look for any storage containing those storage/streams: |
| ... | ... | @@ -2253,15 +2262,6 @@ class VBA_Parser(object): |
| 2253 | 2262 | vba_root += '/' |
| 2254 | 2263 | log.debug('Checking vba_root="%s"' % vba_root) |
| 2255 | 2264 | |
| 2256 | - def check_vba_stream(ole, vba_root, stream_path): | |
| 2257 | - full_path = vba_root + stream_path | |
| 2258 | - if ole.exists(full_path) and ole.get_type(full_path) == olefile.STGTY_STREAM: | |
| 2259 | - log.debug('Found %s stream: %s' % (stream_path, full_path)) | |
| 2260 | - return full_path | |
| 2261 | - else: | |
| 2262 | - log.debug('Missing %s stream, this is not a valid VBA project structure' % stream_path) | |
| 2263 | - return False | |
| 2264 | - | |
| 2265 | 2265 | # Check if the VBA root storage also contains a PROJECT stream: |
| 2266 | 2266 | project_path = check_vba_stream(ole, vba_root, 'PROJECT') |
| 2267 | 2267 | if not project_path: continue | ... | ... |