Issues (41)

Security Analysis    not enabled

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/Inbounder/Parsers/PostmarkappParser.php (23 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
namespace Inbounder\Parsers;
4
5
use Illuminate\Support\Collection;
6
use Inbounder\Parsers\Contracts\EmailParserInterface;
7
use Inbounder\Parsers\Contracts\ParserInterface;
8
use Inbounder\Parsers\Objects\Attachment;
9
use Inbounder\Parsers\Objects\Email\Address;
10
use Inbounder\Parsers\Objects\Email\Header;
11
12
class PostmarkappParser extends AbstractParser implements EmailParserInterface
13
{
14
    /**
15
     * Parse the request and return itself.
16
     *
17
     * @return ParserInterface
18
     */
19
    public function parse() : ParserInterface
20
    {
21
        $this->from = $this->from();
0 ignored issues
show
The property from does not exist on object<Inbounder\Parsers\PostmarkappParser>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
22
        $this->replyTo = $this->replyTo();
0 ignored issues
show
The property replyTo does not exist on object<Inbounder\Parsers\PostmarkappParser>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
23
24
        $this->to = $this->to();
0 ignored issues
show
The property to does not exist on object<Inbounder\Parsers\PostmarkappParser>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
25
        $this->cc = $this->cc();
0 ignored issues
show
The property cc does not exist on object<Inbounder\Parsers\PostmarkappParser>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
26
        $this->bcc = $this->bcc();
0 ignored issues
show
The property bcc does not exist on object<Inbounder\Parsers\PostmarkappParser>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
27
28
        $this->subject = $this->subject();
0 ignored issues
show
The property subject does not exist on object<Inbounder\Parsers\PostmarkappParser>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
29
        $this->body = $this->body();
0 ignored issues
show
The property body does not exist on object<Inbounder\Parsers\PostmarkappParser>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
30
31
        $this->attachements = $this->attachements();
0 ignored issues
show
The property attachements does not exist on object<Inbounder\Parsers\PostmarkappParser>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
32
33
        return $this;
34
    }
35
36
    /**
37
     * Return an Address object from an input.
38
     *
39
     * @param array $input
40
     *
41
     * @return Address
42
     */
43
    protected function address(array $input) : Address
44
    {
45
        return new Address($input['Email'], $input['Name'], $input['MailboxHash']);
46
    }
47
48
    /**
49
     * Parse an array of addresses.
50
     *
51
     * @param array $input
52
     *
53
     * @return Collection
54
     */
55
    protected function foreachAddress(array $input) : Collection
56
    {
57
        $collection = new Collection();
58
59
        foreach ($input as $address) {
60
            $collection->push($this->address($address));
61
        }
62
63
        return $collection;
64
    }
65
66
    /**
67
     * From property.
68
     *
69
     * @return Address
70
     */
71
    public function from() : Address
72
    {
73
        return $this->address($this->input('FromFull'));
0 ignored issues
show
It seems like $this->input('FromFull') targeting Inbounder\Parsers\AbstractParser::input() can also be of type string; however, Inbounder\Parsers\PostmarkappParser::address() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
74
    }
75
76
    /**
77
     * Reply-to property.
78
     *
79
     * @todo: edit this to handler the reply-to parameter
80
     *
81
     * @return Address
82
     */
83
    public function replyTo() : Address
84
    {
85
        return $this->address($this->input('FromFull'));
0 ignored issues
show
It seems like $this->input('FromFull') targeting Inbounder\Parsers\AbstractParser::input() can also be of type string; however, Inbounder\Parsers\PostmarkappParser::address() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
86
    }
87
88
    /**
89
     * To property.
90
     *
91
     * @return Collection<Address>
0 ignored issues
show
The doc-type Collection<Address> could not be parsed: Expected "|" or "end of type", but got "<" at position 10. (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...
92
     */
93
    public function to() : Collection
94
    {
95
        return $this->foreachAddress($this->input('ToFull'));
0 ignored issues
show
It seems like $this->input('ToFull') targeting Inbounder\Parsers\AbstractParser::input() can also be of type string; however, Inbounder\Parsers\Postma...arser::foreachAddress() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
96
    }
97
98
    /**
99
     * CC property.
100
     *
101
     * @return Collection<Address>
0 ignored issues
show
The doc-type Collection<Address> could not be parsed: Expected "|" or "end of type", but got "<" at position 10. (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...
102
     */
103
    public function cc() : Collection
104
    {
105
        return $this->foreachAddress($this->input('CcFull'));
0 ignored issues
show
It seems like $this->input('CcFull') targeting Inbounder\Parsers\AbstractParser::input() can also be of type string; however, Inbounder\Parsers\Postma...arser::foreachAddress() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
106
    }
107
108
    /**
109
     * BCC property.
110
     *
111
     * @return Collection<Address>
0 ignored issues
show
The doc-type Collection<Address> could not be parsed: Expected "|" or "end of type", but got "<" at position 10. (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...
112
     */
113
    public function bcc() : Collection
114
    {
115
        return $this->foreachAddress($this->input('BccFull'));
0 ignored issues
show
It seems like $this->input('BccFull') targeting Inbounder\Parsers\AbstractParser::input() can also be of type string; however, Inbounder\Parsers\Postma...arser::foreachAddress() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
116
    }
117
118
    /**
119
     * Subject property.
120
     *
121
     * @return string
122
     */
123
    public function subject()
124
    {
125
        return $this->input('Subject');
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->input('Subject'); of type string|array adds the type array to the return on line 125 which is incompatible with the return type declared by the interface Inbounder\Parsers\Contra...arserInterface::subject of type string.
Loading history...
126
    }
127
128
    /**
129
     * Body.
130
     *
131
     * @return string
132
     */
133
    public function body()
134
    {
135
        $body = $this->bodyHtml();
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->bodyHtml(); of type string|array adds the type array to the return on line 141 which is incompatible with the return type declared by the interface Inbounder\Parsers\Contra...ilParserInterface::body of type string.
Loading history...
136
137
        if ($this->bodyIsText()) {
138
            $body = $this->bodyText();
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->bodyText(); of type string|array adds the type array to the return on line 141 which is incompatible with the return type declared by the interface Inbounder\Parsers\Contra...ilParserInterface::body of type string.
Loading history...
139
        }
140
141
        return $body;
142
    }
143
144
    /**
145
     * Return the body html.
146
     *
147
     * @return string
148
     */
149
    public function bodyHtml()
150
    {
151
        return $this->input('HtmlBody');
152
    }
153
154
    /**
155
     * Return the body text.
156
     *
157
     * @return string
158
     */
159
    public function bodyText()
160
    {
161
        return $this->input('TextBody');
162
    }
163
164
    /**
165
     * IsText.
166
     *
167
     * @return bool
168
     */
169
    public function bodyIsText()
170
    {
171
        return !$this->bodyIsHtml();
172
    }
173
174
    /**
175
     * IsHtml.
176
     *
177
     * @return bool
178
     */
179
    public function bodyIsHtml()
180
    {
181
        return !is_null($this->input('HtmlBody')) || $this->input('HtmlBody') !== '';
182
    }
183
184
    /**
185
     * Get email headers.
186
     *
187
     * @return Collection
188
     */
189
    public function headers() : Collection
190
    {
191
        $collection = new Collection();
192
193
        foreach ($this->input('Headers') as $header) {
0 ignored issues
show
The expression $this->input('Headers') of type string|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
194
            $collection->push(new Header($header['Name'], $header['Value']));
195
        }
196
197
        return $collection;
198
    }
199
200
    /**
201
     * retrieve a email header.
202
     *
203
     * return Array
204
     */
205
    public function header($name)
206
    {
207
        return $this->headers()->filter(function ($header) use ($name) {
208
            return $header->name === $name;
209
        })->first();
210
    }
211
212
    /**
213
     * Determinate if the email is marked as spam.
214
     *
215
     * @return bool
216
     */
217
    public function isSpam()
218
    {
219
        $header = $this->header('X-Spam-Flag');
220
221
        return $header->value === 'NO' ? false : true;
222
    }
223
224
    /**
225
     * Has attachements.
226
     *
227
     * @return bool
228
     */
229
    public function hasAttachements()
230
    {
231
        return $this->attachements->isEmpty();
0 ignored issues
show
The property attachements does not exist on object<Inbounder\Parsers\PostmarkappParser>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
232
    }
233
234
    /**
235
     * Attachments.
236
     *
237
     * @return Collection<File>
0 ignored issues
show
The doc-type Collection<File> could not be parsed: Expected "|" or "end of type", but got "<" at position 10. (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...
238
     */
239
    public function attachements() : Collection
240
    {
241
        $collection = new Collection();
242
243
        foreach ($this->input('Attachments') as $attachment) {
0 ignored issues
show
The expression $this->input('Attachments') of type string|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
244
            $collection->push(
245
                new Attachment(
246
                    $attachment['Name'],
247
                    (isset($attachment['Content']) ? $attachment['Content'] : ''),
248
                    $attachment['ContentType'],
249
                    $attachment['ContentLength']
250
                )
251
            );
252
        }
253
254
        return $collection;
255
    }
256
}
257