Issues (387)

Branch: develop

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

Parser/Middleware/StopwatchMiddleware.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of phpDocumentor.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author    Mike van Riel <[email protected]>
11
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
12
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
13
 * @link      http://phpdoc.org
14
 */
15
16
namespace phpDocumentor\Parser\Middleware;
17
18
use phpDocumentor\Reflection\Middleware\Command;
19
use phpDocumentor\Reflection\Middleware\Middleware;
20
use Psr\Log\LoggerInterface;
21
use Psr\Log\LogLevel;
22
use Symfony\Component\Stopwatch\Stopwatch;
23
24
final class StopwatchMiddleware implements Middleware
25
{
26
    /** @var int $memory amount of memory used */
27
    private $memory = 0;
28
29
    /** @var Stopwatch */
30
    private $stopwatch;
31
32
    /** @var LoggerInterface */
33
    private $logger;
34
35 1
    public function __construct(Stopwatch $stopwatch, LoggerInterface $logger)
36
    {
37 1
        $this->stopwatch = $stopwatch;
38 1
        $this->logger = $logger;
39 1
    }
40
41
    /**
42
     * Executes this middleware class.
43
     *
44
     * @return object
45
     */
46 1
    public function execute(Command $command, callable $next)
47
    {
48 1
        $result = $next($command);
49
50 1
        $lap = $this->stopwatch->lap('parser.parse');
51 1
        $oldMemory = $this->memory;
52 1
        $periods = $lap->getPeriods();
53 1
        $memory = end($periods)->getMemory();
54
55 1
        $differenceInMemory = $memory - $oldMemory;
56 1
        $this->log(
57 1
            sprintf(
58 1
                '>> Memory after processing of file: %s megabytes (%s kilobytes)',
59 1
                $this->formatMemoryInMegabytes($memory),
60 1
                (($differenceInMemory >= 0) ? '+' : '-') . $this->formatMemoryInKilobytes($differenceInMemory)
61
            ),
62 1
            LogLevel::DEBUG
63
        );
64
65 1
        $this->memory = $memory;
0 ignored issues
show
Documentation Bug introduced by
It seems like $memory can also be of type double. However, the property $memory is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
66
67 1
        return $result;
68
    }
69
70
    /**
71
     * Dispatches a logging request.
72
     */
73 1
    private function log(string $message, string $priority = LogLevel::INFO, array $parameters = [])
74
    {
75 1
        $this->logger->log($priority, $message, $parameters);
76 1
    }
77
78 1
    private function formatMemoryInMegabytes(int $memory): string
79
    {
80 1
        return number_format($memory / 1024 / 1024, 2);
81
    }
82
83 1
    private function formatMemoryInKilobytes(int $memory): string
84
    {
85 1
        return number_format($memory / 1024);
86
    }
87
}
88