Issues (41)

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/Mapping/Context.php (10 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
/*
4
 * This file is part of the xAPI package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace XApi\Repository\Doctrine\Mapping;
13
14
use Xabbuh\XApi\Model\Context as ContextModel;
15
use Xabbuh\XApi\Model\ContextActivities;
16
use Xabbuh\XApi\Model\StatementId;
17
use Xabbuh\XApi\Model\StatementReference;
18
19
/**
20
 * @author Christian Flothmann <[email protected]>
21
 */
22
class Context
23
{
24
    public $identifier;
25
26
    /**
27
     * @var string|null
28
     */
29
    public $registration;
30
31
    /**
32
     * @var StatementObject|null
33
     */
34
    public $instructor;
35
36
    /**
37
     * @var StatementObject|null
38
     */
39
    public $team;
40
41
    /**
42
     * @var bool|null
43
     */
44
    public $hasContextActivities;
45
46
    /**
47
     * @var StatementObject[]|null
48
     */
49
    public $parentActivities;
50
51
    /**
52
     * @var StatementObject[]|null
53
     */
54
    public $groupingActivities;
55
56
    /**
57
     * @var StatementObject[]|null
58
     */
59
    public $categoryActivities;
60
61
    /**
62
     * @var StatementObject[]|null
63
     */
64
    public $otherActivities;
65
66
    /**
67
     * @var string|null
68
     */
69
    public $revision;
70
71
    /**
72
     * @var string|null
73
     */
74
    public $platform;
75
76
    /**
77
     * @var string|null
78
     */
79
    public $language;
80
81
    /**
82
     * @var string|null
83
     */
84
    public $statement;
85
86
    /**
87
     * @var Extensions|null
88
     */
89
    public $extensions;
90
91
    public static function fromModel(ContextModel $model)
92
    {
93
        $context = new self();
94
        $context->registration = $model->getRegistration();
95
        $context->revision = $model->getRevision();
96
        $context->platform = $model->getPlatform();
97
        $context->language = $model->getLanguage();
98
99
        if (null !== $instructor = $model->getInstructor()) {
100
            $context->instructor = StatementObject::fromModel($instructor);
101
        }
102
103
        if (null !== $team = $model->getTeam()) {
104
            $context->team = StatementObject::fromModel($team);
105
        }
106
107
        if (null !== $contextActivities = $model->getContextActivities()) {
108
            $context->hasContextActivities = true;
109
110
            if (null !== $parentActivities = $contextActivities->getParentActivities()) {
111
                $context->parentActivities = array();
112
113
                foreach ($parentActivities as $parentActivity) {
114
                    $activity = StatementObject::fromModel($parentActivity);
115
                    $activity->parentContext = $context;
0 ignored issues
show
Documentation Bug introduced by
It seems like $context of type object<XApi\Repository\Doctrine\Mapping\Context> is incompatible with the declared type object<XApi\Repository\D...Mapping\Statement>|null of property $parentContext.

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...
116
                    $context->parentActivities[] = $activity;
117
                }
118
            }
119
120
            if (null !== $groupingActivities = $contextActivities->getGroupingActivities()) {
121
                $context->groupingActivities = array();
122
123
                foreach ($groupingActivities as $groupingActivity) {
124
                    $activity = StatementObject::fromModel($groupingActivity);
125
                    $activity->groupingContext = $context;
0 ignored issues
show
Documentation Bug introduced by
It seems like $context of type object<XApi\Repository\Doctrine\Mapping\Context> is incompatible with the declared type object<XApi\Repository\D...Mapping\Statement>|null of property $groupingContext.

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...
126
                    $context->groupingActivities[] = $activity;
127
                }
128
            }
129
130
            if (null !== $categoryActivities = $contextActivities->getCategoryActivities()) {
131
                $context->categoryActivities = array();
132
133
                foreach ($categoryActivities as $categoryActivity) {
134
                    $activity = StatementObject::fromModel($categoryActivity);
135
                    $activity->categoryContext = $context;
0 ignored issues
show
Documentation Bug introduced by
It seems like $context of type object<XApi\Repository\Doctrine\Mapping\Context> is incompatible with the declared type object<XApi\Repository\D...Mapping\Statement>|null of property $categoryContext.

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...
136
                    $context->categoryActivities[] = $activity;
137
                }
138
            }
139
140
            if (null !== $otherActivities = $contextActivities->getOtherActivities()) {
141
                $context->otherActivities = array();
142
143
                foreach ($otherActivities as $otherActivity) {
144
                    $activity = StatementObject::fromModel($otherActivity);
145
                    $activity->otherContext = $context;
0 ignored issues
show
Documentation Bug introduced by
It seems like $context of type object<XApi\Repository\Doctrine\Mapping\Context> is incompatible with the declared type object<XApi\Repository\D...Mapping\Statement>|null of property $otherContext.

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...
146
                    $context->otherActivities[] = $activity;
147
                }
148
            }
149
        } else {
150
            $context->hasContextActivities = false;
151
        }
152
153
        if (null !== $statementReference = $model->getStatement()) {
154
            $context->statement = $statementReference->getStatementId()->getValue();
155
        }
156
157
        if (null !== $contextExtensions = $model->getExtensions()) {
158
            $context->extensions = Extensions::fromModel($contextExtensions);
159
        }
160
161
        return $context;
162
    }
163
164
    public function getModel()
165
    {
166
        $context = new ContextModel();
167
        $context = $context->withRegistration($this->registration);
168
        $context = $context->withRevision($this->revision);
169
        $context = $context->withPlatform($this->platform);
170
        $context = $context->withLanguage($this->language);
171
172
        if (null !== $this->instructor) {
173
            $context = $context->withInstructor($this->instructor->getModel());
0 ignored issues
show
It seems like $this->instructor->getModel() targeting XApi\Repository\Doctrine...ementObject::getModel() can also be of type object<Xabbuh\XApi\Model\Activity> or object<Xabbuh\XApi\Model\StatementReference> or object<Xabbuh\XApi\Model\SubStatement>; however, Xabbuh\XApi\Model\Context::withInstructor() does only seem to accept object<Xabbuh\XApi\Model\Actor>, 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...
174
        }
175
176
        if (null !== $this->team) {
177
            $context = $context->withTeam($this->team->getModel());
0 ignored issues
show
It seems like $this->team->getModel() targeting XApi\Repository\Doctrine...ementObject::getModel() can also be of type object<Xabbuh\XApi\Model\Activity> or object<Xabbuh\XApi\Model\Agent> or object<Xabbuh\XApi\Model\StatementReference> or object<Xabbuh\XApi\Model\SubStatement>; however, Xabbuh\XApi\Model\Context::withTeam() does only seem to accept object<Xabbuh\XApi\Model\Group>, 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...
178
        }
179
180
        if ($this->hasContextActivities) {
181
            $contextActivities = new ContextActivities();
182
183
            if (null !== $this->parentActivities) {
184
                foreach ($this->parentActivities as $contextParentActivity) {
185
                    $contextActivities = $contextActivities->withAddedParentActivity($contextParentActivity->getModel());
0 ignored issues
show
It seems like $contextParentActivity->getModel() targeting XApi\Repository\Doctrine...ementObject::getModel() can also be of type object<Xabbuh\XApi\Model\Agent> or object<Xabbuh\XApi\Model\Group> or object<Xabbuh\XApi\Model\StatementReference> or object<Xabbuh\XApi\Model\SubStatement>; however, Xabbuh\XApi\Model\Contex...thAddedParentActivity() does only seem to accept object<Xabbuh\XApi\Model\Activity>, 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...
186
                }
187
            }
188
189
            if (null !== $this->groupingActivities) {
190
                foreach ($this->groupingActivities as $contextGroupingActivity) {
191
                    $contextActivities = $contextActivities->withAddedGroupingActivity($contextGroupingActivity->getModel());
0 ignored issues
show
It seems like $contextGroupingActivity->getModel() targeting XApi\Repository\Doctrine...ementObject::getModel() can also be of type object<Xabbuh\XApi\Model\Agent> or object<Xabbuh\XApi\Model\Group> or object<Xabbuh\XApi\Model\StatementReference> or object<Xabbuh\XApi\Model\SubStatement>; however, Xabbuh\XApi\Model\Contex...AddedGroupingActivity() does only seem to accept object<Xabbuh\XApi\Model\Activity>, 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...
192
                }
193
            }
194
195
            if (null !== $this->categoryActivities) {
196
                foreach ($this->categoryActivities as $contextCategoryActivity) {
197
                    $contextActivities = $contextActivities->withAddedCategoryActivity($contextCategoryActivity->getModel());
0 ignored issues
show
It seems like $contextCategoryActivity->getModel() targeting XApi\Repository\Doctrine...ementObject::getModel() can also be of type object<Xabbuh\XApi\Model\Agent> or object<Xabbuh\XApi\Model\Group> or object<Xabbuh\XApi\Model\StatementReference> or object<Xabbuh\XApi\Model\SubStatement>; however, Xabbuh\XApi\Model\Contex...AddedCategoryActivity() does only seem to accept object<Xabbuh\XApi\Model\Activity>, 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...
198
                }
199
            }
200
201
            if (null !== $this->otherActivities) {
202
                foreach ($this->otherActivities as $contextOtherActivity) {
203
                    $contextActivities = $contextActivities->withAddedOtherActivity($contextOtherActivity->getModel());
0 ignored issues
show
It seems like $contextOtherActivity->getModel() targeting XApi\Repository\Doctrine...ementObject::getModel() can also be of type object<Xabbuh\XApi\Model\Agent> or object<Xabbuh\XApi\Model\Group> or object<Xabbuh\XApi\Model\StatementReference> or object<Xabbuh\XApi\Model\SubStatement>; however, Xabbuh\XApi\Model\Contex...ithAddedOtherActivity() does only seem to accept object<Xabbuh\XApi\Model\Activity>, 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...
204
                }
205
            }
206
207
            $context = $context->withContextActivities($contextActivities);
208
        }
209
210
        if (null !== $this->statement) {
211
            $context = $context->withStatement(new StatementReference(StatementId::fromString($this->statement)));
212
        }
213
214
        if (null !== $this->extensions) {
215
            $context = $context->withExtensions($this->extensions->getModel());
216
        }
217
218
        return $context;
219
    }
220
}
221