| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * Rule evaluation utilities | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @license GPL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @author Patrick Proy | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @package trapdirector | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @subpackage Processing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | trait RuleUtils | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |      * Get full number | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |      * @param string $rule Rule as string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |      * @param int item current eval position | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      * @return array<int,string> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     private function get_number(string $rule,int &$item) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         $item2=$item+1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         while ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |             ($item2!=strlen($rule)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |             && (preg_match('/[\-0-9\.]/',$rule[$item2]))) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |             $item2++ ; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         $val=substr($rule,$item,$item2-$item); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         $item=$item2; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         //echo "number ".$val."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         return array(0,$val); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * Get a string (between ")  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * @param string $rule Rule as string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @param int item current eval position | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * @return array<int,string> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     private function get_string(string $rule,int &$item) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $item++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         $item2=$this->eval_getNext($rule,$item,'"'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         $val=substr($rule,$item,$item2-$item-1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         $item=$item2; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         //echo "string : ".$val."\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         return array(1,$val); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      * Parse elements inside () : jumps over "" and count parenthesis. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * Ex : ( "test" != ")test" & (1==2) ) will return "test" != ")test" & (1==2) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * @param string $rule : the current rule | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * @param int $item : actual position in rule | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @throws Exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * @return string : everything inside parenthesis | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 61 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |     private function parse_parenthesis(string $rule,int &$item) : string | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |         $item++; | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |         $start=$item; | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |         $parenthesis_count=0; | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |         while (($item < strlen($rule)) // Not end of string AND | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |             && ( ($rule[$item] != ')' ) || $parenthesis_count > 0) ) // Closing ')' or embeded () | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |         { | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |             if ($rule[$item] == '"' ) | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |             { // pass through string | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |                 $item++; | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |                 $item=$this->eval_getNext($rule,$item,'"'); | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |             else{ | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |                 if ($rule[$item] == '(') | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |                 { | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |                     $parenthesis_count++; | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |                 } | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |                 if ($rule[$item] == ')') | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |                 { | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |                     $parenthesis_count--; | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |                 } | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |                 $item++; | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |          | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |         if ($item==strlen($rule)) {throw new Exception("no closing () in ".$rule ." at " .$item);} | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |         $val=substr($rule,$start,$item-$start); | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |         $item++; | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |         return $val; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * Get and eval a grouped condition - ex : (1==1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * @param string $rule | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      * @param int $item | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      * @return array<int,string> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     private function get_group(string $rule,int &$item) : array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         // gets eveything inside parenthesis | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         $val=$this->parse_parenthesis($rule, $item); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         // Returns boolean with evaluation of all inside parenthesis | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         $start=0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         return array(2,$this->evaluation($val,$start)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * @param string $rule | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      * @param int $item | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      * @throws Exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |      * @return array<int,string> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     private function get_function(string $rule,int &$item) : array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |         // function is : __function(param1,param2...) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         $start=$item; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         while (($item < strlen($rule)) && ($rule[$item] != '(' )) // Not end of string AND not opening '(' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |             $item++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         if ($item==strlen($rule)) {throw new Exception("no opening () for function in ".$rule ." at " .$item);} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         // get parameters between parenthesis | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         $this->parse_parenthesis($rule, $item); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         $val=substr($rule,$start,$item-$start); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         $this->logging->log('got function ' . $val,DEBUG); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         return array(2,$this->trapClass->pluginClass->evaluateFunctionString($val)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 136 |  |  |      | 
            
                                                        
            
                                    
            
            
                | 137 |  |  | } | 
            
                        
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths