Once you have issued a command and have asked the system to provide you with an XML report (for example) using the following short-form code, a JSON object will be returned:

my %hashItems;

$hashItems{'primary'} = 'vulnerabilities';

$hashItems{'secondary'} = "report";

$hashItems{'action'} = 'getreport';

$hashItems{'format'} = "xml";

$hashItems{'network'} = "$Network";

$hashItems{'apikey'} = $APIKey;

In the object, the "compresseddata" this field needs to be decoded with Base64 and then uncompressed (this field uses Zlib compression).


Again, in pseudo code without a lot of testing, the flow would look something like:

 my $compresseddata = "";

if (defined $result{'compresseddata'}) {

$compresseddata = $result{'compresseddata'};

}



if (length($compresseddata) != $result{'compressedlength'}) {

print STDERR "Invalid compressed data has been received\n";

next;

}



use Compress::Zlib qw(uncompress);

use MIME::Base64 qw(decode_base64);

my $uncompresseddata = uncompress(decode_base64($compresseddata));



if (length($uncompresseddata) != $result{'uncompressedlength'}) {

print STDERR "Invalid uncompressed data has been received (".length($uncompresseddata)." != ".$result{'uncompressedlength'}.")\n";

next;

}



if(open(FILE, "> $Filename")) {

print FILE $uncompresseddata;

close(FILE);

 }