Issues (74)

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/Protocol/Smtp/Reply.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
namespace Genkgo\Mail\Protocol\Smtp;
5
6
use Genkgo\Mail\Exception\AssertionFailedException;
7
8
final class Reply
9
{
10
    /**
11
     * @var array<int, array<int|string>>
12
     */
13
    private $lines = [];
14
15
    /**
16
     * @var array<int, bool>
17
     */
18
    private $codes = [];
19
20
    /**
21
     * @var array<int, string>
22
     */
23
    private $messages = [];
24
25
    /**
26
     * @var Client
27
     */
28
    private $client;
29
30
    /**
31
     * @param Client $client
32
     */
33 32
    public function __construct(Client $client)
34
    {
35 32
        $this->client = $client;
36 32
    }
37
38
    /**
39
     * @return bool
40
     */
41 6
    public function isError(): bool
42
    {
43
        try {
44 6
            $this->assertBetween(400, 599);
45 2
            return true;
46 4
        } catch (AssertionFailedException $e) {
47 4
            return false;
48
        }
49
    }
50
51
    /**
52
     * @return bool
53
     */
54 14
    public function isCommandNotImplemented(): bool
55
    {
56
        try {
57 14
            $this->assert(502);
58 6
            return true;
59 8
        } catch (AssertionFailedException $e) {
60 8
            return false;
61
        }
62
    }
63
64
    /**
65
     * @return array<int, string>
0 ignored issues
show
The doc-type array<int, could not be parsed: Expected ">" at position 5, but found "end of type". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
66
     */
67 14
    public function getMessages(): array
68
    {
69 14
        return $this->messages;
70
    }
71
72
    /**
73
     * @param int $code
74
     * @param string $message
75
     * @return Reply
76
     */
77 32
    public function withLine(int $code, string $message): Reply
78
    {
79 32
        $clone = clone $this;
80 32
        $clone->lines[] = [$code, $message];
81 32
        $clone->codes[$code] = true;
82 32
        $clone->messages[] = $message;
83 32
        return $clone;
84
    }
85
86
    /**
87
     * @param int $code
88
     * @return Client
89
     */
90 15
    public function assert(int $code): Client
91
    {
92 15
        return $this->assertBetween($code, $code);
93
    }
94
95
    /**
96
     * @return Client
97
     */
98 21
    public function assertCompleted(): Client
99
    {
100 21
        return $this->assertBetween(200, 299);
101
    }
102
103
    /**
104
     * @return Client
105
     */
106 6
    public function assertIntermediate(): Client
107
    {
108 6
        return $this->assertBetween(300, 399);
109
    }
110
111
    /**
112
     * @param int $min
113
     * @param int $max
114
     * @return Client
115
     * @throws AssertionFailedException
116
     */
117 28
    private function assertBetween(int $min, int $max): Client
118
    {
119 28
        foreach ($this->codes as $code => $activated) {
120 28
            if ($code >= $min && $code <= $max) {
121 25
                return $this->client;
122
            }
123
        }
124
125 15
        throw new AssertionFailedException(
126 15
            \sprintf(
127 15
                'Cannot assert reply code between %s and %s. Server replied %s.',
128 15
                $min,
129 15
                $max,
130 15
                $this->createErrorMessage()
131
            )
132
        );
133
    }
134
135
    /**
136
     * @return string
137
     */
138 15
    private function createErrorMessage(): string
139
    {
140 15
        return \implode(
141 15
            "\r\n",
142 15
            \array_map(
143
                function ($values) {
144 15
                    return \implode(' ', $values);
145 15
                },
146 15
                $this->lines
147
            )
148
        );
149
    }
150
}
151