Changeset 722

Show
Ignore:
Timestamp:
07/20/07 18:27:19 (1 year ago)
Author:
kindlund
Message:

Added OO-type sanity checks to all methods.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeyclient/branches/exp/kindlund-firefox/etc/honeyclient.xml

    r717 r722  
    126126                <IE> 
    127127                    <!-- HoneyClient::Agent::Driver::Browser::IE Options --> 
    128                     <!-- TODO: Update this. --> 
    129128                    <process_exec description="The absolute path to the Internet Explorer application process, as it sits in the VM filesystem." default="C:\Program Files\Internet Explorer\iexplore.exe"> 
    130129                        C:\Program Files\Internet Explorer\iexplore.exe 
    131130                    </process_exec> 
     131                    <process_name description="The name of the Internet Explorer executable, as it appears on the VM filesystem." default="iexplore.exe"> 
     132                        iexplore.exe 
     133                    </process_name> 
    132134                </IE> 
    133135                <FF> 
     
    136138                        C:\Program Files\Mozilla Firefox\firefox.exe 
    137139                    </process_exec> 
     140                    <process_name description="The name of the Mozilla Firefox executable, as it appears on the VM filesystem." default="firefox.exe"> 
     141                        firefox.exe 
     142                    </process_name> 
    138143                </FF> 
    139144            </Browser> 
  • honeyclient/branches/exp/kindlund-firefox/lib/HoneyClient/Agent/Driver.pm

    r615 r722  
    306306 
    307307    # Sanity check: Make sure the supplied value is an object. 
    308     my $type = ref($self) or Carp::croak "Error: $self is not an object!\n"; 
     308    my $type = ref($self); 
     309    unless(defined($type)) { 
     310        $LOG->error("Error: $self is not an object!"); 
     311        Carp::croak "Error: $self is not an object!\n"; 
     312    } 
    309313 
    310314    # Now, get the name of the function. 
  • honeyclient/branches/exp/kindlund-firefox/lib/HoneyClient/Agent/Driver/Browser.pm

    r696 r722  
    625625# hashtable.  The link with the highest score is returned. 
    626626# 
    627 # 
    628 # 
    629627# Inputs: hashref 
    630628# Outputs: valid key, or undef if the hash is empty 
     
    828826} 
    829827 
     828# XXX: Is this really needed? 
    830829# Helper function designed to kill all instances of the driven 
    831830# application. 
     
    848847 
    849848    if (!$som->result) { 
     849        $LOG->warn("Failed to kill process: '" . $self->process_name . "'!"); 
    850850        Carp::carp "Failed to kill process: '" . $self->process_name . "'!\n"; 
    851851    } 
     
    986986    # Sanity check: Make sure we've been fed an object. 
    987987    unless (ref($self)) { 
     988        $LOG->error("Error: Function must be called in reference to a " . 
     989                    __PACKAGE__ . "->new() object!"); 
    988990        Carp::croak "Error: Function must be called in reference to a " . 
    989991                    __PACKAGE__ . "->new() object!\n"; 
     
    10021004    # Sanity check: Make sure our next URL is defined. 
    10031005    unless (defined($args{'url'})) { 
    1004         Carp::croak "Error: Unable to drive browser - 'links_to_visit' " . 
    1005                     "hashtable is empty!\n"; 
     1006        $LOG->error("Error: Unable to drive browser - no links left to browse!"); 
     1007        Carp::croak "Error: Unable to drive browser - no links left to browse!\n"; 
    10061008    } 
    10071009 
     
    11521154    # Sanity check: Make sure we've been fed an object. 
    11531155    unless (ref($self)) { 
     1156        $LOG->error("Error: Function must be called in reference to a " . 
     1157                    __PACKAGE__ . "->new() object!"); 
    11541158        Carp::croak "Error: Function must be called in reference to a " . 
    11551159                    __PACKAGE__ . "->new() object!\n"; 
     
    12481252    # Sanity check: Make sure we've been fed an object. 
    12491253    unless (ref($self)) { 
     1254        $LOG->error("Error: Function must be called in reference to a " . 
     1255                    __PACKAGE__ . "->new() object!"); 
    12501256        Carp::croak "Error: Function must be called in reference to a " . 
    12511257                    __PACKAGE__ . "->new() object!\n"; 
     
    15911597    # Sanity check: Make sure we've been fed an object. 
    15921598    unless (ref($self)) { 
     1599        $LOG->error("Error: Function must be called in reference to a " . 
     1600                    __PACKAGE__ . "->new() object!"); 
    15931601        Carp::croak "Error: Function must be called in reference to a " . 
    15941602                    __PACKAGE__ . "->new() object!\n"; 
     
    16541662    # Sanity check: Make sure we've been fed an object. 
    16551663    unless (ref($self)) { 
     1664        $LOG->error("Error: Function must be called in reference to a " . 
     1665                    __PACKAGE__ . "->new() object!"); 
    16561666        Carp::croak "Error: Function must be called in reference to a " . 
    16571667                    __PACKAGE__ . "->new() object!\n"; 
  • honeyclient/branches/exp/kindlund-firefox/lib/HoneyClient/Agent/Driver/Browser/FF.pm

    r707 r722  
    190190    # Sanity check: Make sure we've been fed an object. 
    191191    unless (ref($self)) { 
     192        $LOG->error("Error: Function must be called in reference to a " . 
     193                    __PACKAGE__ . "->new() object!"); 
    192194        Carp::croak "Error: Function must be called in reference to a " . 
    193195                    __PACKAGE__ . "->new() object!\n"; 
     
    209211    # Sanity check: Make sure our next URL is defined. 
    210212    unless (defined($args{'url'})) { 
    211         Carp::croak "Error: Unable to drive browser - 'links_to_visit' " . 
    212                     "hashtable is empty!\n"; 
     213        $LOG->error("Error: Unable to drive browser - no links left to browse!"); 
     214        Carp::croak "Error: Unable to drive browser - no links left to browse!\n"; 
    213215    } 
    214216 
     
    222224    # Sanity check. 
    223225    if (!defined($job)) { 
     226        $LOG->error("Error: Unable to spawn new job - " . $^E . "."); 
    224227        Carp::croak "Error: Unable to spawn new job - " . $^E . ".\n"; 
    225228    } 
  • honeyclient/branches/exp/kindlund-firefox/lib/HoneyClient/Agent/Driver/Browser/IE.pm

    r605 r722  
    211211    # Sanity check: Make sure we've been fed an object. 
    212212    unless (ref($self)) { 
     213        $LOG->error("Error: Function must be called in reference to a " . 
     214                    __PACKAGE__ . "->new() object!"); 
    213215        Carp::croak "Error: Function must be called in reference to a " . 
    214216                    __PACKAGE__ . "->new() object!\n"; 
     
    227229    # Drive the generic browser before opening with IE 
    228230    $self = $self->SUPER::drive(%args); 
    229  
     231     
    230232    # Sanity check: Make sure our next URL is defined. 
    231233    unless (defined($args{'url'})) { 
    232         Carp::croak "Error: Unable to drive browser - 'links_to_visit' " . 
    233                     "hashtable is empty!\n"; 
     234        $LOG->error("Error: Unable to drive browser - no links left to browse!"); 
     235        Carp::croak "Error: Unable to drive browser - no links left to browse!\n"; 
    234236    } 
    235237 
     
    243245    # Sanity check. 
    244246    if (!defined($job)) { 
     247        $LOG->error("Error: Unable to spawn new job - " . $^E . "."); 
    245248        Carp::croak "Error: Unable to spawn new job - " . $^E . ".\n"; 
    246249    } 
  • honeyclient/branches/exp/kindlund-firefox/lib/HoneyClient/Agent/Integrity.pm

    r605 r722  
    534534    my ($self, %args) = @_; 
    535535 
     536    # Sanity check: Make sure we've been fed an object. 
     537    unless (ref($self)) { 
     538        $LOG->error("Error: Function must be called in reference to a " . 
     539                    __PACKAGE__ . "->new() object!"); 
     540        Carp::croak "Error: Function must be called in reference to a " . 
     541                    __PACKAGE__ . "->new() object!\n"; 
     542    } 
     543 
    536544    # Log resolved arguments. 
    537545    $LOG->debug(sub { 
     
    568576    my $self = shift; 
    569577 
     578    # Sanity check: Make sure we've been fed an object. 
     579    unless (ref($self)) { 
     580        $LOG->error("Error: Function must be called in reference to a " . 
     581                    __PACKAGE__ . "->new() object!"); 
     582        Carp::croak "Error: Function must be called in reference to a " . 
     583                    __PACKAGE__ . "->new() object!\n"; 
     584    } 
     585 
    570586    if (defined($self->{'_registry'})) { 
    571587        $self->{'_registry'}->closeFiles(); 
     
    576592sub destroy { 
    577593    my $self = shift; 
     594 
     595    # Sanity check: Make sure we've been fed an object. 
     596    unless (ref($self)) { 
     597        $LOG->error("Error: Function must be called in reference to a " . 
     598                    __PACKAGE__ . "->new() object!"); 
     599        Carp::croak "Error: Function must be called in reference to a " . 
     600                    __PACKAGE__ . "->new() object!\n"; 
     601    } 
    578602 
    579603    if (defined($self->{'_registry'})) { 
  • honeyclient/branches/exp/kindlund-firefox/lib/HoneyClient/Agent/Integrity/Filesystem.pm

    r605 r722  
    13701370    my ($self, %args) = @_; 
    13711371 
     1372    # Sanity check: Make sure we've been fed an object. 
     1373    unless (ref($self)) { 
     1374        $LOG->error("Error: Function must be called in reference to a " . 
     1375                    __PACKAGE__ . "->new() object!"); 
     1376        Carp::croak "Error: Function must be called in reference to a " . 
     1377                    __PACKAGE__ . "->new() object!\n"; 
     1378    } 
     1379 
    13721380    # Log resolved arguments. 
    13731381    $LOG->debug(sub { 
  • honeyclient/branches/exp/kindlund-firefox/lib/HoneyClient/Agent/Integrity/Registry.pm

    r605 r722  
    411411    # Extract arguments. 
    412412    my $self = shift; 
     413 
     414    # Sanity check: Make sure we've been fed an object. 
     415    unless (ref($self)) { 
     416        $LOG->error("Error: Function must be called in reference to a " . 
     417                    __PACKAGE__ . "->new() object!"); 
     418        Carp::croak "Error: Function must be called in reference to a " . 
     419                    __PACKAGE__ . "->new() object!\n"; 
     420    } 
    413421 
    414422    # Delete any temporary files created by the baseline 
     
    14711479    my ($self, %args) = @_; 
    14721480 
     1481    # Sanity check: Make sure we've been fed an object. 
     1482    unless (ref($self)) { 
     1483        $LOG->error("Error: Function must be called in reference to a " . 
     1484                    __PACKAGE__ . "->new() object!"); 
     1485        Carp::croak "Error: Function must be called in reference to a " . 
     1486                    __PACKAGE__ . "->new() object!\n"; 
     1487    } 
     1488 
    14731489    # Log resolved arguments. 
    14741490    $LOG->debug(sub { 
     
    15841600    # Extract arguments. 
    15851601    my ($self, %args) = @_; 
     1602 
     1603    # Sanity check: Make sure we've been fed an object. 
     1604    unless (ref($self)) { 
     1605        $LOG->error("Error: Function must be called in reference to a " . 
     1606                    __PACKAGE__ . "->new() object!"); 
     1607        Carp::croak "Error: Function must be called in reference to a " . 
     1608                    __PACKAGE__ . "->new() object!\n"; 
     1609    } 
    15861610 
    15871611    # Log resolved arguments. 
     
    16391663    my ($self, %args) = @_; 
    16401664 
     1665    # Sanity check: Make sure we've been fed an object. 
     1666    unless (ref($self)) { 
     1667        $LOG->error("Error: Function must be called in reference to a " . 
     1668                    __PACKAGE__ . "->new() object!"); 
     1669        Carp::croak "Error: Function must be called in reference to a " . 
     1670                    __PACKAGE__ . "->new() object!\n"; 
     1671    } 
     1672 
    16411673    # Log resolved arguments. 
    16421674    $LOG->debug(sub { 
  • honeyclient/branches/exp/kindlund-firefox/lib/HoneyClient/Agent/Integrity/Registry/Parser.pm

    r605 r722  
    781781    my ($self, %args) = @_; 
    782782 
     783    # Sanity check: Make sure we've been fed an object. 
     784    unless (ref($self)) { 
     785        $LOG->error("Error: Function must be called in reference to a " . 
     786                    __PACKAGE__ . "->new() object!"); 
     787        Carp::croak "Error: Function must be called in reference to a " . 
     788                    __PACKAGE__ . "->new() object!\n"; 
     789    } 
     790 
    783791    # Log resolved arguments. 
    784792    $LOG->debug(sub { 
     
    10191027    my ($self, %args) = @_; 
    10201028 
     1029    # Sanity check: Make sure we've been fed an object. 
     1030    unless (ref($self)) { 
     1031        $LOG->error("Error: Function must be called in reference to a " . 
     1032                    __PACKAGE__ . "->new() object!"); 
     1033        Carp::croak "Error: Function must be called in reference to a " . 
     1034                    __PACKAGE__ . "->new() object!\n"; 
     1035    } 
     1036 
    10211037    # Log resolved arguments. 
    10221038    $LOG->debug(sub { 
     
    10851101    # Extract arguments. 
    10861102    my ($self, %args) = @_; 
     1103 
     1104    # Sanity check: Make sure we've been fed an object. 
     1105    unless (ref($self)) { 
     1106        $LOG->error("Error: Function must be called in reference to a " . 
     1107                    __PACKAGE__ . "->new() object!"); 
     1108        Carp::croak "Error: Function must be called in reference to a " . 
     1109                    __PACKAGE__ . "->new() object!\n"; 
     1110    } 
    10871111     
    10881112    # Log resolved arguments. 
     
    11351159    my ($self, %args) = @_; 
    11361160 
     1161    # Sanity check: Make sure we've been fed an object. 
     1162    unless (ref($self)) { 
     1163        $LOG->error("Error: Function must be called in reference to a " . 
     1164                    __PACKAGE__ . "->new() object!"); 
     1165        Carp::croak "Error: Function must be called in reference to a " . 
     1166                    __PACKAGE__ . "->new() object!\n"; 
     1167    } 
     1168 
    11371169    # Log resolved arguments. 
    11381170    $LOG->debug(sub { 
     
    11791211    my ($self, %args) = @_; 
    11801212 
     1213    # Sanity check: Make sure we've been fed an object. 
     1214    unless (ref($self)) { 
     1215        $LOG->error("Error: Function must be called in reference to a " . 
     1216                    __PACKAGE__ . "->new() object!"); 
     1217        Carp::croak "Error: Function must be called in reference to a " . 
     1218                    __PACKAGE__ . "->new() object!\n"; 
     1219    } 
     1220 
    11811221    # Log resolved arguments. 
    11821222    $LOG->debug(sub { 
     
    12221262    # Extract arguments. 
    12231263    my ($self, %args) = @_; 
     1264 
     1265    # Sanity check: Make sure we've been fed an object. 
     1266    unless (ref($self)) { 
     1267        $LOG->error("Error: Function must be called in reference to a " . 
     1268                    __PACKAGE__ . "->new() object!"); 
     1269        Carp::croak "Error: Function must be called in reference to a " . 
     1270                    __PACKAGE__ . "->new() object!\n"; 
     1271    } 
    12241272 
    12251273    # Log resolved arguments. 
     
    12761324    my ($self, %args) = @_; 
    12771325 
     1326    # Sanity check: Make sure we've been fed an object. 
     1327    unless (ref($self)) { 
     1328        $LOG->error("Error: Function must be called in reference to a " . 
     1329                    __PACKAGE__ . "->new() object!"); 
     1330        Carp::croak "Error: Function must be called in reference to a " . 
     1331                    __PACKAGE__ . "->new() object!\n"; 
     1332    } 
     1333 
    12781334    # Log resolved arguments. 
    12791335    $LOG->debug(sub { 
     
    13251381    # Extract arguments. 
    13261382    my ($self, %args) = @_; 
     1383 
     1384    # Sanity check: Make sure we've been fed an object. 
     1385    unless (ref($self)) { 
     1386        $LOG->error("Error: Function must be called in reference to a " . 
     1387                    __PACKAGE__ . "->new() object!"); 
     1388        Carp::croak "Error: Function must be called in reference to a " . 
     1389                    __PACKAGE__ . "->new() object!\n"; 
     1390    } 
    13271391 
    13281392    # Log resolved arguments. 
     
    14861550    my ($self, %args) = @_; 
    14871551 
     1552    # Sanity check: Make sure we've been fed an object. 
     1553    unless (ref($self)) { 
     1554        $LOG->error("Error: Function must be called in reference to a " . 
     1555                    __PACKAGE__ . "->new() object!"); 
     1556        Carp::croak "Error: Function must be called in reference to a " . 
     1557                    __PACKAGE__ . "->new() object!\n"; 
     1558    } 
     1559 
    14881560    # Log resolved arguments. 
    14891561    $LOG->debug(sub { 
  • honeyclient/branches/exp/kindlund-firefox/lib/HoneyClient/Agent/Integrity/Registry/Parser.yp

    r605 r722  
    626626    my ($self, %args) = @_; 
    627627 
     628    # Sanity check: Make sure we've been fed an object. 
     629    unless (ref($self)) { 
     630        $LOG->error("Error: Function must be called in reference to a " . 
     631                    __PACKAGE__ . "->new() object!"); 
     632        Carp::croak "Error: Function must be called in reference to a " . 
     633                    __PACKAGE__ . "->new() object!\n"; 
     634    } 
     635 
    628636    # Log resolved arguments. 
    629637    $LOG->debug(sub { 
     
    864872    my ($self, %args) = @_; 
    865873 
     874    # Sanity check: Make sure we've been fed an object. 
     875    unless (ref($self)) { 
     876        $LOG->error("Error: Function must be called in reference to a " . 
     877                    __PACKAGE__ . "->new() object!"); 
     878        Carp::croak "Error: Function must be called in reference to a " . 
     879                    __PACKAGE__ . "->new() object!\n"; 
     880    } 
     881 
    866882    # Log resolved arguments. 
    867883    $LOG->debug(sub { 
     
    930946    # Extract arguments. 
    931947    my ($self, %args) = @_; 
     948 
     949    # Sanity check: Make sure we've been fed an object. 
     950    unless (ref($self)) { 
     951        $LOG->error("Error: Function must be called in reference to a " . 
     952                    __PACKAGE__ . "->new() object!"); 
     953        Carp::croak "Error: Function must be called in reference to a " . 
     954                    __PACKAGE__ . "->new() object!\n"; 
     955    } 
    932956     
    933957    # Log resolved arguments. 
     
    9801004    my ($self, %args) = @_; 
    9811005 
     1006    # Sanity check: Make sure we've been fed an object. 
     1007    unless (ref($self)) { 
     1008        $LOG->error("Error: Function must be called in reference to a " . 
     1009                    __PACKAGE__ . "->new() object!"); 
     1010        Carp::croak "Error: Function must be called in reference to a " . 
     1011                    __PACKAGE__ . "->new() object!\n"; 
     1012    } 
     1013 
    9821014    # Log resolved arguments. 
    9831015    $LOG->debug(sub { 
     
    10241056    my ($self, %args) = @_; 
    10251057 
     1058    # Sanity check: Make sure we've been fed an object. 
     1059    unless (ref($self)) { 
     1060        $LOG->error("Error: Function must be called in reference to a " . 
     1061                    __PACKAGE__ . "->new() object!"); 
     1062        Carp::croak "Error: Function must be called in reference to a " . 
     1063                    __PACKAGE__ . "->new() object!\n"; 
     1064    } 
     1065 
    10261066    # Log resolved arguments. 
    10271067    $LOG->debug(sub { 
     
    10681108    my ($self, %args) = @_; 
    10691109 
     1110    # Sanity check: Make sure we've been fed an object. 
     1111    unless (ref($self)) { 
     1112        $LOG->error("Error: Function must be called in reference to a " . 
     1113                    __PACKAGE__ . "->new() object!"); 
     1114        Carp::croak "Error: Function must be called in reference to a " . 
     1115                    __PACKAGE__ . "->new() object!\n"; 
     1116    } 
     1117 
    10701118    # Log resolved arguments. 
    10711119    $LOG->debug(sub { 
     
    11211169    my ($self, %args) = @_; 
    11221170 
     1171    # Sanity check: Make sure we've been fed an object. 
     1172    unless (ref($self)) { 
     1173        $LOG->error("Error: Function must be called in reference to a " . 
     1174                    __PACKAGE__ . "->new() object!"); 
     1175        Carp::croak "Error: Function must be called in reference to a " . 
     1176                    __PACKAGE__ . "->new() object!\n"; 
     1177    } 
     1178 
    11231179    # Log resolved arguments. 
    11241180    $LOG->debug(sub { 
     
    11701226    # Extract arguments. 
    11711227    my ($self, %args) = @_; 
     1228 
     1229    # Sanity check: Make sure we've been fed an object. 
     1230    unless (ref($self)) { 
     1231        $LOG->error("Error: Function must be called in reference to a " . 
     1232                    __PACKAGE__ . "->new() object!"); 
     1233        Carp::croak "Error: Function must be called in reference to a " . 
     1234                    __PACKAGE__ . "->new() object!\n"; 
     1235    } 
    11721236 
    11731237    # Log resolved arguments. 
     
    13301394    # Extract arguments. 
    13311395    my ($self, %args) = @_; 
     1396 
     1397    # Sanity check: Make sure we've been fed an object. 
     1398    unless (ref($self)) { 
     1399        $LOG->error("Error: Function must be called in reference to a " . 
     1400                    __PACKAGE__ . "->new() object!"); 
     1401        Carp::croak "Error: Function must be called in reference to a " . 
     1402                    __PACKAGE__ . "->new() object!\n"; 
     1403    } 
    13321404 
    13331405    # Log resolved arguments. 
  • honeyclient/branches/exp/kindlund-firefox/lib/HoneyClient/Manager/VM/Clone.pm

    r605 r722  
    755755    # Check to see if the class name is inherited or defined. 
    756756    my $class = ref($self) || $self; 
     757     
     758    # Sanity check: Make sure we've been fed an object. 
     759    unless (ref($self)) { 
     760        $LOG->error("Error: Function must be called in reference to a " . 
     761                    __PACKAGE__ . "->new() object!"); 
     762        Carp::croak "Error: Function must be called in reference to a " . 
     763                    __PACKAGE__ . "->new() object!"; 
     764    } 
    757765 
    758766    # Emit generic "not implemented" error message. 
     
    840848    # Check to see if the class name is inherited or defined. 
    841849    my $class = ref($self) || $self; 
     850     
     851    # Sanity check: Make sure we've been fed an object. 
     852    unless (ref($self)) { 
     853        $LOG->error("Error: Function must be called in reference to a " . 
     854                    __PACKAGE__ . "->new() object!"); 
     855        Carp::croak "Error: Function must be called in reference to a " . 
     856                    __PACKAGE__ . "->new() object!"; 
     857    } 
    842858 
    843859    # Emit generic "not implemented" error message. 
     
    923939    # Check to see if the class name is inherited or defined. 
    924940    my $class = ref($self) || $self; 
     941     
     942    # Sanity check: Make sure we've been fed an object. 
     943    unless (ref($self)) { 
     944        $LOG->error("Error: Function must be called in reference to a " . 
     945                    __PACKAGE__ . "->new() object!"); 
     946        Carp::croak "Error: Function must be called in reference to a " . 
     947                    __PACKAGE__ . "->new() object!"; 
     948    } 
    925949 
    926950    # Emit generic "not implemented" error message.