Issues (23)

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/Parsers/AbstractParser.php (3 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 Sportic\Timing\RaceTecClient\Parsers;
4
5
use Sportic\Timing\CommonClient\Content\ContentFactory;
6
use Sportic\Timing\CommonClient\Models\AbstractModel;
7
use Sportic\Timing\RaceTecClient\Scrapers\AbstractScraper;
8
use Symfony\Component\DomCrawler\Crawler;
9
10
/**
11
 * Class AbstractParser
12
 * @package Sportic\Timing\RaceTecClient\Parsers
13
 */
14
abstract class AbstractParser
15
{
16
17
    /**
18
     * @var AbstractScraper
19
     */
20
    protected $scraper;
21
22
    /**
23
     * @var Crawler
24
     */
25
    protected $crawler;
26
27
    /**
28
     * @var null|boolean
29
     */
30
    protected $isValidContent = null;
31
32
    /**
33
     * @var null|AbstractContent
34
     */
35
    protected $contents = null;
36
37
    /**
38
     * @return mixed
39
     */
40
    public function getContent()
41
    {
42
        if ($this->contents === null) {
43
            if ($this->isValidContent()) {
44
                $contents = $this->generateContent();
45
                $this->contents = ContentFactory::createFromArray($contents);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Sportic\Timing\CommonCl...ateFromArray($contents) of type object<Sportic\Timing\Co...ontent\AbstractContent> is incompatible with the declared type null|object<Sportic\Timi...arsers\AbstractContent> of property $contents.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
46
            } else {
47
                $this->contents = false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false is incompatible with the declared type null|object<Sportic\Timi...arsers\AbstractContent> of property $contents.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
48
            }
49
        }
50
51
        return $this->contents;
52
    }
53
54
    abstract protected function generateContent();
55
56
    /**
57
     * @return bool|null
58
     */
59
    public function isValidContent()
60
    {
61
        if ($this->isValidContent == null) {
62
            $this->doValidation();
63
            $this->isValidContent = true;
64
        }
65
66
        return $this->isValidContent;
67
    }
68
69
    /**
70
     * @return void
71
     */
72
    protected function doValidation()
73
    {
74
    }
75
76
    /**
77
     * @return AbstractScraper
78
     */
79
    public function getScraper()
80
    {
81
        return $this->scraper;
82
    }
83
84
    /**
85
     * @param AbstractScraper $scraper
86
     */
87
    public function setScraper($scraper)
88
    {
89
        $this->scraper = $scraper;
90
    }
91
92
    /**
93
     * @return Crawler
94
     */
95
    public function getCrawler(): Crawler
96
    {
97
        return $this->crawler;
98
    }
99
100
    /**
101
     * @param Crawler $crawler
102
     */
103
    public function setCrawler(Crawler $crawler)
104
    {
105
        $this->crawler = $crawler;
106
    }
107
108
    /**
109
     * @return array
110
     */
111
    public function getArray()
112
    {
113
        return $this->getContent();
114
    }
115
116
    /**
117
     * @return AbstractModel
118
     */
119
    public function getModel()
120
    {
121
        $model      = $this->getNewModel();
122
        $parameters = $this->getContent();
123
        $model->setParameters($parameters);
0 ignored issues
show
It seems like $parameters defined by $this->getContent() on line 122 can also be of type false or object<Sportic\Timing\Co...ontent\AbstractContent>; however, Sportic\Timing\CommonCli...tModel::setParameters() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
124
125
        return $model;
126
    }
127
128
    /**
129
     * @return AbstractModel
130
     */
131
    public function getNewModel()
132
    {
133
        $className = $this->getModelClassName();
134
        $model     = new $className();
135
136
        return $model;
137
    }
138
139
    abstract public function getModelClassName();
140
141
    /**
142
     * @return string
143
     */
144
    protected function getContentClassName()
145
    {
146
        return GenericContent::class;
147
    }
148
}
149