Skip to content

Commit

Permalink
Print full path in match results
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebFenton committed Jun 5, 2019
1 parent f11b21e commit c9f91ef
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions apkid/apkid.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def __init__(self, rules: yara.Rules, options: Options):
self.options = options

def scan(self, path: str) -> None:

if os.path.isfile(path):
results = self.scan_file(path)
if len(results) > 0:
Expand All @@ -119,14 +118,14 @@ def scan_file(self, file_path: str) -> Dict[str, List[yara.Match]]:
return results
matches: List[yara.Matches] = self.rules.match(data=f.read(), timeout=self.options.timeout)
if len(matches) > 0:
results[filename] = matches
results[file_path] = matches

try:
if self._is_zipfile(f, filename):
with zipfile.ZipFile(f) as zf:
zip_results = self._scan_zip(zf)
for entry_name, entry_matches in zip_results.items():
results[f'{filename}!{entry_name}'] = entry_matches
results[f'{file_path}!{entry_name}'] = entry_matches
except Exception as e:
stack = traceback.format_exc()
print(f"Exception scanning {file_path}: {stack}")
Expand Down

0 comments on commit c9f91ef

Please sign in to comment.