forked from log2timeline/plaso
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code review: 240160044: Moving output modules to use argument helpers…
…, re-factor of psort into tools/frontend and bugfixes
- Loading branch information
1 parent
9cf3fda
commit 23991d2
Showing
47 changed files
with
1,274 additions
and
501 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ python-plaso (1.2.1-1) unstable; urgency=low | |
|
||
* Auto-generated | ||
|
||
-- Log2Timeline <[email protected]> Wed, 03 Jun 2015 20:43:58 +0200 | ||
-- Log2Timeline <[email protected]> Wed, 03 Jun 2015 12:12:02 -0700 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# -*- coding: utf-8 -*- | ||
"""The arguments helper for a database configuration.""" | ||
|
||
from plaso.lib import errors | ||
from plaso.cli.helpers import interface | ||
from plaso.cli.helpers import server_config | ||
|
||
|
||
class DatabaseConfigHelper(interface.ArgumentsHelper): | ||
"""CLI arguments helper class for database configuration.""" | ||
|
||
NAME = u'database_config' | ||
DESCRIPTION = u'Argument helper for a database configuration.' | ||
|
||
_DEFAULT_NAME = u'data' | ||
_DEFAULT_PASSWORD = u'toor' | ||
_DEFAULT_USERNAME = u'root' | ||
|
||
@classmethod | ||
def AddArguments(cls, argument_group): | ||
"""Add command line arguments the helper supports to an argument group. | ||
This function takes an argument parser or an argument group object and adds | ||
to it all the command line arguments this helper supports. | ||
Args: | ||
argument_group: the argparse group (instance of argparse._ArgumentGroup or | ||
or argparse.ArgumentParser). | ||
""" | ||
argument_group.add_argument( | ||
u'--user', dest=u'username', type=unicode, action=u'store', | ||
default=None, metavar=u'USERNAME', required=False, help=( | ||
u'The username used to connect to the database.')) | ||
argument_group.add_argument( | ||
u'--password', dest=u'password', type=unicode, action=u'store', | ||
default=None, metavar=u'PASSWORD', help=( | ||
u'The password for the database user.')) | ||
argument_group.add_argument( | ||
u'--db_name', '--db-name', dest=u'db_name', action=u'store', | ||
type=unicode, default=None, required=False, help=( | ||
u'The name of the database to connect to.')) | ||
|
||
server_config.BaseServerConfigHelper.AddArguments(argument_group) | ||
|
||
@classmethod | ||
def ParseOptions(cls, options, output_module): | ||
"""Parses and validates options. | ||
Args: | ||
options: the parser option object (instance of argparse.Namespace). | ||
output_module: an output module (instance of OutputModule). | ||
Raises: | ||
BadConfigObject: when the output module object is of the wrong type. | ||
BadConfigOption: when a configuration parameter fails validation. | ||
""" | ||
if not hasattr(output_module, u'SetCredentials'): | ||
raise errors.BadConfigObject(u'Unable to set username information.') | ||
|
||
username = getattr(options, u'username', None) | ||
if not username: | ||
username = cls._DEFAULT_USERNAME | ||
|
||
password = getattr(options, u'password', None) | ||
if not password: | ||
password = cls._DEFAULT_PASSWORD | ||
|
||
name = getattr(options, u'db_name', None) | ||
if not name: | ||
name = cls._DEFAULT_NAME | ||
|
||
output_module.SetCredentials( | ||
username=username, password=password) | ||
output_module.SetDatabaseName(name) | ||
server_config.BaseServerConfigHelper.ParseOptions(options, output_module) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# -*- coding: utf-8 -*- | ||
"""The arguments helper for the 4n6time MySQL database output module.""" | ||
|
||
from plaso.lib import errors | ||
from plaso.cli.helpers import interface | ||
from plaso.cli.helpers import database_config | ||
from plaso.cli.helpers import shared_4n6time_output | ||
from plaso.cli.helpers import manager | ||
from plaso.output import mysql_4n6time | ||
|
||
|
||
class MySQL4n6TimeHelper(database_config.DatabaseConfigHelper): | ||
"""CLI argument helper for a 4n6Time MySQL database server.""" | ||
|
||
_DEFAULT_USERNAME = u'root' | ||
_DEFAULT_PASSWORD = u'forensic' | ||
|
||
|
||
class MySQL4n6TimeOutputHelper(interface.ArgumentsHelper): | ||
"""CLI arguments helper class for a MySQL 4n6time output module.""" | ||
|
||
NAME = u'4n6time_mysql' | ||
CATEGORY = u'output' | ||
DESCRIPTION = u'Argument helper for the 4n6Time MySQL output module.' | ||
|
||
@classmethod | ||
def AddArguments(cls, argument_group): | ||
"""Add command line arguments the helper supports to an argument group. | ||
This function takes an argument parser or an argument group object and adds | ||
to it all the command line arguments this helper supports. | ||
Args: | ||
argument_group: the argparse group (instance of argparse._ArgumentGroup or | ||
or argparse.ArgumentParser). | ||
""" | ||
shared_4n6time_output.Shared4n6TimeOutputHelper.AddArguments(argument_group) | ||
MySQL4n6TimeHelper.AddArguments(argument_group) | ||
|
||
@classmethod | ||
def ParseOptions(cls, options, output_module): | ||
"""Parses and validates options. | ||
Args: | ||
options: the parser option object (instance of argparse.Namespace). | ||
output_module: an output module (instance of OutputModule). | ||
Raises: | ||
BadConfigObject: when the output module object is of the wrong type. | ||
BadConfigOption: when a configuration parameter fails validation. | ||
""" | ||
if not isinstance(output_module, mysql_4n6time.MySQL4n6TimeOutputModule): | ||
raise errors.BadConfigObject( | ||
u'Output module is not an instance of MySQL4n6TimeOutputModule') | ||
|
||
MySQL4n6TimeHelper.ParseOptions(options, output_module) | ||
shared_4n6time_output.Shared4n6TimeOutputHelper.ParseOptions( | ||
options, output_module) | ||
|
||
|
||
manager.ArgumentHelperManager.RegisterHelper(MySQL4n6TimeOutputHelper) |
Oops, something went wrong.