Issues (283)

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/Api/IO/Input.php (5 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
/*
4
 * This file is part of the webmozart/console package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Webmozart\Console\Api\IO;
13
14
/**
15
 * The console input.
16
 *
17
 * This class wraps an input stream and adds convenience functionality for
18
 * reading that stream.
19
 *
20
 * @since  1.0
21
 *
22
 * @author Bernhard Schussek <[email protected]>
23
 */
24
class Input
25
{
26
    /**
27
     * @var InputStream
28
     */
29
    private $stream;
30
31
    /**
32
     * @var bool
33
     */
34
    private $interactive = true;
35
36
    /**
37
     * Creates an input for the given input stream.
38
     *
39
     * @param InputStream $stream The input stream.
40
     */
41 238
    public function __construct(InputStream $stream)
42
    {
43 238
        $this->stream = $stream;
44 238
    }
45
46
    /**
47
     * Reads the given amount of characters from the input stream.
48
     *
49
     * @param int    $length  The number of characters to read.
50
     * @param string $default The default to return if interaction is disabled.
0 ignored issues
show
Should the type for parameter $default not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
51
     *
52
     * @return string The characters read from the input stream.
0 ignored issues
show
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
53
     *
54
     * @throws IOException If reading fails or if the input stream is closed.
55
     */
56 4
    public function read($length, $default = null)
57
    {
58 4
        if (!$this->interactive) {
59 1
            return $default;
60
        }
61
62 3
        return $this->stream->read($length);
63
    }
64
65
    /**
66
     * Reads a line from the input stream.
67
     *
68
     * @param string $default The default to return if interaction is disabled.
0 ignored issues
show
Should the type for parameter $default not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
69
     * @param int    $length  The maximum number of characters to read. If
0 ignored issues
show
Should the type for parameter $length not be integer|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
70
     *                        `null`, all characters up to the first newline are
71
     *                        returned.
72
     *
73
     * @return string The characters read from the input stream.
0 ignored issues
show
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
74
     *
75
     * @throws IOException If reading fails or if the input stream is closed.
76
     */
77 13
    public function readLine($default = null, $length = null)
78
    {
79 13
        if (!$this->interactive) {
80 1
            return $default;
81
        }
82
83 12
        return $this->stream->readLine($length);
84
    }
85
86
    /**
87
     * Closes the input.
88
     */
89 1
    public function close()
90
    {
91 1
        $this->stream->close();
92 1
    }
93
94
    /**
95
     * Returns whether the input is closed.
96
     *
97
     * @return bool Returns `true` if the input is closed and `false`
98
     *              otherwise.
99
     */
100 1
    public function isClosed()
101
    {
102 1
        return $this->stream->isClosed();
103
    }
104
105
    /**
106
     * Sets the underlying stream.
107
     *
108
     * @param InputStream $stream The input stream.
109
     */
110
    public function setStream(InputStream $stream)
111
    {
112
        $this->stream = $stream;
113
    }
114
115
    /**
116
     * Returns the underlying stream.
117
     *
118
     * @return InputStream The input stream.
119
     */
120 4
    public function getStream()
121
    {
122 4
        return $this->stream;
123
    }
124
125
    /**
126
     * Enables or disables interaction with the user.
127
     *
128
     * @param bool $interactive Whether the inputmay interact with the user. If
129
     *                          set to `false`, all calls to {@link read()} and
130
     *                          {@link readLine()} will immediately return the
131
     *                          default value.
132
     */
133 5
    public function setInteractive($interactive)
134
    {
135 5
        $this->interactive = (bool) $interactive;
136 5
    }
137
138
    /**
139
     * Returns whether the user may be asked for input.
140
     *
141
     * @return bool Returns `true` if the user may be asked for input and
142
     *              `false` otherwise.
143
     */
144 3
    public function isInteractive()
145
    {
146 3
        return $this->interactive;
147
    }
148
}
149