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/Mime/ResourceAttachment.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\Mime;
5
6
use Genkgo\Mail\Header\ContentDisposition;
7
use Genkgo\Mail\Header\ContentTransferEncoding;
8
use Genkgo\Mail\Header\ContentType;
9
use Genkgo\Mail\HeaderInterface;
10
use Genkgo\Mail\Stream\Base64EncodedStream;
11
use Genkgo\Mail\StreamInterface;
12
13
final class ResourceAttachment implements PartInterface
14
{
15
    /**
16
     * @var PartInterface
17
     */
18
    private $decoratedPart;
19
20
    /**
21
     * @param resource $resource
22
     * @param string $filename
23
     * @param ContentType $contentType
24
     */
25 8
    public function __construct($resource, string $filename, ContentType $contentType)
26
    {
27 8
        if (!\is_resource($resource)) {
28
            throw new \InvalidArgumentException('Resource must be a resource');
29
        }
30
31 8
        $this->decoratedPart = (new GenericPart())
32 8
            ->withBody(new Base64EncodedStream($resource))
33 8
            ->withHeader($contentType)
34 8
            ->withHeader(new ContentTransferEncoding('base64'))
35 8
            ->withHeader(ContentDisposition::newAttachment($filename));
36 8
    }
37
38
    /**
39
     * @param string $string
40
     * @param string $filename
41
     * @param ContentType $contentType
42
     * @return ResourceAttachment
43
     */
44 8
    public static function fromString(string $string, string $filename, ContentType $contentType)
45
    {
46 8
        $resource = \fopen('php://memory', 'r+');
47 8
        if ($resource === false) {
48
            throw new \UnexpectedValueException('Cannot open php://memory for writing');
49
        }
50
51 8
        \fwrite($resource, $string);
52 8
        return new self($resource, $filename, $contentType);
53
    }
54
55
    /**
56
     * @return iterable<HeaderInterface>
0 ignored issues
show
The doc-type 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...
57
     */
58 6
    public function getHeaders(): iterable
59
    {
60 6
        return $this->decoratedPart->getHeaders();
61
    }
62
63
    /**
64
     * @param string $name
65
     * @return bool
66
     */
67
    public function hasHeader(string $name): bool
68
    {
69
        return $this->decoratedPart->hasHeader($name);
70
    }
71
72
    /**
73
     * @param string $name
74
     * @return HeaderInterface
75
     */
76 8
    public function getHeader(string $name): HeaderInterface
77
    {
78 8
        return $this->decoratedPart->getHeader($name);
79
    }
80
81
    /**
82
     * @param HeaderInterface $header
83
     * @return PartInterface
84
     */
85
    public function withHeader(HeaderInterface $header): PartInterface
86
    {
87
        $clone = clone $this;
88
        $clone->decoratedPart = $this->decoratedPart->withHeader($header);
89
        return $clone;
90
    }
91
92
    /**
93
     * @param string $name
94
     * @return PartInterface
95
     */
96
    public function withoutHeader(string $name): PartInterface
97
    {
98
        $clone = clone $this;
99
        $clone->decoratedPart = $this->decoratedPart->withoutHeader($name);
100
        return $clone;
101
    }
102
103
    /**
104
     * @param StreamInterface $body
105
     * @return PartInterface
106
     */
107
    public function withBody(StreamInterface $body): PartInterface
108
    {
109
        throw new \RuntimeException('Cannot modify body of ResourceAttachment');
110
    }
111
112
    /**
113
     * @return StreamInterface
114
     */
115 6
    public function getBody(): StreamInterface
116
    {
117 6
        return $this->decoratedPart->getBody();
118
    }
119
}
120