Branch Coverage

blib/lib/Parse/YARA.pm
Criterion Covered Total %
branch 150 188 79.7


line true false branch
227 0 8 if ($args{'verbose'})
233 6 2 unless ($args{'disable_includes'})
242 1 7 if ($args{'rule'}) { }
2 5 elsif ($args{'file'}) { }
1 4 elsif ($args{'rulehash'}) { }
250 1 0 if ($args{'rulehash'}{'rule_id'}) { }
317 0 2 if (ref $$string_hash{$string_name} eq 'ARRAY') { }
320 0 0 if ($string_name eq '$') { }
351 512 0 if ($str) { }
352 170 342 if ($type eq 'rule_id') { }
342 0 elsif ($type eq 'string_name') { }
354 0 170 if ($str =~ /^\d/) { }
0 170 elsif (not $str =~ /^[a-zA-Z0-9_]+$/) { }
363 1 341 unless ($str =~ /^\$/)
383 381 0 if ($str) { }
385 243 608 if (exists $RESERVED_WORDS{$_})
387 1 242 if ($type eq 'meta' and not $_ =~ /^(?:include|indexes)$/) { }
1 241 elsif ($type eq 'condition' and /^(?:include|ascii|condition|meta|nocase|fullword|strings|wide)$/) { }
1 240 elsif (not $type =~ /^(?:meta|condition)$/) { }
422 484 50 defined $3 ? :
440 170 1412 if ($line and $line =~ /^(?:(global|private)\s+)?rule\s+([a-zA-Z0-9_]+)(?:\s*:\s*([^{]*))?\s*({.*})?/) { }
26 1386 elsif (not $rule_id) { }
1236 150 elsif ($line) { }
446 0 170 if ($self->_check_reserved($rule_id, 'rule_id')) { }
0 170 elsif (not $self->_is_valid($rule_id, 'rule_id')) { }
456 0 170 if ($4)
480 10 160 if ($$rule_data{$rule}{'modifier'})
486 18 152 if ($$rule_data{$rule}{'tags'})
492 0 170 if ($$self{'verbose'})
494 0 0 if ($$self{'rules'}{$rule}{'tags'} and scalar $$self{'rules'}{$rule}{'tags'} > 0)
516 0 8 if ($$self{'verbose'})
518 0 8 unless open RULESFILE, '<', $file
523 4 1716 if ($$self{'include'} and /^include\s+"(.*?)"/) { }
1712 4 elsif (not /^include\s+"(.*?)"/) { }
554 6 1826 if ($line =~ /meta:/)
562 6 1820 if ($flag and $line =~ /^\s*(?:strings:|condition:)\s*$/)
569 16 1804 if ($flag and $line =~ /^\s*(\S[^=\s]*)\s*=\s*(\S+.*)$/)
572 8 8 unless ($meta_val =~ /^(\d+|true|false)$/)
595 122 1710 if ($line =~ /strings:/)
603 122 1588 if ($flag and $line =~ /^\s*(?:meta:|condition:)\s*$/)
610 382 1206 if ($flag and $line =~ m[^\s*(\$[a-zA-Z0-9_]*)\s*=\s*((?:"|/|{)\s*\S+.*(?:"|/|}))\s*(.*)$])
616 182 200 if ($str_val =~ /^{.*?}$/) { }
10 190 elsif ($str_val =~ m[^/.*?/$]) { }
627 44 338 if ($str_name eq '$') { }
632 26 356 if ($str_mods)
656 170 1662 if ($line =~ /condition:/)
664 0 1662 if ($flag and $line =~ /^\s*(?:meta:|strings:)\s*$/)
671 174 360 if ($flag and $line =~ /^\s*(\S+.*)$/ and not $line =~ /^\s*({|})\s*$/)
675 170 4 if (length $condition == 0) { }
700 14 1 if ($modifier) { }
703 13 1 if ($modifier =~ /^(?:private|global)$/) { }
724 173 0 if ($condition) { }
726 1 172 if ($self->_check_reserved($condition, 'condition')) { }
753 0 18 if ($_ eq $tag) { }
1 17 elsif ($self->_check_reserved($tag, 'tag')) { }
765 31 1 if ($flag)
780 7 13 unless ($$self{'rules'}{$rule_id}{'meta'})
785 1 19 if ($self->_check_reserved($meta_name, 'meta')) { }
0 19 elsif ($$self{'rules'}{$rule_id}{'meta'}{$meta_name}) { }
810 42 0 if ($modifier) { }
812 40 2 if ($modifier =~ /^(?:wide|nocase|ascii|fullword)$/) { }
1 1 elsif ($modifier eq 'all') { }
840 5 0 if ($modifier) { }
842 4 1 if ($modifier =~ /^(?:wide|nocase|ascii|fullword)$/) { }
1 0 elsif ($modifier eq 'all') { }
865 8 38 unless ($$self{'rules'}{$rule_id}{'strings'})
876 149 4 if (/^\$+$/)
894 115 228 unless ($$self{'rules'}{$rule_id}{'strings'})
899 1 342 if ($$self{'rules'}{$rule_id}{'strings'}{$str_name}) { }
341 1 elsif ($self->_is_valid($str_name, 'string_name')) { }
920 0 1 if (scalar(@{$$self{'rules'}{$rule_id}{'tags'};} < 1))
950 1 2 if ($str_name =~ /^\$+$/ and $$self{'rules'}{$rule_id}{'strings'}{$str_name}{'value'} eq $str_val)
968 1 1 if ($str_name eq '$') { }
986 0 1 if (not $$self{'rules'}{$rule_id}{'meta'}{$meta_name}) { }
1006 0 1 if ($str_name =~ /^\$+$/) { }
0 1 elsif (not $$self{'rules'}{$rule_id}{'strings'}{$str_name}) { }
1027 0 171 if (not exists $$self{'rules'}{$rule_id}{'condition'}) { }
1030 11 160 if ($$self{'rules'}{$rule_id}{'modifier'})
1037 19 152 if ($$self{'rules'}{$rule_id}{'tags'})
1048 7 164 if ($$self{'rules'}{$rule_id}{'meta'})
1053 8 10 if ($$self{'rules'}{$rule_id}{'meta'}{$meta_name} =~ /^(\d+|true|false)$/) { }
1063 123 48 if ($$self{'rules'}{$rule_id}{'strings'})
1069 44 340 if ($string_name =~ /^\$+$/)
1072 192 192 if ($$self{'rules'}{$rule_id}{'strings'}{$string_name}{'type'} eq 'text') { }
182 10 elsif ($$self{'rules'}{$rule_id}{'strings'}{$string_name}{'type'} eq 'hex') { }
10 0 elsif ($$self{'rules'}{$rule_id}{'strings'}{$string_name}{'type'} eq 'regex') { }
1113 0 7 if ($rule_id) { }
1140 1 2 if (exists $$self{'rules'}{$_})
1161 0 2 if (not $position =~ /^(before|after)$/) { }
0 2 elsif (not $$self{'rules'}{$rule_id}) { }
0 2 elsif (not $$self{'rules'}{$relative_rule_id}) { }
1170 0 2 if ($$self{'verbose'})
1179 0 2 if ($position eq 'after' and $rule_pos > $relative_rule_pos) { }
0 3 elsif ($position eq 'before' and $rule_pos < $relative_rule_pos) { }