Starting the Excel part.
This commit is contained in:
parent
4c29612774
commit
ea2accf8f8
|
@ -7,6 +7,8 @@ no if $] ge '5.018', warnings => "experimental::smartmatch";
|
||||||
use Term::ANSIColor;
|
use Term::ANSIColor;
|
||||||
use Getopt::Long qw( :config no_ignore_case bundling );
|
use Getopt::Long qw( :config no_ignore_case bundling );
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
#use Spreadsheet::WriteExcel;
|
||||||
|
use Excel::Writer::XLSX;
|
||||||
|
|
||||||
my ($help,$verbose,$excel,$output);
|
my ($help,$verbose,$excel,$output);
|
||||||
GetOptions(
|
GetOptions(
|
||||||
|
@ -21,7 +23,11 @@ if ($help) { &usage; }
|
||||||
my %to_bool = ( 0 => 'false', 1 => 'true' );
|
my %to_bool = ( 0 => 'false', 1 => 'true' );
|
||||||
my %to_long_severity = ( 'C' => 'Critical', 'S' => 'Severe', 'H' => 'High', 'M' => 'Medium', 'L' => 'Low', 'I' => 'Informational' );
|
my %to_long_severity = ( 'C' => 'Critical', 'S' => 'Severe', 'H' => 'High', 'M' => 'Medium', 'L' => 'Low', 'I' => 'Informational' );
|
||||||
|
|
||||||
|
if ($excel) {
|
||||||
|
$output = 'report.xlsx' unless ((defined($output)) and ($output ne ""));
|
||||||
|
} else {
|
||||||
$output = "report.html" unless ((defined($output)) and ($output ne ""));
|
$output = "report.html" unless ((defined($output)) and ($output ne ""));
|
||||||
|
}
|
||||||
|
|
||||||
my $lynis_log = '/var/log/lynis.log';
|
my $lynis_log = '/var/log/lynis.log';
|
||||||
my $lynis_report = '/var/log/lynis-report.dat';
|
my $lynis_report = '/var/log/lynis-report.dat';
|
||||||
|
@ -112,6 +118,25 @@ delete($lynis_report_data{'tests_executed'});
|
||||||
|
|
||||||
#print Dumper(\%warnings);
|
#print Dumper(\%warnings);
|
||||||
|
|
||||||
|
if ($excel) {
|
||||||
|
# do the Excel thing....
|
||||||
|
my $wb = Excel::Writer::XLSX->new('report.xlsx');
|
||||||
|
my $title_format = $wb->add_format();
|
||||||
|
$title_format->set_size('32');
|
||||||
|
|
||||||
|
my $subtitle_format = $wb->add_format();
|
||||||
|
$subtitle_format->set_size('24');
|
||||||
|
|
||||||
|
my $summary_ws = $wb->add_worksheet('Summary');
|
||||||
|
$summary_ws->write('B2', "lynis Asset Report", $title_format);
|
||||||
|
$summary_ws->write('B3', "created by ");
|
||||||
|
$summary_ws->write_url('C3', "http://github.com/d4t4king/lynis_report.git", '', 'lynis_report');
|
||||||
|
$summary_ws->write('A4', "Host Findings:", $subtitle_format);
|
||||||
|
$summary_ws->write('A5', "hardening index:");
|
||||||
|
$summary_ws->write('B5', $lynis_report_data{'hardening_index'});
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
open OUT, ">$output" or die colored("There was a problem opening the output file ($output): $! \n", "bold red");
|
open OUT, ">$output" or die colored("There was a problem opening the output file ($output): $! \n", "bold red");
|
||||||
print OUT <<END;
|
print OUT <<END;
|
||||||
|
|
||||||
|
@ -629,6 +654,8 @@ my @indexes = qw( lynis_version lynis_tests_done lynis_update_available license_
|
||||||
foreach my $idx ( sort @indexes ) {
|
foreach my $idx ( sort @indexes ) {
|
||||||
delete($lynis_report_data{$idx});
|
delete($lynis_report_data{$idx});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#print Dumper(\%lynis_report_data);
|
#print Dumper(\%lynis_report_data);
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
Loading…
Reference in New Issue
Block a user