From 66ac368a41123a17323e256506c4caae938a00ca Mon Sep 17 00:00:00 2001 From: d4t4king Date: Fri, 25 Nov 2016 14:10:24 -0800 Subject: [PATCH] removed explicit new lines (\n) from die()s and warn()s --- lynis-report-converter.pl | 44 +++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/lynis-report-converter.pl b/lynis-report-converter.pl index f344349..45b2b5d 100755 --- a/lynis-report-converter.pl +++ b/lynis-report-converter.pl @@ -96,7 +96,7 @@ unless ($quiet) { # the report is easy to process, and actually doesn't contain the "audit findings"....just the data. # but it is not our job to draw conclusions here, just present the findings of the tool. -open RPT, "<$lynis_report" or die colored("There was a problem opening the lynis report: $! \n", "bold red"); +open RPT, "<$lynis_report" or die colored("There was a problem opening the lynis report: $! ", "bold red"); while (my $line = ) { next if ($line =~ /^#/); # skip commented lines next if ($line =~ /Result.*allow\_url\_fopen.*/); # This looks like a bug in the report output. Skip it. @@ -114,13 +114,17 @@ while (my $line = ) { } else { my $tmp_v = $lynis_report_data{$k}; undef($lynis_report_data{$k}); - push @{$lynis_report_data{$k}}, $tmp_v, $v; + if ($tmp_v eq ' ') { + push @{$lynis_report_data{$k}}, $v; + } else { + push @{$lynis_report_data{$k}}, $tmp_v, $v; + } } } else { $lynis_report_data{$k} = $v; } } -close RPT or die colored("There was a problem closing the lynis report: $! \n", "bold red"); +close RPT or die colored("There was a problem closing the lynis report: $! ", "bold red"); @@ -1130,10 +1134,10 @@ END my $warn_f4 = ${$lynis_report_data{'warning[]'}}[3]; print OUT "\t\t\t\t\t$warn_id$warn_desc$to_long_severity{$warn_sev}$warn_f4\n"; } else { - die colored("Unexpected ARRAY format! \n", "bold red"); + die colored("Unexpected ARRAY format!\n".Dumper(\@{$lynis_report_data{'warning[]'}}), "bold red"); } } else { - die colored("warning[] not ARRAY ref!: ".ref($lynis_report_data{'warning[]'})."\n", "bold red"); + die colored("warning[] not ARRAY ref!: ".ref($lynis_report_data{'warning[]'}), "bold red"); } print OUT < @@ -1183,7 +1187,7 @@ END } foreach my $f ( @{$lynis_report_data{'deleted_file[]'}} ) { print OUT "\t\t\t\t\t