| | 1 | ####################################################################### |
|---|
| | 2 | # Created on: Jan 25, 2008 |
|---|
| | 3 | # Package: HoneyClient::Manager::Database |
|---|
| | 4 | # File: Database.pm |
|---|
| | 5 | # Description: XML-RPC client interface to access HoneyClient data within |
|---|
| | 6 | # the Hive web service. |
|---|
| | 7 | # |
|---|
| | 8 | # CVS: $Id: Database.pm 994 2007-11-08 20:30:12Z kindlund $ |
|---|
| | 9 | # |
|---|
| | 10 | # @author mbriggs, kindlund |
|---|
| | 11 | # |
|---|
| | 12 | # Copyright (C) 2008 The MITRE Corporation. All rights reserved. |
|---|
| | 13 | # |
|---|
| | 14 | # This program is free software; you can redistribute it and/or |
|---|
| | 15 | # modify it under the terms of the GNU General Public License |
|---|
| | 16 | # as published by the Free Software Foundation, using version 2 |
|---|
| | 17 | # of the License. |
|---|
| | 18 | # |
|---|
| | 19 | # This program is distributed in the hope that it will be useful, |
|---|
| | 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| | 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| | 22 | # GNU General Public License for more details. |
|---|
| | 23 | # |
|---|
| | 24 | # You should have received a copy of the GNU General Public License |
|---|
| | 25 | # along with this program; if not, write to the Free Software |
|---|
| | 26 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|---|
| | 27 | # 02110-1301, USA. |
|---|
| | 28 | # |
|---|
| | 29 | ####################################################################### |
|---|
| | 30 | |
|---|
| | 31 | =pod |
|---|
| | 32 | |
|---|
| | 33 | =head1 NAME |
|---|
| | 34 | |
|---|
| | 35 | HoneyClient::Manager::Database - Perl extension to provide an abstract |
|---|
| | 36 | interface for storing/accessing HoneyClient within the Hive web service. |
|---|
| | 37 | |
|---|
| | 38 | =head1 VERSION |
|---|
| | 39 | |
|---|
| | 40 | This documentation refers to HoneyClient::Manager::Database version 1.00. |
|---|
| | 41 | |
|---|
| | 42 | =head1 SYNOPSIS |
|---|
| | 43 | |
|---|
| | 44 | # XXX: Need to fill this in. |
|---|
| | 45 | |
|---|
| | 46 | =head1 DESCRIPTION |
|---|
| | 47 | |
|---|
| | 48 | This library is an abstract interface to access and store HoneyClient |
|---|
| | 49 | data within the Hive web service. |
|---|
| | 50 | |
|---|
| | 51 | # XXX: Need further descriptions. |
|---|
| | 52 | |
|---|
| | 53 | =cut |
|---|
| | 54 | |
|---|
| | 55 | package HoneyClient::Manager::Database; |
|---|
| | 56 | |
|---|
| 2 | | |
|---|
| | 58 | use warnings; |
|---|
| | 59 | use Carp (); |
|---|
| | 60 | |
|---|
| | 61 | ####################################################################### |
|---|
| | 62 | # Module Initialization # |
|---|
| | 63 | ####################################################################### |
|---|
| | 64 | |
|---|
| | 65 | BEGIN { |
|---|
| | 66 | # Defines which functions can be called externally. |
|---|
| | 67 | require Exporter; |
|---|
| | 68 | our (@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION); |
|---|
| | 69 | |
|---|
| | 70 | # Set our package version. |
|---|
| | 71 | $VERSION = 1.00; |
|---|
| | 72 | |
|---|
| | 73 | @ISA = qw(Exporter); |
|---|
| | 74 | |
|---|
| | 75 | # Symbols to export automatically |
|---|
| | 76 | # Note: Since this module is object-oriented, we do *NOT* export |
|---|
| | 77 | # any functions other than "new" to call statically. Each function |
|---|
| | 78 | # for this module *must* be called as a method from a unique |
|---|
| | 79 | # object instance. |
|---|
| | 80 | @EXPORT = qw(); |
|---|
| | 81 | |
|---|
| | 82 | # Items to export into callers namespace by default. Note: do not export |
|---|
| | 83 | # names by default without a very good reason. Use EXPORT_OK instead. |
|---|
| | 84 | # Do not simply export all your public functions/methods/constants. |
|---|
| | 85 | |
|---|
| | 86 | # This allows declaration use HoneyClient::Manager::Database ':all'; |
|---|
| | 87 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
|---|
| | 88 | # will save memory. |
|---|
| | 89 | |
|---|
| | 90 | # Note: Since this module is object-oriented, we do *NOT* export |
|---|
| | 91 | # any functions other than "new" to call statically. Each function |
|---|
| | 92 | # for this module *must* be called as a method from a unique |
|---|
| | 93 | # object instance. |
|---|
| | 94 | %EXPORT_TAGS = ( |
|---|
| | 95 | 'all' => [ qw() ], |
|---|
| | 96 | ); |
|---|
| | 97 | |
|---|
| | 98 | # Symbols to autoexport (when qw(:all) tag is used) |
|---|
| | 99 | @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
|---|
| | 100 | |
|---|
| | 101 | $SIG{PIPE} = 'IGNORE'; # Do not exit on broken pipes. |
|---|
| | 102 | } |
|---|
| | 103 | our (@EXPORT_OK, $VERSION); |
|---|
| | 104 | |
|---|
| | 105 | =pod |
|---|
| | 106 | |
|---|
| | 107 | =begin testing |
|---|
| | 108 | |
|---|
| | 109 | # Make sure Log::Log4perl loads |
|---|
| | 110 | BEGIN { use_ok('Log::Log4perl', qw(:nowarn)) |
|---|
| | 111 | or diag("Can't load Log::Log4perl package. Check to make sure the package library is correctly listed within the path."); |
|---|
| | 112 | |
|---|
| | 113 | # Suppress all logging messages, since we need clean output for unit testing. |
|---|
| | 114 | Log::Log4perl->init({ |
|---|
| | 115 | "log4perl.rootLogger" => "DEBUG, Buffer", |
|---|
| | 116 | "log4perl.appender.Buffer" => "Log::Log4perl::Appender::TestBuffer", |
|---|
| | 117 | "log4perl.appender.Buffer.min_level" => "fatal", |
|---|
| | 118 | "log4perl.appender.Buffer.layout" => "Log::Log4perl::Layout::PatternLayout", |
|---|
| | 119 | "log4perl.appender.Buffer.layout.ConversionPattern" => "%d{yyyy-MM-dd HH:mm:ss} %5p [%M] (%F:%L) - %m%n", |
|---|
| | 120 | }); |
|---|
| | 121 | } |
|---|
| | 122 | require_ok('Log::Log4perl'); |
|---|
| | 123 | use Log::Log4perl qw(:easy); |
|---|
| | 124 | |
|---|
| | 125 | # Make sure HoneyClient::Util::Config loads. |
|---|
| | 126 | BEGIN { use_ok('HoneyClient::Util::Config', qw(getVar)) |
|---|
| | 127 | or diag("Can't load HoneyClient::Util::Config package. Check to make sure the package library is correctly listed within the path."); |
|---|
| | 128 | |
|---|
| | 129 | # Suppress all logging messages, since we need clean output for unit testing. |
|---|
| | 130 | Log::Log4perl->init({ |
|---|
| | 131 | "log4perl.rootLogger" => "DEBUG, Buffer", |
|---|
| | 132 | "log4perl.appender.Buffer" => "Log::Log4perl::Appender::TestBuffer", |
|---|
| | 133 | "log4perl.appender.Buffer.min_level" => "fatal", |
|---|
| | 134 | "log4perl.appender.Buffer.layout" => "Log::Log4perl::Layout::PatternLayout", |
|---|
| | 135 | "log4perl.appender.Buffer.layout.ConversionPattern" => "%d{yyyy-MM-dd HH:mm:ss} %5p [%M] (%F:%L) - %m%n", |
|---|
| | 136 | }); |
|---|
| | 137 | |
|---|
| | 138 | } |
|---|
| | 139 | require_ok('HoneyClient::Util::Config'); |
|---|
| | 140 | can_ok('HoneyClient::Util::Config', 'getVar'); |
|---|
| | 141 | use HoneyClient::Util::Config qw(getVar); |
|---|
| | 142 | |
|---|
| | 143 | # Make sure the module loads properly, with the exportable |
|---|
| | 144 | # functions shared. |
|---|
| | 145 | BEGIN { use_ok('HoneyClient::Manager::Database') or diag("Can't load HoneyClient::Manager::Database package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| | 146 | require_ok('HoneyClient::Manager::Database'); |
|---|
| | 147 | use HoneyClient::Manager::Database; |
|---|
| | 148 | |
|---|
| | 149 | # Suppress all logging messages, since we need clean output for unit testing. |
|---|
| | 150 | Log::Log4perl->init({ |
|---|
| | 151 | "log4perl.rootLogger" => "DEBUG, Buffer", |
|---|
| | 152 | "log4perl.appender.Buffer" => "Log::Log4perl::Appender::TestBuffer", |
|---|
| | 153 | "log4perl.appender.Buffer.min_level" => "fatal", |
|---|
| | 154 | "log4perl.appender.Buffer.layout" => "Log::Log4perl::Layout::PatternLayout", |
|---|
| | 155 | "log4perl.appender.Buffer.layout.ConversionPattern" => "%d{yyyy-MM-dd HH:mm:ss} %5p [%M] (%F:%L) - %m%n", |
|---|
| | 156 | }); |
|---|
| | 157 | |
|---|
| | 158 | # Make sure we use the exception testing library. |
|---|
| | 159 | require_ok('Test::Exception'); |
|---|
| | 160 | can_ok('Test::Exception', 'dies_ok'); |
|---|
| | 161 | use Test::Exception; |
|---|
| | 162 | |
|---|
| | 163 | # Make sure YAML loads. |
|---|
| | 164 | BEGIN { use_ok('YAML') or diag("Can't load YAML package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| | 165 | require_ok('YAML'); |
|---|
| | 208 | # Include Logging Library |
|---|
| | 209 | use Log::Log4perl qw(:easy); |
|---|
| | 210 | |
|---|
| | 211 | # The global logging object. |
|---|
| | 212 | our $LOG = get_logger(); |
|---|
| | 213 | |
|---|
| | 214 | ####################################################################### |
|---|
| | 215 | # Public Methods Implemented # |
|---|
| | 216 | ####################################################################### |
|---|
| | 217 | |
|---|
| | 218 | # Helper function designed to programmatically call the Hive web service, |
|---|
| | 219 | # based upon arbitrary inputs given. |
|---|
| | 220 | # |
|---|
| | 221 | # For example, this call: |
|---|
| | 222 | # my $output = HoneyClient::Manager::Database::foo($bar); |
|---|
| | 223 | # |
|---|
| | 224 | # ... will contact the Hive web service using the "foo" function name |
|---|
| | 225 | # and supply the hashtable reference, specified by $bar. |
|---|
| | 226 | # |
|---|
| | 227 | # Note: Errors generated by the web service call will be propagated back |
|---|
| | 228 | # in the form of croaked exceptions. |
|---|
| | 229 | # |
|---|
| | 230 | # Inputs: the hashtable or object to send |
|---|
| | 231 | # Outputs: the returned data from the web service |
|---|
| | 255 | |
|---|
| | 256 | ####################################################################### |
|---|
| | 257 | # Additional Module Documentation # |
|---|
| | 258 | ####################################################################### |
|---|
| | 259 | |
|---|
| | 260 | __END__ |
|---|
| | 261 | |
|---|
| | 262 | =head1 BUGS & ASSUMPTIONS |
|---|
| | 263 | |
|---|
| | 264 | # XXX: Fill this in. |
|---|
| | 265 | |
|---|
| | 266 | =head1 SEE ALSO |
|---|
| | 267 | |
|---|
| | 268 | L<perltoot/"Autoloaded Data Methods"> |
|---|
| | 269 | |
|---|
| | 270 | L<http://www.honeyclient.org/trac> |
|---|
| | 271 | |
|---|
| | 272 | =head1 REPORTING BUGS |
|---|
| | 273 | |
|---|
| | 274 | L<http://www.honeyclient.org/trac/newticket> |
|---|
| | 275 | |
|---|
| | 276 | =head1 AUTHORS |
|---|
| | 277 | |
|---|
| | 278 | Matt Briggs, E<lt>mbriggs@mitre.orgE<gt> |
|---|
| | 279 | |
|---|
| | 280 | Darien Kindlund, E<lt>kindlund@mitre.orgE<gt> |
|---|
| | 281 | |
|---|
| | 282 | =head1 COPYRIGHT & LICENSE |
|---|
| | 283 | |
|---|
| | 284 | Copyright (C) 2008 The MITRE Corporation. All rights reserved. |
|---|
| | 285 | |
|---|
| | 286 | This program is free software; you can redistribute it and/or |
|---|
| | 287 | modify it under the terms of the GNU General Public License |
|---|
| | 288 | as published by the Free Software Foundation, using version 2 |
|---|
| | 289 | of the License. |
|---|
| | 290 | |
|---|
| | 291 | This program is distributed in the hope that it will be useful, |
|---|
| | 292 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| | 293 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| | 294 | GNU General Public License for more details. |
|---|
| | 295 | |
|---|
| | 296 | You should have received a copy of the GNU General Public License |
|---|
| | 297 | along with this program; if not, write to the Free Software |
|---|
| | 298 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|---|
| | 299 | 02110-1301, USA. |
|---|
| | 300 | |
|---|
| | 301 | |
|---|
| | 302 | =cut |
|---|