Skip to content
This repository was archived by the owner on Oct 18, 2020. It is now read-only.

Commit 9536a0a

Browse files
committed
EFilter bugfixes
BUG= Review URL: https://codereview.appspot.com/322440043 .
1 parent 251d4be commit 9536a0a

File tree

7 files changed

+278
-153
lines changed

7 files changed

+278
-153
lines changed

rekall-core/rekall/plugins/common/efilter_plugins/helpers.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import functools
44
import re
5+
import six
56

67
from efilter import query as q
78
from efilter import api
@@ -39,6 +40,20 @@ def noncase_search_function(regex, value):
3940
return bool(re.search(unicode(regex), unicode(value), re.I))
4041

4142

43+
def substitute(pattern, repl, target):
44+
if target is None:
45+
return
46+
47+
if isinstance(target, (list, tuple)):
48+
result = []
49+
for item in target:
50+
result.append(substitute(pattern, repl, item))
51+
52+
return result
53+
else:
54+
return re.sub(pattern, repl, six.text_type(target), re.I)
55+
56+
4257
EFILTER_SCOPES = dict(
4358
hex=api.user_func(
4459
hex_function, arg_types=[int], return_type=[str]),
@@ -52,6 +67,9 @@ def noncase_search_function(regex, value):
5267
regex_search=api.user_func(
5368
noncase_search_function, arg_types=[unicode, unicode],
5469
return_type=[bool]),
70+
71+
concat=api.user_func(lambda *args: "".join(args)),
72+
sub=api.user_func(substitute),
5573
)
5674

5775

rekall-core/rekall/plugins/common/efilter_plugins/info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ class Describe(plugin.TypedProfileCommand, plugin.ProfileCommand):
3737
help="A plugin or plugin name to describe."),
3838

3939
dict(name="args", required=False, default={}, type="dict",
40+
positional=True,
4041
help="args to run the plugin with."),
4142

4243
dict(name="max_depth", positional=True, required=False,
43-
type="IntParser", default=0,
44+
type="IntParser", default=3,
4445
help="The maximum depth to follow mappings."),
4546
]
4647

rekall-core/rekall/plugins/common/efilter_plugins/ipython.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@ def _RunPlugin(self, session, plugin_name, line):
1313

1414
return session.RunPlugin(plugin_name, query=line)
1515

16-
@magic.line_cell_magic
17-
def search(self, line, cell=None):
18-
session = self.shell.user_global_ns["session"]
19-
if cell is None:
20-
return self._RunPlugin(session, "search", line)
21-
else:
22-
return self._RunPlugin(session, "search", cell)
23-
2416
@magic.line_cell_magic
2517
def SELECT(self, line, cell=None):
2618
return self._process_select(line, cell)
@@ -39,10 +31,8 @@ def select(self, line, cell=None):
3931

4032
def _process_select(self, line, cell=None):
4133
session = self.shell.user_module.session
42-
if cell is None:
43-
return self._RunPlugin(session, "search", "select " + line)
44-
else:
45-
return self._RunPlugin(session, "search", "select " + cell)
34+
return self._RunPlugin(session, "search", "select " + line + (
35+
cell or ""))
4636

4737
@magic.line_cell_magic
4838
def pager(self, line, cell=None):

0 commit comments

Comments
 (0)