| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 3.4746 |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | 1 | public function assetExists(string $path): bool |
|
| 23 | { |
||
| 24 | 1 | $publicRoot = realpath($this->projectpath . '/public/') . DIRECTORY_SEPARATOR; |
|
| 25 | 1 | $toCheck = $publicRoot . $path; |
|
| 26 | |||
| 27 | // check if the file exists |
||
| 28 | 1 | if (!is_file($toCheck)) { |
|
| 29 | 1 | return false; |
|
| 30 | } |
||
| 31 | |||
| 32 | // check if file is well contained in web/ directory (prevents ../ in paths) |
||
| 33 | if (0 !== strncmp($publicRoot, $toCheck, strlen($publicRoot))) { |
||
| 34 | return false; |
||
| 35 | } |
||
| 36 | |||
| 37 | return true; |
||
| 38 | } |
||
| 40 |