yara-python icon indicating copy to clipboard operation
yara-python copied to clipboard

How to add the match file path name to the callback function argument?

Open YahuiWong opened this issue 4 years ago • 0 comments

Here is an example:

import yara

def mycallback(data):
  print(data)
  return yara.CALLBACK_CONTINUE

matches = rules.match('/foo/bar/my_file', callback=mycallback, which_callbacks=yara.CALLBACK_MATCHES) The passed dictionary will be something like this:

{
  'tags': ['foo', 'bar'],
  'matches': True,
  'namespace': 'default',
  'rule': 'my_rule',
  'meta': {},
  'strings': [(81L, '$a', 'abc'), (141L, '$b', 'def')]
}

How to add the match file path name to the callback function argument? The passed dictionary will be something like this:

{
  'file_path':'/foo/bar/my_file',
  'tags': ['foo', 'bar'],
  'matches': True,
  'namespace': 'default',
  'rule': 'my_rule',
  'meta': {},
  'strings': [(81L, '$a', 'abc'), (141L, '$b', 'def')]
}

YahuiWong avatar Sep 30 '21 02:09 YahuiWong