Issues (38)

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/FeedIo/ParserAbstract.php (1 issue)

Severity

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 declare(strict_types=1);
2
/*
3
 * This file is part of the feed-io package.
4
 *
5
 * (c) Alexandre Debril <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace FeedIo;
12
13
use FeedIo\Parser\UnsupportedFormatException;
14
use FeedIo\Reader\Document;
15
use FeedIo\Feed\ItemInterface;
16
use FeedIo\Feed\NodeInterface;
17
use Psr\Log\LoggerInterface;
18
19
/**
20
 * Parses a document if its format matches the parser's standard
21
 *
22
 * Depends on :
23
 *  - FeedIo\StandardAbstract
24
 *  - Psr\Log\LoggerInterface
25
 *
26
 */
27
abstract class ParserAbstract
28
{
29
30
    /**
31
     * @var \Psr\Log\LoggerInterface
32
     */
33
    protected $logger;
34
35
    /**
36
     * @var array[FilterInterface]
37
     */
38
    protected $filters = array();
39
40
    /**
41
     * @var StandardAbstract
42
     */
43
    protected $standard;
44
45
    /**
46
     * @param StandardAbstract $standard
47
     * @param LoggerInterface  $logger
48
     */
49 45
    public function __construct(StandardAbstract $standard, LoggerInterface $logger)
50
    {
51 45
        $this->standard = $standard;
52 45
        $this->logger = $logger;
53 45
    }
54
55
    /**
56
     * Tries to parse the document
57
     *
58
     * @param Document $document
59
     * @param FeedInterface $feed
60
     * @return \FeedIo\FeedInterface
61
     * @throws \FeedIo\Parser\UnsupportedFormatException
62
     */
63 16
    public function parse(Document $document, FeedInterface $feed) : FeedInterface
64
    {
65 16
        if (!$this->standard->canHandle($document)) {
66 1
            throw new UnsupportedFormatException('this is not a supported format');
67
        }
68
69 15
        $this->checkBodyStructure($document, $this->standard->getMandatoryFields());
0 ignored issues
show
$this->standard->getMandatoryFields() is of type array, but the function expects a object<FeedIo\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
70 14
        $this->parseContent($document, $feed);
71
72 14
        return $feed;
73
    }
74
75
    /**
76
     * This method is called by parse() if and only if the checkBodyStructure was successful
77
     *
78
     * @param Document $document
79
     * @param FeedInterface $feed
80
     * @return \FeedIo\FeedInterface
81
     */
82
    abstract public function parseContent(Document $document, FeedInterface $feed) : FeedInterface;
83
84
    /**
85
     * @param Document $document
86
     * @param iterable $mandatoryFields
87
     * @throws MissingFieldsException
88
     * @return bool
89
     */
90
    abstract public function checkBodyStructure(Document $document, iterable $mandatoryFields) : bool;
91
92
    /**
93
     * @return StandardAbstract
94
     */
95 29
    public function getStandard() : StandardAbstract
96
    {
97 29
        return $this->standard;
98
    }
99
100
    /**
101
     * @param  FeedInterface $feed
102
     * @param  NodeInterface $item
103
     * @return ParserAbstract
104
     */
105 11
    public function addValidItem(FeedInterface $feed, NodeInterface $item) : ParserAbstract
106
    {
107 11
        if ($item instanceof ItemInterface && $this->isValid($item)) {
108 10
            $feed->add($item);
109
        }
110
111 11
        return $this;
112
    }
113
114
    /**
115
     * @param  ItemInterface $item
116
     * @return bool
117
     */
118 13
    public function isValid(ItemInterface $item) : bool
119
    {
120 13
        foreach ($this->filters as $filter) {
121 3
            if (!$filter->isValid($item)) {
122 2
                return false;
123
            }
124
        }
125
126 11
        return true;
127
    }
128
129
    /**
130
     * @param  FilterInterface $filter
131
     * @return ParserAbstract
132
     */
133 4
    public function addFilter(FilterInterface $filter) : ParserAbstract
134
    {
135 4
        $this->filters[] = $filter;
136
137 4
        return $this;
138
    }
139
140
    /**
141
     * Reset filters
142
     * @return ParserAbstract
143
     */
144 2
    public function resetFilters() : ParserAbstract
145
    {
146 2
        $this->filters = [];
147
148 2
        return $this;
149
    }
150
}
151