Skip to content

Commit

Permalink
Code review: 263060043: Refactored filters log2timeline#154
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Dec 31, 2015
1 parent b9349f5 commit e80d876
Show file tree
Hide file tree
Showing 33 changed files with 1,000 additions and 742 deletions.
2 changes: 1 addition & 1 deletion config/dpkg/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ python-plaso (1.3.1-1) unstable; urgency=low

* Auto-generated

-- Log2Timeline <[email protected]> Sat, 05 Sep 2015 19:14:12 +0200
-- Log2Timeline <[email protected]> Sat, 05 Sep 2015 19:18:41 +0200
26 changes: 21 additions & 5 deletions docs/plaso.filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,34 @@ plaso.filters.dynamic_filter module
:undoc-members:
:show-inheritance:

plaso.filters.eventfilter module
plaso.filters.event_filter module
---------------------------------

.. automodule:: plaso.filters.event_filter
:members:
:undoc-members:
:show-inheritance:

plaso.filters.filter_list module
--------------------------------

.. automodule:: plaso.filters.eventfilter
.. automodule:: plaso.filters.filter_list
:members:
:undoc-members:
:show-inheritance:

plaso.filters.interface module
------------------------------

.. automodule:: plaso.filters.interface
:members:
:undoc-members:
:show-inheritance:

plaso.filters.filterlist module
-------------------------------
plaso.filters.manager module
----------------------------

.. automodule:: plaso.filters.filterlist
.. automodule:: plaso.filters.manager
:members:
:undoc-members:
:show-inheritance:
Expand Down
16 changes: 0 additions & 16 deletions docs/plaso.lib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ plaso.lib.eventdata module
:undoc-members:
:show-inheritance:

plaso.lib.filter_interface module
---------------------------------

.. automodule:: plaso.lib.filter_interface
:members:
:undoc-members:
:show-inheritance:

plaso.lib.lexer module
----------------------

Expand Down Expand Up @@ -108,14 +100,6 @@ plaso.lib.py2to3 module
:undoc-members:
:show-inheritance:

plaso.lib.registry module
-------------------------

.. automodule:: plaso.lib.registry
:members:
:undoc-members:
:show-inheritance:

plaso.lib.specification module
------------------------------

Expand Down
4 changes: 2 additions & 2 deletions plaso/analysis/browser_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import logging
import urllib

from plaso import filters
from plaso.analysis import interface
from plaso.analysis import manager
from plaso.filters import manager as filters_manager
from plaso.formatters import manager as formatters_manager
from plaso.lib import event

Expand Down Expand Up @@ -194,7 +194,7 @@ def __init__(self, incoming_queue):
self._search_term_timeline = []

for filter_str, call_back in self.FILTERS:
filter_obj = filters.GetFilter(filter_str)
filter_obj = filters_manager.FiltersManager.GetFilterObject(filter_str)
call_back_obj = getattr(FilterClass, call_back, None)
if filter_obj and call_back_obj:
self._filter_dict[filter_obj] = (call_back, call_back_obj)
Expand Down
16 changes: 10 additions & 6 deletions plaso/analysis/tagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from plaso.analysis import interface
from plaso.analysis import manager
from plaso import filters
from plaso.filters import manager as filters_manager
from plaso.lib import event


Expand Down Expand Up @@ -120,20 +120,24 @@ def _ParseTaggingFile(self, input_path):
line_strip = line_rstrip.lstrip()
if not line_strip or line_strip.startswith(u'#'):
continue

if not line_rstrip[0].isspace():
current_tag = line_rstrip
tags[current_tag] = []
else:
if not current_tag:
continue
compiled_filter = filters.GetFilter(line_strip)
if compiled_filter:
if compiled_filter not in tags[current_tag]:
tags[current_tag].append(compiled_filter)
else:

compiled_filter = filters_manager.FiltersManager.GetFilterObject(
line_strip)
if not compiled_filter:
logging.warning(
u'Tag "{0:s}" contains invalid filter: {1:s}'.format(
current_tag, line_strip))

elif compiled_filter not in tags[current_tag]:
tags[current_tag].append(compiled_filter)

return tags

def CompileReport(self, analysis_mediator):
Expand Down
40 changes: 3 additions & 37 deletions plaso/filters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,6 @@
# -*- coding: utf-8 -*-
import logging
"""This file contains an import statement for each filter."""

from plaso.filters import dynamic_filter
from plaso.filters import eventfilter
from plaso.filters import filterlist

from plaso.lib import filter_interface
from plaso.lib import errors


def ListFilters():
"""Generate a list of all available filters."""
filters = []
for cl in filter_interface.FilterObject.classes:
filters.append(filter_interface.FilterObject.classes[cl]())

return filters


def GetFilter(filter_string):
"""Returns the first filter that matches the filter string.
Args:
filter_string: A filter string for any of the available filters.
Returns:
The first FilterObject found matching the filter string. If no FilterObject
is available for this filter string None is returned.
"""
if not filter_string:
return

for filter_obj in ListFilters():
try:
filter_obj.CompileFilter(filter_string)
return filter_obj
except errors.WrongPlugin:
logging.debug(u'Filterstring [{}] is not a filter: {}'.format(
filter_string, filter_obj.filter_name))
from plaso.filters import event_filter
from plaso.filters import filter_list
Loading

0 comments on commit e80d876

Please sign in to comment.