Issues (9)

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/SubStatement.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
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 Xabbuh\XApi\Model;
13
14
/**
15
 * A {@link Statement} included as part of a parent Statement.
16
 *
17
 * @author Christian Flothmann <[email protected]>
18
 */
19
final class SubStatement extends StatementObject
20
{
21
    private $verb;
22
    private $actor;
23
    private $object;
24
    private $result;
25
    private $created;
26
    private $context;
27
    private $attachments;
28
29
    /**
30
     * @param Attachment[]|null $attachments
31
     */
32
    public function __construct(Actor $actor, Verb $verb, StatementObject $object, Result $result = null, Context $context = null, \DateTime $created = null, array $attachments = null)
33
    {
34
        if ($object instanceof SubStatement) {
35
            throw new \InvalidArgumentException('Nesting sub statements is forbidden by the xAPI spec.');
36
        }
37
38
        $this->actor = $actor;
39
        $this->verb = $verb;
40
        $this->object = $object;
41
        $this->result = $result;
42
        $this->created = $created;
43
        $this->context = $context;
44
        $this->attachments = null !== $attachments ? array_values($attachments) : null;
45
    }
46
47
    public function withActor(Actor $actor): self
48
    {
49
        $subStatement = clone $this;
50
        $subStatement->actor = $actor;
51
52
        return $subStatement;
53
    }
54
55
    public function withVerb(Verb $verb): self
56
    {
57
        $subStatement = clone $this;
58
        $subStatement->verb = $verb;
59
60
        return $subStatement;
61
    }
62
63
    public function withObject(StatementObject $object): self
64
    {
65
        $subStatement = clone $this;
66
        $subStatement->object = $object;
67
68
        return $subStatement;
69
    }
70
71
    public function withResult(Result $result): self
72
    {
73
        $subStatement = clone $this;
74
        $subStatement->result = $result;
75
76
        return $subStatement;
77
    }
78
79
    public function withCreated(\DateTime $created = null): self
80
    {
81
        $statement = clone $this;
82
        $statement->created = $created;
83
84
        return $statement;
85
    }
86
87
    public function withContext(Context $context): self
88
    {
89
        $subStatement = clone $this;
90
        $subStatement->context = $context;
91
92
        return $subStatement;
93
    }
94
95
    /**
96
     * @param Attachment[]|null $attachments
97
     */
98
    public function withAttachments(array $attachments = null): self
99
    {
100
        $statement = clone $this;
101
        $statement->attachments = null !== $attachments ? array_values($attachments) : null;
102
103
        return $statement;
104
    }
105
106
    /**
107
     * Returns the Statement's {@link Verb}.
108
     */
109
    public function getVerb(): Verb
110
    {
111
        return $this->verb;
112
    }
113
114
    /**
115
     * Returns the Statement's {@link Actor}.
116
     */
117
    public function getActor(): Actor
118
    {
119
        return $this->actor;
120
    }
121
122
    /**
123
     * Returns the Statement's {@link StatementObject}.
124
     */
125
    public function getObject(): StatementObject
126
    {
127
        return $this->object;
128
    }
129
130
    /**
131
     * Returns the {@link Activity} {@link Result}.
132
     */
133
    public function getResult(): ?Result
134
    {
135
        return $this->result;
136
    }
137
138
    /**
139
     * Returns the timestamp of when the events described in this statement
140
     * occurred.
141
     */
142
    public function getCreated(): ?\DateTime
143
    {
144
        return $this->created;
145
    }
146
147
    /**
148
     * Returns the {@link Statement} {@link Context}.
149
     */
150
    public function getContext(): ?Context
151
    {
152
        return $this->context;
153
    }
154
155
    /**
156
     * @return Attachment[]|null
157
     */
158
    public function getAttachments(): ?array
159
    {
160
        return $this->attachments;
161
    }
162
163
    /**
164
     * Tests whether or not this Statement is a void Statement (i.e. it voids
165
     * another Statement).
166
     */
167
    public function isVoidStatement(): bool
168
    {
169
        return $this->verb->isVoidVerb();
170
    }
171
172
    /**
173
     * {@inheritdoc}
174
     */
175
    public function equals(StatementObject $statement): bool
176
    {
177
        if (!$statement instanceof SubStatement) {
178
            return false;
179
        }
180
181
        if (!$this->actor->equals($statement->actor)) {
182
            return false;
183
        }
184
185
        if (!$this->verb->equals($statement->verb)) {
186
            return false;
187
        }
188
189
        if (!$this->object->equals($statement->object)) {
190
            return false;
191
        }
192
193
        if (null === $this->result && null !== $statement->result) {
194
            return false;
195
        }
196
197
        if (null !== $this->result && null === $statement->result) {
198
            return false;
199
        }
200
201
        if (null !== $this->result && !$this->result->equals($statement->result)) {
0 ignored issues
show
It seems like $statement->result can be null; however, equals() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
202
            return false;
203
        }
204
205
        if ($this->created != $statement->created) {
206
            return false;
207
        }
208
209
        if (null !== $this->context xor null !== $statement->context) {
210
            return false;
211
        }
212
213
        if (null !== $this->context && null !== $statement->context && !$this->context->equals($statement->context)) {
214
            return false;
215
        }
216
217
        if (null !== $this->attachments xor null !== $statement->attachments) {
218
            return false;
219
        }
220
221
        if (null !== $this->attachments && null !== $statement->attachments) {
222
            if (count($this->attachments) !== count($statement->attachments)) {
223
                return false;
224
            }
225
226
            foreach ($this->attachments as $key => $attachment) {
227
                if (!$attachment->equals($statement->attachments[$key])) {
228
                    return false;
229
                }
230
            }
231
        }
232
233
        return true;
234
    }
235
}
236