Skip to content

Commit d6549f8

Browse files
committed
new filter field: command; added changes to log
1 parent fd71863 commit d6549f8

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

CHANGES.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ Changes
55
------------------
66

77
* FEATURE: New flag ``-j`` for JSON-formatted log output
8-
* FEATURE: (UNTESTED) Mac OS X support
9-
* FIX: Several implementations of FUSE calls such as truncate did rely on the assumption that the current working directory of the file system process would not change. This was risky.
8+
* FEATURE: New field ``command`` allowed in XML configuration files for filtering for command strings with regular expressions
9+
* FEATURE: All fields in ``include`` and ``exclude`` tags, e.g. ``extension`` or ``uid``, become optional / implicit and can be omitted.
10+
* FEATURE: (UNTESTED) Mac OS X support. Test framework still relies on Linux.
11+
* FIX: Several implementations of FUSE calls such as truncate did rely on the assumption that the current working directory of the file system process would not change. This was risky. LoggedFS-python does also NOT change the current working directory anymore on its own.
1012
* Code cleanup
1113

1214
0.0.1 (2019-04-11)

src/loggedfs/filter.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def new_filter_item():
5555
'extension': '.*',
5656
'uid': '*',
5757
'action': '.*',
58-
'retname': '.*'
58+
'retname': '.*',
59+
'command': '.*'
5960
}
6061

6162

@@ -121,39 +122,41 @@ def _compile_filter_item_(in_item):
121122
re.compile(in_item['extension']),
122123
int(in_item['uid']) if in_item['uid'].isnumeric() else None,
123124
re.compile(in_item['action']),
124-
re.compile(in_item['retname'])
125+
re.compile(in_item['retname']),
126+
re.compile(in_item['command'])
125127
)
126128

127129

128130
def match_filters(
129-
abs_path, uid, action, ret_status,
131+
abs_path, uid, action, ret_status, command,
130132
incl_filter_list, excl_filter_list
131133
):
132134

133135
if len(incl_filter_list) != 0:
134136
included = False
135137
for filter_tuple in incl_filter_list:
136-
if _match_filter_item_(abs_path, uid, action, ret_status, *filter_tuple):
138+
if _match_filter_item_(abs_path, uid, action, ret_status, command, *filter_tuple):
137139
included = True
138140
break
139141
if not included:
140142
return False
141143

142144
for filter_tuple in excl_filter_list:
143-
if _match_filter_item_(abs_path, uid, action, ret_status, *filter_tuple):
145+
if _match_filter_item_(abs_path, uid, action, ret_status, command, *filter_tuple):
144146
return False
145147

146148
return True
147149

148150

149151
def _match_filter_item_(
150-
abs_path, uid, action, ret_status,
151-
f_path, f_uid, f_action, f_status
152+
abs_path, uid, action, ret_status, command,
153+
f_path, f_uid, f_action, f_status, f_command
152154
):
153155

154156
return all((
155157
bool(f_path.match(abs_path)),
156158
(uid == f_uid) if isinstance(f_uid, int) else True,
157159
bool(f_action.match(action)),
158-
bool(f_status.match(ret_status))
160+
bool(f_status.match(ret_status)),
161+
bool(f_command.match(command))
159162
))

src/loggedfs/out.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def _log_event_(
217217
log_dict['return'] = ret_str
218218

219219
if not match_filters(
220-
log_dict['param_%s' % func_arg_abspath], uid, func.__name__, ret_status,
220+
log_dict['param_%s' % func_arg_abspath], uid, func.__name__, ret_status, p_cmdname,
221221
self._f_incl, self._f_excl
222222
):
223223
return

tests/test_loggedfs_cfg.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<include extension=".*" uid="*" action=".*" retname=".*"/>
66
</includes>
77
<excludes>
8+
<exclude command=".*gvfs.*"/>
89
<exclude extension=".*.proverc" uid="*" action=".*" retname=".*"/>
910
<exclude extension=".*.prove" uid="*" action=".*" retname=".*"/>
1011
<exclude extension=".*autorun.inf" uid="*" action=".*" retname=".*"/>

0 commit comments

Comments
 (0)