Issues (5)

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.

lib/PhpFlo/TraceableNetwork.php (2 issues)

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
/*
3
 * This file is part of the phpflo/phpflo-flowtrace package.
4
 *
5
 * (c) Marc Aschmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
declare(strict_types=1);
11
namespace PhpFlo;
12
13
use PhpFlo\Common\AbstractNetworkDecorator;
14
use PhpFlo\Common\NetworkDecoratorInterface;
15
use PhpFlo\Common\NetworkInterface;
16
use Psr\Log\LoggerInterface;
17
18
/**
19
 * Network for tracing events.
20
 *
21
 * @package PhpFlo
22
 * @author Marc Aschmann <[email protected]>
23
 */
24
class TraceableNetwork extends AbstractNetworkDecorator implements NetworkDecoratorInterface
25
{
26
    const TYPE_DATA = 'data';
27
    const TYPE_CONNECT = 'connect';
28
    const TYPE_DISCONNECT = 'disconnect';
29
    const TYPE_BEGIN_GROUP = 'begin.group';
30
    const TYPE_END_GROUP = 'end.group';
31
32
    /**
33
     * @var array
34
     */
35
    private $actions;
36
37
    /**
38
     * @var LoggerInterface
39
     */
40
    private $logger;
41
42
    /**
43
     * TraceableNetwork constructor.
44
     *
45
     * @param NetworkInterface $network
46
     * @param LoggerInterface $logger
47
     */
48 2
    public function __construct(NetworkInterface $network, LoggerInterface $logger)
49
    {
50 2
        parent::__construct($network);
51
52 2
        $this->actions = [
53 2
            self::TYPE_DATA       => 'DATA',
54 2
            self::TYPE_CONNECT    => 'CONN',
55 2
            self::TYPE_DISCONNECT => 'DISC'
56 2
        ];
57
58 2
        $this->logger = $logger;
59 2
        $this->network->hook(self::TYPE_DATA, 'flowtrace', $this->trace(self::TYPE_DATA));
60 2
        $this->network->hook(self::TYPE_CONNECT, 'flowtrace', $this->trace(self::TYPE_CONNECT));
61 2
        $this->network->hook(self::TYPE_DISCONNECT, 'flowtrace', $this->trace(self::TYPE_DISCONNECT));
62 2
    }
63
64
    /**
65
     * Wrap the creation of the callback
66
     *
67
     * @param string $type
68
     * @return \Closure
69
     */
70
    private function trace(string $type) : \Closure
71
    {
72 2
        $trace = function() use ($type) {
73
            switch ($type) {
74
                case TraceableNetwork::TYPE_DATA:
75
                    $this->traceData(func_get_args(), $type);
76
                    break;
77
                case TraceableNetwork::TYPE_CONNECT:
78
                case TraceableNetwork::TYPE_DISCONNECT:
79
                    $this->traceAction(func_get_args(), $type);
80
                    break;
81
            }
82 2
        };
83
84 2
        return $trace->bindTo($this);
85
    }
86
87
    /**
88
     * @param array $args
89
     * @param string $type
90
     */
91
    private function traceData(array $args, string $type)
92
    {
93
        $data   = $args[0];
94
        $socket = $args[1];
95
96
        if (!is_string($data)) {
97
            $data = serialize($data);
98
        }
99
        $to = $socket->to();
100
        $message = "-> {$to['port']} {$to['process']['id']}";
101
102
        $from = $socket->from();
103 View Code Duplication
        if (isset($from['process'])) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
104
            $message = " {$from['process']['id']} {$from['port']} {$message}";
105
        }
106
107
        $this->logger->info("{$message} {$this->actions[$type]} {$data}");
108
    }
109
110
    /**
111
     * @param array $args
112
     * @param string $type
113
     */
114
    private function traceAction(array $args, string $type)
115
    {
116
        $socket = $args[0];
117
        $to = $socket->to();
118
        $message = "-> {$to['port']} {$to['process']['id']}";
119
120
        $from = $socket->from();
121 View Code Duplication
        if (isset($from['process'])) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
122
            $message = " {$from['process']['id']} {$from['port']} {$message}";
123
        }
124
125
        $this->logger->debug("{$message} {$this->actions[$type]}");
126
    }
127
}
128