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/PlainTextMessage.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;
5
6
use Genkgo\Mail\Header\ContentTransferEncoding;
7
use Genkgo\Mail\Header\ContentType;
8
use Genkgo\Mail\Stream\OptimalTransferEncodedTextStream;
9
10
final class PlainTextMessage implements MessageInterface
11
{
12
    /**
13
     * @var MessageInterface
14
     */
15
    private $decoratedMessage;
16
17
    /**
18
     * @param string $text
19
     * @param string $charset
20
     */
21 22
    public function __construct(string $text, string $charset = 'UTF-8')
22
    {
23 22
        $stream = new OptimalTransferEncodedTextStream($text);
24 22
        $encoding = $stream->getMetadata(['transfer-encoding'])['transfer-encoding'];
25
26 22
        if ($encoding === '7bit') {
27 22
            $charset = 'us-ascii';
28
        }
29
30 22
        $this->decoratedMessage = (new GenericMessage())
31 22
            ->withHeader(new ContentType('text/plain', $charset))
32 22
            ->withBody($stream)
33 22
            ->withHeader(new ContentTransferEncoding($encoding));
34 22
    }
35
36
    /**
37
     * @return iterable<iterable<HeaderInterface>>
0 ignored issues
show
The doc-type iterable<iterable<HeaderInterface>> could not be parsed: Expected "|" or "end of type", but got "<" at position 8. (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...
38
     */
39 7
    public function getHeaders(): iterable
40
    {
41 7
        return $this->decoratedMessage->getHeaders();
42
    }
43
44
    /**
45
     * @param string $name
46
     * @return bool
47
     */
48 2
    public function hasHeader(string $name): bool
49
    {
50 2
        return $this->decoratedMessage->hasHeader($name);
51
    }
52
53
    /**
54
     * @param string $name
55
     * @return iterable|HeaderInterface[]
56
     */
57 2
    public function getHeader(string $name): iterable
58
    {
59 2
        return $this->decoratedMessage->getHeader($name);
60
    }
61
62
    /**
63
     * @param HeaderInterface $header
64
     * @return MessageInterface
65
     */
66 9
    public function withHeader(HeaderInterface $header): MessageInterface
67
    {
68 9
        $clone = clone $this;
69 9
        $clone->decoratedMessage = $clone->decoratedMessage->withHeader($header);
70 9
        return $clone;
71
    }
72
73
    /**
74
     * @param HeaderInterface $header
75
     * @return MessageInterface
76
     */
77 1
    public function withAddedHeader(HeaderInterface $header): MessageInterface
78
    {
79 1
        $clone = clone $this;
80 1
        $clone->decoratedMessage = $clone->decoratedMessage->withAddedHeader($header);
81 1
        return $clone;
82
    }
83
84
    /**
85
     * @param string $name
86
     * @return MessageInterface
87
     */
88 1
    public function withoutHeader(string $name): MessageInterface
89
    {
90 1
        $clone = clone $this;
91 1
        $clone->decoratedMessage = $clone->decoratedMessage->withoutHeader($name);
92 1
        return $clone;
93
    }
94
95
    /**
96
     * @return StreamInterface
97
     */
98 7
    public function getBody(): StreamInterface
99
    {
100 7
        return $this->decoratedMessage->getBody();
101
    }
102
103
    /**
104
     * @param StreamInterface $body
105
     * @return MessageInterface
106
     */
107 1
    public function withBody(StreamInterface $body): MessageInterface
108
    {
109 1
        $clone = clone $this;
110 1
        $clone->decoratedMessage = $clone->decoratedMessage->withBody($body);
111 1
        return $clone;
112
    }
113
114
    /**
115
     * @return string
116
     */
117 8
    public function __toString(): string
118
    {
119 8
        return $this->decoratedMessage->__toString();
120
    }
121
}
122