Issues (25)

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.

src/Queue/Pipe.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
 * @author Jenner <[email protected]>
4
 * @blog http://www.huyanping.cn
5
 * @license https://opensource.org/licenses/MIT MIT
6
 * @datetime: 2015/11/24 16:29
7
 */
8
9
namespace Jenner\SimpleFork\Queue;
10
11
12
class Pipe
13
{
14
    /**
15
     * @var resource
16
     */
17
    protected $read;
18
19
    /**
20
     * @var resource
21
     */
22
    protected $write;
23
24
    /**
25
     * @var string
26
     */
27
    protected $filename;
28
29
    /**
30
     * @var bool
31
     */
32
    protected $block;
33
34
    /**
35
     * @param string $filename fifo filename
36
     * @param int $mode
37
     * @param bool $block if blocking
38
     */
39 12
    public function __construct($filename = '/tmp/simple-fork.pipe', $mode = 0666, $block = false)
40
    {
41 12
        if (!file_exists($filename) && !posix_mkfifo($filename, $mode)) {
42
            throw new \RuntimeException('create pipe failed');
43
        }
44 12
        if (filetype($filename) != 'fifo') {
45
            throw new \RuntimeException('file exists and it is not a fifo file');
46
        }
47
48 12
        $this->filename = $filename;
49 12
        $this->block = $block;
50 12
    }
51
52 6
    public function setBlock($block = true)
53
    {
54 6
        if (is_resource($this->read)) {
55
            $set = stream_set_blocking($this->read, $block);
56
            if (!$set) {
57
                throw new \RuntimeException('stream_set_blocking failed');
58
            }
59
        }
60
61 6
        if (is_resource($this->write)) {
62
            $set = stream_set_blocking($this->write, $block);
63
            if (!$set) {
64
                throw new \RuntimeException('stream_set_blocking failed');
65
            }
66
        }
67
68 6
        $this->block = $block;
69 6
    }
70
71
    /**
72
     * if the stream is blocking, you would better set the value of size,
73
     * it will not return until the data size is equal to the value of param size
74
     *
75
     * @param int $size
76
     * @return string
77
     */
78 9 View Code Duplication
    public function read($size = 1024)
0 ignored issues
show
This method seems to be duplicated in 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...
79
    {
80 9
        if (!is_resource($this->read)) {
81 9
            $this->read = fopen($this->filename, 'r+');
82 9
            if (!is_resource($this->read)) {
83
                throw new \RuntimeException('open file failed');
84
            }
85 9
            if (!$this->block) {
86 6
                $set = stream_set_blocking($this->read, false);
87 6
                if (!$set) {
88
                    throw new \RuntimeException('stream_set_blocking failed');
89
                }
90 6
            }
91 9
        }
92
93 9
        return fread($this->read, $size);
94
    }
95
96
    /**
97
     * @param $message
98
     * @return int
99
     */
100 6 View Code Duplication
    public function write($message)
0 ignored issues
show
This method seems to be duplicated in 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...
101
    {
102 6
        if (!is_resource($this->write)) {
103 6
            $this->write = fopen($this->filename, 'w+');
104 6
            if (!is_resource($this->write)) {
105
                throw new \RuntimeException('open file failed');
106
            }
107 6
            if (!$this->block) {
108 6
                $set = stream_set_blocking($this->write, false);
109 6
                if (!$set) {
110
                    throw new \RuntimeException('stream_set_blocking failed');
111
                }
112 6
            }
113 6
        }
114
115 6
        return fwrite($this->write, $message);
116
    }
117
118
    /**
119
     *
120
     */
121 12
    public function __destruct()
122
    {
123 12
        $this->close();
124 12
    }
125
126
    /**
127
     *
128
     */
129 12
    public function close()
130
    {
131 12
        if (is_resource($this->read)) {
132 9
            fclose($this->read);
133 9
        }
134 12
        if (is_resource($this->write)) {
135 6
            fclose($this->write);
136 6
        }
137 12
    }
138
139
    public function remove()
140
    {
141
        return unlink($this->filename);
142
    }
143
}
144