conflict reolution
This commit is contained in:
commit
1641810c5c
|
@ -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;
|
||||||
|
|
||||||
|
@ -528,22 +553,19 @@ END
|
||||||
$arrlen = scalar(@{$lynis_report_data{'loaded_kernel_module[]'}});
|
$arrlen = scalar(@{$lynis_report_data{'loaded_kernel_module[]'}});
|
||||||
#print "ARRLEN: $arrlen \n";
|
#print "ARRLEN: $arrlen \n";
|
||||||
if (($arrlen % 5) == 0) {
|
if (($arrlen % 5) == 0) {
|
||||||
#warn colored("ARRLEN divisible by 5. \n", "yellow");
|
print "ARRLEN divisible by 5. \n";
|
||||||
for (my $i=0;$i<$arrlen;$i+=5) {
|
|
||||||
print OUT "\t\t\t\t\t\t<tr><td>${$lynis_report_data{'loaded_kernel_module[]'}}[$i]</td><td>${$lynis_report_data{'loaded_kernel_module[]'}}[($i + 1)]</td><td>${$lynis_report_data{'loaded_kernel_module[]'}}[($i + 2)]</td><td>${$lynis_report_data{'loaded_kernel_module[]'}}[($i + 3)]</td><td>${$lynis_report_data{'loaded_kernel_module[]'}}[($i + 4)]</td></tr>\n";
|
|
||||||
}
|
|
||||||
} elsif (($arrlen % 4) == 0) {
|
} elsif (($arrlen % 4) == 0) {
|
||||||
#warn colored("ARRLEN divisible by 4. \n", "yellow");
|
#print "ARRLEN divisible by 4. \n";
|
||||||
for (my $i=0;$i<$arrlen;$i+=4) {
|
for (my $i=0;$i<$arrlen;$i+=4) {
|
||||||
print OUT "\t\t\t\t\t\t<tr><td>${$lynis_report_data{'loaded_kernel_module[]'}}[$i]</td><td>${$lynis_report_data{'loaded_kernel_module[]'}}[($i + 1)]</td><td>${$lynis_report_data{'loaded_kernel_module[]'}}[($i + 2)]</td><td>${$lynis_report_data{'loaded_kernel_module[]'}}[($i + 3)]</td></tr>\n";
|
print OUT "\t\t\t\t\t\t<tr><td>${$lynis_report_data{'loaded_kernel_module[]'}}[$i]</td><td>${$lynis_report_data{'loaded_kernel_module[]'}}[($i + 1)]</td><td>${$lynis_report_data{'loaded_kernel_module[]'}}[($i + 2)]</td><td>${$lynis_report_data{'loaded_kernel_module[]'}}[($i + 3)]</td></tr>\n";
|
||||||
}
|
}
|
||||||
} elsif (($arrlen % 3) == 0) {
|
} elsif (($arrlen % 3) == 0) {
|
||||||
#warn colored("ARRLEN divisible by 3. \n", "yellow");
|
#print "ARRLEN divisible by 3. \n";
|
||||||
for (my $i=0;$i<$arrlen;$i+=3) {
|
for (my $i=0;$i<$arrlen;$i+=3) {
|
||||||
print OUT "\t\t\t\t\t\t<tr><td>${$lynis_report_data{'loaded_kernel_module[]'}}[$i]</td><td>${$lynis_report_data{'loaded_kernel_module[]'}}[($i + 1)]</td><td>${$lynis_report_data{'loaded_kernel_module[]'}}[($i + 2)]</td></tr>\n";
|
print OUT "\t\t\t\t\t\t<tr><td>${$lynis_report_data{'loaded_kernel_module[]'}}[$i]</td><td>${$lynis_report_data{'loaded_kernel_module[]'}}[($i + 1)]</td><td>${$lynis_report_data{'loaded_kernel_module[]'}}[($i + 2)]</td></tr>\n";
|
||||||
}
|
}
|
||||||
} elsif (($arrlen % 2) == 0) {
|
} elsif (($arrlen % 2) == 0) {
|
||||||
warn colored("ARRLEN divisible by 2. \n", "yellow");
|
print "ARRLEN divisible by 2. \n";
|
||||||
} else {
|
} else {
|
||||||
die colored("ARRLEN appears to be number with a divisor larger than 5 or 1 ($arrlen) \n","bold red");
|
die colored("ARRLEN appears to be number with a divisor larger than 5 or 1 ($arrlen) \n","bold red");
|
||||||
}
|
}
|
||||||
|
@ -632,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