| 1 | package Net::SecurityCenter::Utils; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Params::Check qw(allow); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Time::Piece; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Data::Dumper (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | our $VERSION = '0.311'; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||
| 15 | sc_check_params | ||||||||||||||||||||||||||||||||||||||||||
| 16 | sc_decode_scanner_status | ||||||||||||||||||||||||||||||||||||||||||
| 17 | sc_filter_array_to_string | ||||||||||||||||||||||||||||||||||||||||||
| 18 | sc_filter_int_to_bool | ||||||||||||||||||||||||||||||||||||||||||
| 19 | sc_filter_datetime_to_epoch | ||||||||||||||||||||||||||||||||||||||||||
| 20 | sc_merge | ||||||||||||||||||||||||||||||||||||||||||
| 21 | sc_normalize_hash | ||||||||||||||||||||||||||||||||||||||||||
| 22 | sc_normalize_array | ||||||||||||||||||||||||||||||||||||||||||
| 23 | sc_method_usage | ||||||||||||||||||||||||||||||||||||||||||
| 24 | sc_schedule | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | dumper | ||||||||||||||||||||||||||||||||||||||||||
| 27 | trim | ||||||||||||||||||||||||||||||||||||||||||
| 28 | deprecated | ||||||||||||||||||||||||||||||||||||||||||
| 29 | cpe_decode | ||||||||||||||||||||||||||||||||||||||||||
| 30 | file_slurp | ||||||||||||||||||||||||||||||||||||||||||
| 31 | config_parse_line | ||||||||||||||||||||||||||||||||||||||||||
| 32 | config_parser | ||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | our %EXPORT_TAGS = ( all => \@EXPORT_OK ); | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | our $NESSUS_SCANNER_STATUS = { | |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 => 'Working', | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 => 'Connection Error', | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 4 => 'Connection Timeout', | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 8 => 'Certificate mismatch', | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 16 => 'Protocol Error', | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 32 => 'Authentication Error', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 64 => 'Invalid Configuration', | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 128 => 'Reloading Scanner', | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 256 => 'Plugins out-of-sync', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 512 => 'PVS results ready', | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 1024 => 'Updating plugins', | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 2048 => 'LCE main daemon down', | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 4096 => 'LCE query daemon down', | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 8192 => 'Updating Status', | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 16384 => 'Scanner disabled by user', | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 32768 => 'Scanner requires an upgrade', | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 65536 => 'LCE version too low', | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 131072 => 'License Invalid', | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 262144 => 'Not used', | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 524288 => 'Resource Unavailable', | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 63 | # COMMON UTILS | ||||||||||||||||||||||||||||||||||||||||||
| 64 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 44 | ▶ | sub dumper { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dumper: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 44 | return Data::Dumper->new( [@_] )->Indent(1)->Sortkeys(1)->Terse(1)->Useqq(1)->Dump; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | ▶ | sub trim { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trim: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | my ($string) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | ▶ | return if ( !$string ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | $string =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | return $string; | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub deprecated { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deprecated: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | local $Carp::CarpLevel = 1; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | carp @_; | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub cpe_decode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cpe_decode: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my ($cpe) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $cpe =~ s/cpe:\///; | |||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my ( $part, $vendor, $product, $version, $update, $edition, | |||||||||||||||||||||||||||||||||||||||||
| 99 | $language, $sw_edition, $target_sw, $target_hw, $other ); | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ( $part, $vendor, $product, $version, $update, $edition, $language ) = split( /:/, $cpe ); | |||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | ( $sw_edition, $target_sw, $target_hw, $other ) = split( /~/, $language ) if ($language); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | 'part' => $part, | |||||||||||||||||||||||||||||||||||||||||
| 107 | 'vendor' => $vendor, | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 'product' => $product, | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 'version' => $version, | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 'update' => $update, | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 'edition' => $edition, | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 'language' => $language, | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 'sw_edition' => $sw_edition, | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 'target_sw' => $target_sw, | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 'target_hw' => $target_hw, | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 'other' => $other | ||||||||||||||||||||||||||||||||||||||||||
| 117 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 122 | # COMMON CLASS UTILS | ||||||||||||||||||||||||||||||||||||||||||
| 123 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | ▶ | sub sc_schedule { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_schedule: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | my (%args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 2 | my $tmpl = { | |||||||||||||||||||||||||||||||||||||||||
| 130 | type => { | ||||||||||||||||||||||||||||||||||||||||||
| 131 | allow => [ 'dependent', 'ical', 'never', 'rollover', 'template', 'now' ], | ||||||||||||||||||||||||||||||||||||||||||
| 132 | default => 'never', | ||||||||||||||||||||||||||||||||||||||||||
| 133 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 134 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 135 | start => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 136 | repeat_rule => { | ||||||||||||||||||||||||||||||||||||||||||
| 137 | remap => 'repeatRule', | ||||||||||||||||||||||||||||||||||||||||||
| 138 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 139 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | my $params = sc_check_params( $tmpl, \%args ); | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | ▶ | if ( $params->{'type'} eq 'now' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | 'repeatRule' => 'FREQ=NOW;INTERVAL=1', | |||||||||||||||||||||||||||||||||||||||||
| 147 | 'type' => 'now' | ||||||||||||||||||||||||||||||||||||||||||
| 148 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | ▶ | if ( $params->{'type'} eq 'ical' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 'type' => 'ical', | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 'start' => $params->{'start'}, | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | 'repeatRule' => $params->{'repeatRule'}, | |||||||||||||||||||||||||||||||||||||||||
| 158 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | return $params; | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | sub sc_method_usage { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_method_usage: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my ($template) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | my $usage_class = ( caller(2) )[3] || q{}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
(caller 2)[3] || ''
MC/DC0%0/1
(caller 2)[3] || ''
(caller 2)[3]
Truth table0%0/2
A
A= (caller 2)[3]
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $usage_class =~ s/(::)(\w+)$/->$2/; | |||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $usage_args = q{}; | |||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my @usage_req_args; | |||||||||||||||||||||||||||||||||||||||||
| 178 | my @usage_opt_args; | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | foreach my $key ( sort keys %{$template} ) { | |||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | ( exists $template->{$key}->{'required'} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | ? push @usage_req_args, "$key => ..." | ||||||||||||||||||||||||||||||||||||||||||
| 184 | : push @usage_opt_args, "$key => ..."; | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $usage_args .= join ' , ', @usage_req_args; | |||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | if (@usage_req_args) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $usage_args .= ' , '; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $usage_args .= '[ ' . ( join ' , ', @usage_opt_args ) . ' ]'; | |||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | return "Usage: $usage_class( $usage_args )"; | |||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 45 | ▶ | sub sc_check_params { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_check_params: called CC=24 SCAR=40.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 45 | my ( $template, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 45 | my $args = {}; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 45 | my $output = {}; | |||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 45 | foreach my $key ( keys %{$params} ) { | |||||||||||||||||||||||||||||||||||||||||
| 210 | 36 | my $lc_key = lc $key; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 36 | $args->{$lc_key} = $params->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 45 | foreach my $key ( keys %{$template} ) { | |||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 136 | my $tmpl = $template->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 136 | ▶ | if ( exists $tmpl->{'required'} and not exists $args->{$key} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $tmpl->{"required"} and not exists $args->{$key}
MC/DC0%0/2
exists $tmpl->{"required"} and not exists $args->{$key}
exists $tmpl->{"required"}
not exists $args->{$key}
Truth table66%2/3
A and not(B)
A= exists $tmpl->{"required"}B= not exists $args->{$key}
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $error_message = "Required '$key' param is not provided"; | |||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ( defined $tmpl->{'messages'}->{'required'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $error_message = $tmpl->{'messages'}->{'required'}; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | carp $error_message; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | croak sc_method_usage($template); | |||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 136 | ▶ | if ( exists $tmpl->{'default'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 3 | $output->{$key} = $tmpl->{'default'}; | |||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 45 | foreach my $key ( keys %{$args} ) { | |||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 36 | ▶ | next if ( !exists $template->{$key} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 36 | my $value = $args->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 36 | my $tmpl = $template->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | # Execute pre-validation filter | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 36 | ▶ | if ( exists $tmpl->{'filter'} and ref $tmpl->{'filter'} eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $tmpl->{"filter"} and ref $tmpl->{"filter"} eq "CODE"
MC/DC50%1/2
exists $tmpl->{"filter"} and ref $tmpl->{"filter"} eq "CODE"
exists $tmpl->{"filter"}
ref $tmpl->{"filter"} eq "CODE"
Truth table66%2/3
A and B
A= exists $tmpl->{"filter"}B= ref $tmpl->{"filter"} eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | $value = $tmpl->{'filter'}->($value); | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 36 | ▶ | if ( exists $tmpl->{'allow'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 29 | ▶ | if ( ref $value eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | foreach ( @{$value} ) { | |||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 5 | ▶ | if ( !allow( $_, $tmpl->{'allow'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | carp "Invalid '$key' ($_) value (allowed values: " . join( ', ', @{ $tmpl->{'allow'} } ) . ')'; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | croak sc_method_usage($template); | |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 27 | ▶ | if ( !allow( $value, $tmpl->{'allow'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $error_message = q{}; | |||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if ( ref $tmpl->{'allow'} eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | $error_message | ||||||||||||||||||||||||||||||||||||||||||
| 270 | = "Invalid '$key' ($value) value (allowed values: " | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | . join( ', ', @{ $tmpl->{'allow'} } ) . ')'; | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if ( ref $tmpl->{'allow'} eq 'Regexp' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $error_message = "Invalid param '$key' ($value) value"; | |||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | if ( exists $tmpl->{'messages'}->{'allow'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $error_message = $tmpl->{'messages'}->{'allow'}; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | carp $error_message; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | croak sc_method_usage($template); | |||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | # Execute post validation filter | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 36 | ▶ | if ( exists $tmpl->{'post_filter'} and ref $tmpl->{'post_filter'} eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $tmpl->{"post_filter"} and ref $tmpl->{"post_filter"} eq "CODE"
MC/DC0%0/2
exists $tmpl->{"post_filter"} and ref $tmpl->{"post_filter"} eq "CODE"
exists $tmpl->{"post_filter"}
ref $tmpl->{"post_filter"} eq "CODE"
Truth table33%1/3
A and B
A= exists $tmpl->{"post_filter"}B= ref $tmpl->{"post_filter"} eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $value = $tmpl->{'post_filter'}->($value); | |||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | 36 | ▶ | if ( $key eq 'fields' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 3 | ▶ | if ( ref $value eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 2 | $value = join( ',', @{$value} ); | |||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 36 | $output->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 36 | ▶ | if ( exists $tmpl->{'remap'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | $output->{ $tmpl->{'remap'} } = $output->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | delete $output->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 45 | return $output; | |||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 21 | ▶ | sub sc_decode_scanner_status { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_decode_scanner_status: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 21 | my ($scanner_status) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 21 | foreach ( sort { $b <=> $a } keys %{$NESSUS_SCANNER_STATUS} ) { | |||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | 217 | ▶ | if ( $scanner_status >= $_ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 21 | return $NESSUS_SCANNER_STATUS->{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 205 | ▶ | sub sc_normalize_hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_normalize_hash: called CC=12 SCAR=24.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 205 | my ($data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | 205 | my @time_fields = qw( | |||||||||||||||||||||||||||||||||||||||||
| 340 | createdTime | ||||||||||||||||||||||||||||||||||||||||||
| 341 | finishTime | ||||||||||||||||||||||||||||||||||||||||||
| 342 | importFinish | ||||||||||||||||||||||||||||||||||||||||||
| 343 | importStart | ||||||||||||||||||||||||||||||||||||||||||
| 344 | lastSyncTime | ||||||||||||||||||||||||||||||||||||||||||
| 345 | lastTrendUpdate | ||||||||||||||||||||||||||||||||||||||||||
| 346 | lastVulnUpdate | ||||||||||||||||||||||||||||||||||||||||||
| 347 | modifiedTime | ||||||||||||||||||||||||||||||||||||||||||
| 348 | startTime | ||||||||||||||||||||||||||||||||||||||||||
| 349 | updateTime | ||||||||||||||||||||||||||||||||||||||||||
| 350 | diagnosticsGenerated | ||||||||||||||||||||||||||||||||||||||||||
| 351 | statusLastChecked | ||||||||||||||||||||||||||||||||||||||||||
| 352 | lastScan | ||||||||||||||||||||||||||||||||||||||||||
| 353 | lastUnauthRun | ||||||||||||||||||||||||||||||||||||||||||
| 354 | lastAuthRun | ||||||||||||||||||||||||||||||||||||||||||
| 355 | time | ||||||||||||||||||||||||||||||||||||||||||
| 356 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 205 | my @seconds_fields = qw( | |||||||||||||||||||||||||||||||||||||||||
| 359 | scanDuration | ||||||||||||||||||||||||||||||||||||||||||
| 360 | uptime | ||||||||||||||||||||||||||||||||||||||||||
| 361 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | 205 | foreach my $item ( keys %{$data} ) { | |||||||||||||||||||||||||||||||||||||||||
| 364 | 986 | ▶ | if ( ref $data->{$item} eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 48 | $data->{$item} = sc_normalize_hash( $data->{$item} ); | |||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 986 | ▶ | if ( $item =~ m/(Update|Date|Time)$/ && $data->{$item} =~ /\d+/ && ref $data->{$item} ne 'Time::Piece' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$item =~ /(Update|Date|Time)$/ and $data->{$item} =~ /\d+/ and ref $data->{$item} ne "Time::Piece"
$item =~ /(Update|Date|Time)$/ and $data->{$item} =~ /\d+/
MC/DC33%1/3
$item =~ /(Update|Date|Time)$/ and $data->{$item} =~ /\d+/ and ref $data->{$item} ne "Time::Piece"
$item =~ /(Update|Date|Time)$/
$data->{$item} =~ /\d+/
ref $data->{$item} ne "Time::Piece"
Truth table50%2/4
A and B and C
A= $item =~ /(Update|Date|Time)$/B= $data->{$item} =~ /\d+/C= ref $data->{$item} ne "Time::Piece"
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 45 | $data->{$item} = Time::Piece->new( $data->{$item} ); | |||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 205 | foreach my $field (@time_fields) { | |||||||||||||||||||||||||||||||||||||||||
| 373 | 3280 | ▶ | if ( exists( $data->{$field} ) && ref $data->{$field} ne 'Time::Piece' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $data->{$field} and ref $data->{$field} ne "Time::Piece"
MC/DC100%2/2
exists $data->{$field} and ref $data->{$field} ne "Time::Piece"
exists $data->{$field}
ref $data->{$field} ne "Time::Piece"
Truth table100%3/3
A and B
A= exists $data->{$field}B= ref $data->{$field} ne "Time::Piece"
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 11 | $data->{$field} = Time::Piece->new( $data->{$field} ); | |||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 205 | foreach my $field (@seconds_fields) { | |||||||||||||||||||||||||||||||||||||||||
| 379 | 410 | ▶ | if ( exists( $data->{$field} ) && ref $data->{$field} ne 'Time::Seconds' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $data->{$field} and ref $data->{$field} ne "Time::Seconds"
MC/DC50%1/2
exists $data->{$field} and ref $data->{$field} ne "Time::Seconds"
exists $data->{$field}
ref $data->{$field} ne "Time::Seconds"
Truth table66%2/3
A and B
A= exists $data->{$field}B= ref $data->{$field} ne "Time::Seconds"
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 5 | $data->{$field} = Time::Seconds->new( $data->{$field} ); | |||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | 205 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | 7 | ▶ | sub sc_normalize_array { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_normalize_array: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 7 | my ($data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 7 | my $results = []; | |||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | 7 | foreach my $item ( @{$data} ) { | |||||||||||||||||||||||||||||||||||||||||
| 397 | 106 | push( @{$results}, sc_normalize_hash($item) ); | |||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | 7 | return $results; | |||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | 5 | ▶ | sub sc_merge { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_merge: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 5 | my ($data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 5 | my %hash = (); | |||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | 5 | foreach my $type ( ( 'usable', 'manageable' ) ) { | |||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | 10 | ▶ | next unless ( exists( $data->{$type} ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | 10 | foreach my $item ( @{ $data->{$type} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 36 | $item = sc_normalize_hash($item); | |||||||||||||||||||||||||||||||||||||||||
| 418 | 36 | $item->{$type} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 36 | ▶ | if ( exists( $hash{ $item->{'id'} } ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | 16 | $hash{ $item->{'id'} }->{$type} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 422 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 20 | $hash{ $item->{'id'} } = $item; | |||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | 5 | my @results = values %hash; | |||||||||||||||||||||||||||||||||||||||||
| 429 | 5 | return \@results; | |||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 434 | # FILTERS | ||||||||||||||||||||||||||||||||||||||||||
| 435 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | 6 | ▶ | sub sc_filter_array_to_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_filter_array_to_string: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | 6 | my ($data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | 6 | ▶ | if ( ref $data eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | 1 | return join( ',', @{$data} ); | |||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | 5 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | sub sc_filter_int_to_bool { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_filter_int_to_bool: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | return ( $_[0] == 1 ) ? \1 : \0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | sub sc_filter_datetime_to_epoch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sc_filter_datetime_to_epoch: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | my ($date) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | if ( ref $date eq 'Time::Piece' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | return $date->epoch; | |||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | if ( $date =~ /^\d{4}-\d{2}-\d{2}$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | my $t = Time::Piece->strptime( $date, '%Y-%m-%d' ); | |||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | return $t->epoch; | |||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | if ( $date =~ /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | my $t = Time::Piece->strptime( $date, '%Y-%m-%d %H:%M:%S' ); | |||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | return $t->epoch; | |||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | if ( $date =~ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | my $t = Time::Piece->strptime( $date, '%Y-%m-%dT%H:%M:%S' ); | |||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | return $t->epoch; | |||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | return $date; | |||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | __END__ | ||||||||||||||||||||||||||||||||||||||||||