OLD | NEW |
| (Empty) |
1 # -*- coding: utf-8 -*- | |
2 """The log2timeline front-end.""" | |
3 | |
4 import logging | |
5 import sys | |
6 | |
7 import plaso | |
8 # The following import makes sure the filters are registered. | |
9 from plaso import filters # pylint: disable=unused-import | |
10 # The following import makes sure the analyzers are registered. | |
11 from plaso import analyzers # pylint: disable=unused-import | |
12 # The following import makes sure the parsers are registered. | |
13 from plaso import parsers # pylint: disable=unused-import | |
14 # The following import makes sure the output modules are registered. | |
15 from plaso import output # pylint: disable=unused-import | |
16 from plaso.filters import manager as filters_manager | |
17 from plaso.frontend import extraction_frontend | |
18 from plaso.output import manager as output_manager | |
19 | |
20 | |
21 class LoggingFilter(logging.Filter): | |
22 """Class that implements basic filtering of log events for plaso. | |
23 | |
24 Some libraries, like binplist, introduce excessive amounts of | |
25 logging that clutters the debug logs of plaso, making them | |
26 almost unusable. This class implements a filter designed to make | |
27 the debug logs more clutter-free. | |
28 """ | |
29 | |
30 def filter(self, record): | |
31 """Filter messages sent to the logging infrastructure.""" | |
32 if record.module == u'binplist' and record.levelno < logging.ERROR: | |
33 return False | |
34 | |
35 return True | |
36 | |
37 | |
38 class Log2TimelineFrontend(extraction_frontend.ExtractionFrontend): | |
39 """Class that implements the log2timeline front-end.""" | |
40 | |
41 def _GetFiltersInformation(self): | |
42 """Retrieves the filters information. | |
43 | |
44 Returns: | |
45 A list of tuples of filter names and docstrings. | |
46 """ | |
47 filters_information = [] | |
48 for filter_object in sorted( | |
49 filters_manager.FiltersManager.GetFilterObjects()): | |
50 # TODO: refactor to use DESCRIPTION instead of docstring. | |
51 doc_string, _, _ = filter_object.__doc__.partition(u'\n') | |
52 filters_information.append((filter_object.filter_name, doc_string)) | |
53 | |
54 return filters_information | |
55 | |
56 def _GetOutputModulesInformation(self): | |
57 """Retrieves the output modules information. | |
58 | |
59 Returns: | |
60 A list of tuples of output module names and descriptions. | |
61 """ | |
62 output_modules_information = [] | |
63 for name, output_class in output_manager.OutputManager.GetOutputClasses(): | |
64 output_modules_information.append((name, output_class.DESCRIPTION)) | |
65 | |
66 return output_modules_information | |
67 | |
68 def GetDisabledOutputClasses(self): | |
69 """Retrieves the disabled output classes. | |
70 | |
71 Returns: | |
72 An output module generator which yields tuples of output class names | |
73 and type object. | |
74 """ | |
75 return output_manager.OutputManager.GetDisabledOutputClasses() | |
76 | |
77 def GetOutputClasses(self): | |
78 """Retrieves the available output classes. | |
79 | |
80 Returns: | |
81 An output module generator which yields tuples of output class names | |
82 and type object. | |
83 """ | |
84 return output_manager.OutputManager.GetOutputClasses() | |
85 | |
86 def GetPluginData(self): | |
87 """Retrieves the version and various plugin information. | |
88 | |
89 Returns: | |
90 A dictionary object with lists of available parsers and plugins. | |
91 """ | |
92 return_dict = {} | |
93 | |
94 return_dict[u'Versions'] = [ | |
95 (u'plaso engine', plaso.__version__), | |
96 (u'python', sys.version)] | |
97 | |
98 return_dict[u'Hashers'] = self.GetHashersInformation() | |
99 return_dict[u'Parsers'] = self.GetParsersInformation() | |
100 return_dict[u'Parser Plugins'] = self.GetParserPluginsInformation() | |
101 return_dict[u'Parser Presets'] = self.GetParserPresetsInformation() | |
102 return_dict[u'Output Modules'] = self._GetOutputModulesInformation() | |
103 return_dict[u'Filters'] = self._GetFiltersInformation() | |
104 | |
105 return return_dict | |
OLD | NEW |