This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php namespace Understand\UnderstandLaravel5; |
||
2 | |||
3 | use Understand\UnderstandLaravel5\FieldProvider; |
||
4 | use Understand\UnderstandLaravel5\Handlers\BaseHandler; |
||
5 | |||
6 | class Logger |
||
7 | { |
||
8 | |||
9 | /** |
||
10 | * Version Number |
||
11 | */ |
||
12 | const VERSION = 2.3; |
||
13 | |||
14 | /** |
||
15 | * Field provider |
||
16 | * |
||
17 | * @var FieldProvider |
||
18 | */ |
||
19 | protected $fieldProvider; |
||
20 | |||
21 | /** |
||
22 | * Transport layer |
||
23 | * |
||
24 | * @var BaseHandler |
||
25 | */ |
||
26 | protected $handler; |
||
27 | |||
28 | /** |
||
29 | * @param FieldProvider $fieldProvider |
||
30 | * @param BaseHandler $handler |
||
31 | * @param bool $silent |
||
0 ignored issues
–
show
|
|||
32 | */ |
||
33 | public function __construct(FieldProvider $fieldProvider, BaseHandler $handler) |
||
34 | { |
||
35 | $this->setFieldProvider($fieldProvider); |
||
36 | $this->setHandler($handler); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @param $log |
||
41 | * @param array $additional |
||
42 | * @param array $customFields |
||
43 | * @return mixed |
||
44 | */ |
||
45 | public function log($log, array $additional = [], array $customFields = []) |
||
46 | { |
||
47 | $event = $this->prepare($log, $additional, $customFields); |
||
48 | |||
49 | return $this->send($event); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @param $log |
||
54 | * @param array $additional |
||
55 | * @param array $customFields |
||
56 | * @return array |
||
57 | */ |
||
58 | protected function prepare($log, array $additional = [], array $customFields = []) |
||
59 | { |
||
60 | // integer, float, string or boolean as message |
||
61 | if (is_scalar($log)) |
||
62 | { |
||
63 | $log = ['message' => $log]; |
||
64 | } |
||
65 | |||
66 | if (isset($log['message'])) |
||
67 | { |
||
68 | $log['message'] = $this->formatMessage($log['message']); |
||
69 | } |
||
70 | |||
71 | // resolve additional properties from field providers |
||
72 | $data = $this->resolveData($log, $additional, $customFields); |
||
73 | |||
74 | $event = $data + $log; |
||
75 | |||
76 | if (!isset($event['timestamp'])) |
||
77 | { |
||
78 | $event['timestamp'] = round(microtime(true) * 1000); |
||
79 | } |
||
80 | |||
81 | return $event; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @param $log |
||
86 | * @param array $additional |
||
87 | * @param array $customFields |
||
88 | * @return array |
||
89 | */ |
||
90 | protected function resolveData($log, array $additional = [], array $customFields = []) |
||
91 | { |
||
92 | $data = $this->fieldProvider->resolveValues($additional, $log); |
||
93 | |||
94 | if ($customFields) |
||
0 ignored issues
–
show
The expression
$customFields of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
95 | { |
||
96 | $data['custom'] = $this->fieldProvider->resolveValues($customFields, $log); |
||
97 | } |
||
98 | |||
99 | return $data; |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * Format message field |
||
104 | * |
||
105 | * @param string $message |
||
106 | * @return string |
||
107 | */ |
||
108 | protected function formatMessage($message) |
||
109 | { |
||
110 | if ( ! is_bool($message)) |
||
111 | { |
||
112 | return (string)$message; |
||
113 | } |
||
114 | |||
115 | // cast boolean values to "1" or "0" strings |
||
116 | if ($message) |
||
117 | { |
||
118 | return '1'; |
||
119 | } |
||
120 | |||
121 | return '0'; |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * Set handler |
||
126 | * |
||
127 | * @param BaseHandler $handler |
||
128 | */ |
||
129 | public function setHandler(BaseHandler $handler) |
||
130 | { |
||
131 | $this->handler = $handler; |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * Set field provider |
||
136 | * |
||
137 | * @param FieldProvider $fieldProvider |
||
138 | */ |
||
139 | public function setFieldProvider(FieldProvider $fieldProvider) |
||
140 | { |
||
141 | $this->fieldProvider = $fieldProvider; |
||
142 | } |
||
143 | |||
144 | /** |
||
145 | * Send data to storage |
||
146 | * |
||
147 | * @param array $requestData |
||
0 ignored issues
–
show
There is no parameter named
$requestData . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. ![]() |
|||
148 | * @return mixed |
||
149 | */ |
||
150 | protected function send(array $event) |
||
151 | { |
||
152 | try |
||
153 | { |
||
154 | return $this->handler->handle($event); |
||
155 | } |
||
156 | catch (\Throwable $e) |
||
0 ignored issues
–
show
The class
Throwable does not exist. Did you forget a USE statement, or did you not list all dependencies?
Scrutinizer analyzes your It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis. ![]() |
|||
157 | { |
||
158 | return false; |
||
159 | } |
||
160 | catch (\Exception $ex) |
||
161 | { |
||
162 | return false; |
||
163 | } |
||
164 | } |
||
165 | } |
||
166 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.