From 87d2f90dfc924e5d746b0f7aa0e54777a5cda141 Mon Sep 17 00:00:00 2001 From: dataking Date: Thu, 27 Apr 2017 13:44:19 -0700 Subject: [PATCH] fixed non-existent issue with 'systemd_unit_file[]' --- lynis-report-converter.pl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lynis-report-converter.pl b/lynis-report-converter.pl index 82a0619..1e45d1e 100755 --- a/lynis-report-converter.pl +++ b/lynis-report-converter.pl @@ -198,13 +198,16 @@ if ($debug) { if ($json) { require JSON; # tidy up some of the "object" variables - my @sduf = @{$lynis_report_data{'systemd_unit_file[]'}}; - my @sduf_new; - foreach my $uf ( @sduf ) { - my ($name,$status) = split(/\|/, $uf); - push @sduf_new, { 'name' => $name, 'state' => $status }; + my @sduf; + if ((ref($lynis_report_data{'systemd_unit_file[]'}) eq 'ARRAY') and ($lynis_report_data{'systemd_unit_file[]'} ne 'NA')) { + @sduf = @{$lynis_report_data{'systemd_unit_file[]'}}; + my @sduf_new; + foreach my $uf ( @sduf ) { + my ($name,$status) = split(/\|/, $uf); + push @sduf_new, { 'name' => $name, 'state' => $status }; + } + $lynis_report_data{'systemd_unit_file[]'} = \@sduf_new; } - $lynis_report_data{'systemd_unit_file[]'} = \@sduf_new; my @ipa = @{$lynis_report_data{'installed_packages_array'}}; my @ipa_new; foreach my $pkg ( @ipa ) {