QualysGuard::Response::HostInfo - QualysGuard::Response::HostInfo documentation


QualysGuard-Request documentation Contained in the QualysGuard-Request distribution.

Index


Code Index:

NAME

Top

QualysGuard::Response::HostInfo

VERSION

Top

Version 0.02

SYNOPSIS

Top

see QualysGuard::Request for more information.

DESCRIPTION

Top

This module is a subclass of QualysGuard::Response and XML::XPath.

see QualysGuard API documentation for more information.

PUBLIC INTERFACE

Top

get_ticket_numbers

Returns an arrayref of all /HOST/TICKETS/*/TICKET_NUMBER nodes.

get_vuln_info

Returns an arrayref of hasrefs containing vulnerability info from /HOST/*/*/VULNINFO nodes.

The method includes the VULN_LEVEL within the hashref.

get_tracking_method

Returns the host tracking method assigned to the host. A valid value is “IP address”, “DNS hostname”, or “NetBIOS hostname”.

get_security_risk

Returns the current security risk of the host, reflecting the number of vulnerabilities detected on the host and the relative security risk of those vulnerabilities. Security risk is a value from 1 to 5, where a rating of 5 represents the highest security risk.

get_ip

Returns the IP address of the host.

get_dns

Returns the DNS host name when known.

get_netbios

Returns the Microsoft Windows NetBIOS host name if appropriate, when known.

get_operating_system

Returns the operating system detected on the host.

get_last_scan_date

Returns the date and time when the host was last scanned (most recent scan, in YYYY-MM-DDTHH:MM:SSZ format (UTC/GMT).

get_comment

Returns user-supplied host comments.

AUTHOR

Top

Patrick Devlin, <pdevlin at cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-qualysguard-response-assetdatareport at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=QualysGuard::Request. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc QualysGuard::Request




You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=QualysGuard::Request

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/QualysGuard::Request

* CPAN Ratings

http://cpanratings.perl.org/d/QualysGuard::Request

* Search CPAN

http://search.cpan.org/dist/QualysGuard::Request

SEE ALSO

Top

QualysGuard::Request

COPYRIGHT & LICENSE

Top


QualysGuard-Request documentation Contained in the QualysGuard-Request distribution.

package QualysGuard::Response::HostInfo;

use warnings;
use strict;

use base qw( QualysGuard::Response );

our $VERSION = '0.02';


# =============================================================
# - new
# =============================================================
sub new {
    my ( $class, $xml ) = @_; 

    my $self = __PACKAGE__->SUPER::new( $xml );

    bless $self, $class;

    # -- check for QualysGuard function error

    if ( $self->exists('/HOST/ERROR') ) { 
        $self->{error_code} = $self->findvalue('/HOST/ERROR/@number');
        $self->{error_text} = $self->getNodeText('/HOST/ERROR');
        $self->{error_text} =~ s/^\s+(.*)\s+$/$1/m;
    }   

    return $self;
}



# =============================================================
# - various get methods
# =============================================================
sub get_tracking_method  { $_[0]->getNodeText( '/HOST/TRACKING_METHOD'  )->string_value(); }
sub get_security_risk    { $_[0]->getNodeText( '/HOST/SECURITY_RISK'    )->string_value(); }
sub get_ip               { $_[0]->getNodeText( '/HOST/IP'               )->string_value(); }
sub get_dns              { $_[0]->getNodeText( '/HOST/DNS'              )->string_value(); }
sub get_netbios          { $_[0]->getNodeText( '/HOST/NETBIOS'          )->string_value(); }
sub get_operating_system { $_[0]->getNodeText( '/HOST/OPERATING_SYSTEM' )->string_value(); }
sub get_last_scan_date   { $_[0]->getNodeText( '/HOST/LAST_SCAN_DATE'   )->string_value(); }
sub get_comment          { $_[0]->getNodeText( '/HOST/COMMENT'          )->string_value(); }



# =============================================================
# - get_ticket_numbers
# =============================================================
sub get_ticket_numbers {
    my $self    = shift;
    my @nodes   = $self->findnodes('/HOST/TICKETS/*/*/TICKET_NUMBER');
    my @tickets = ();

    foreach my $node ( @nodes ) {
        push( @tickets, $node->string_value() );
    }

    return \@tickets;
}



# =============================================================
# - get_vuln_info
# =============================================================
sub get_vuln_info {
    my $self = shift;
    my @nodes = $self->findnodes('/HOST/*/*/VULNINFO');
    my @vulns = (); 

    foreach my $node ( @nodes ) { 

        my @children = $node->getChildNodes();
        my $vuln     = {}; 

        $vuln->{VULN_LEVEL} = $node->getParentNode()->getParentNode()->getName();

        foreach my $child ( @children ) { 
            next unless ( $child->isa( "XML::XPath::Node::Element" ) );

            my $key = $child->getName();

            # ------- CVSS_SCORE -------------------------------------------

            if ( $key eq "CVSS_SCORE" ) {
                $vuln->{$key} = {};
                my @gc = $child->getChildNodes();

                foreach my $c ( @gc ) {
                    next unless ( $c->isa( "XML::XPath::Node::Element" ) );
                    my $ckey = $c->getName();

                    if ( defined $ckey ) {
                        $vuln->{$key}->{$ckey} = $c->string_value();
                    }
                }
            }

            # ------- LISTS -------------------------------------------------

            elsif ( $key eq "VENDOR_REFERENCE_LIST" || $key eq "CVE_ID_LIST" || $key eq "BUGTRAQ_ID_LIST" ) {
                my @n = $child->findnodes( "*/ID" );
                $vuln->{$key} = ();

                foreach my $id ( @n ) {
                    push( @{$vuln->{$key}}, $id->string_value() );
                }
            }

            else {
                $vuln->{$key} = $child->string_value();
            }
        }   

        push(@vulns, $vuln);
    }   

    return \@vulns;
}



1;

__END__