| @@ -79,9 +79,9 @@ | ||
| 79 | 79 | 'text' => $text, |
| 80 | 80 | 'offset' => $offset, |
| 81 | 81 | ); |
| 82 | 82 | } |
| 83 | - if ( empty( $local_issues['catches'] ) ) { | |
| 83 | + if ( array() === $local_issues['catches'] ) { | |
| 84 | 84 | continue; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | if ( $this->condition_valid( $local_issues['catches'], $rule ) ) { |
| @@ -105,21 +105,23 @@ | ||
| 105 | 105 | private function condition_valid( $found, $rule ): bool { |
| 106 | 106 | $condition = explode( 'and', $rule['condition'] ); |
| 107 | 107 | $count = 0; |
| 108 | 108 | foreach ( $condition as $item ) { |
| 109 | - $patterns = array( | |
| 110 | - 'x_of_them' => '/([a-z0-9]+)\s*of\s*(.*)/', | |
| 111 | - 'id_at_pos' => '/(\$[a-zA-Z0-9]+)\s*at\s*(\d+)/', | |
| 112 | - ); | |
| 113 | - foreach ( $patterns as $func => $pattern ) { | |
| 114 | - if ( preg_match( $pattern, $item, $match ) ) { | |
| 115 | - ++$count; | |
| 116 | - $ret = $this->$func( $found, $match, $rule ); | |
| 117 | - if ( false === $ret ) { | |
| 118 | - return false; | |
| 119 | - } | |
| 109 | + if ( preg_match( '/([a-z0-9]+)\s*of\s*(.*)/', $item, $match ) ) { | |
| 110 | + ++$count; | |
| 111 | + $ret = $this->x_of_them( $found, $match, $rule ); | |
| 112 | + if ( false === $ret ) { | |
| 113 | + return false; | |
| 120 | 114 | } |
| 121 | 115 | } |
| 116 | + | |
| 117 | + if ( preg_match( '/(\$[a-zA-Z0-9]+)\s*at\s*(\d+)/', $item, $match ) ) { | |
| 118 | + ++$count; | |
| 119 | + $ret = $this->id_at_pos( $found, $match, $rule ); | |
| 120 | + if ( false === $ret ) { | |
| 121 | + return false; | |
| 122 | + } | |
| 123 | + } | |
| 122 | 124 | } |
| 123 | 125 | if ( 0 === $count ) { |
| 124 | 126 | $this->log( $rule['identifier'], Malware_Scan::MALWARE_LOG ); |
| 125 | 127 | $this->log( $found, Malware_Scan::MALWARE_LOG ); |
| @@ -169,9 +171,9 @@ | ||
| 169 | 171 | private function id_at_pos( $found, $check_info, $rule ): bool { |
| 170 | 172 | // Get the text to check. |
| 171 | 173 | foreach ( $found as $item ) { |
| 172 | 174 | if ( $item['id'] === $check_info[1] ) { |
| 173 | - return strpos( $this->content, $item['text'] ) === $check_info[2]; | |
| 175 | + return strpos( $this->content, $item['text'] ) === (int) $check_info[2]; | |
| 174 | 176 | } |
| 175 | 177 | } |
| 176 | 178 | |
| 177 | 179 | return false; |