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

Labels
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
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
 * An {@link Actor Actor's} outcome related to the {@link Statement} in which
16
 * it is included.
17
 *
18
 * @author Christian Flothmann <[email protected]>
19
 */
20
final class Result
21
{
22
    private $score;
23
    private $success;
24
    private $completion;
25
    private $response;
26
    private $duration;
27
    private $extensions;
28
29
    public function __construct(Score $score = null, bool $success = null, bool $completion = null, string $response = null, string $duration = null, Extensions $extensions = null)
30
    {
31
        $this->score = $score;
32
        $this->success = $success;
33
        $this->completion = $completion;
34
        $this->response = $response;
35
        $this->duration = $duration;
36
        $this->extensions = $extensions;
37
    }
38
39
    public function withScore(Score $score = null): self
40
    {
41
        $result = clone $this;
42
        $result->score = $score;
43
44
        return $result;
45
    }
46
47
    public function withSuccess(bool $success = null): self
48
    {
49
        $result = clone $this;
50
        $result->success = $success;
51
52
        return $result;
53
    }
54
55
    public function withCompletion(bool $completion = null): self
56
    {
57
        $result = clone $this;
58
        $result->completion = $completion;
59
60
        return $result;
61
    }
62
63
    public function withResponse(string $response = null): self
64
    {
65
        $result = clone $this;
66
        $result->response = $response;
67
68
        return $result;
69
    }
70
71
    public function withDuration(string $duration = null): self
72
    {
73
        $result = clone $this;
74
        $result->duration = $duration;
75
76
        return $result;
77
    }
78
79
    public function withExtensions(Extensions $extensions = null): self
80
    {
81
        $result = clone $this;
82
        $result->extensions = $extensions;
83
84
        return $result;
85
    }
86
87
    /**
88
     * Returns the user's score.
89
     */
90
    public function getScore(): ?Score
91
    {
92
        return $this->score;
93
    }
94
95
    /**
96
     * Returns whether or not the user finished a task successfully.
97
     */
98
    public function getSuccess(): ?bool
99
    {
100
        return $this->success;
101
    }
102
103
    /**
104
     * Returns the completion status.
105
     */
106
    public function getCompletion(): ?bool
107
    {
108
        return $this->completion;
109
    }
110
111
    /**
112
     * Returns the response.
113
     */
114
    public function getResponse(): ?string
115
    {
116
        return $this->response;
117
    }
118
119
    /**
120
     * Returns the period of time over which the Activity was performed.
121
     */
122
    public function getDuration(): ?string
123
    {
124
        return $this->duration;
125
    }
126
127
    /**
128
     * Returns the extensions associated with the result.
129
     */
130
    public function getExtensions(): ?Extensions
131
    {
132
        return $this->extensions;
133
    }
134
135
    /**
136
     * Checks if another result is equal.
137
     *
138
     * Two results are equal if and only if all of their properties are equal.
139
     */
140
    public function equals(Result $result): bool
141
    {
142
        if (null !== $this->score xor null !== $result->score) {
143
            return false;
144
        }
145
146
        if (null !== $this->score && !$this->score->equals($result->score)) {
0 ignored issues
show
It seems like $result->score 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...
147
            return false;
148
        }
149
150
        if ($this->success !== $result->success) {
151
            return false;
152
        }
153
154
        if ($this->completion !== $result->completion) {
155
            return false;
156
        }
157
158
        if ($this->response !== $result->response) {
159
            return false;
160
        }
161
162
        if ($this->duration !== $result->duration) {
163
            return false;
164
        }
165
166
        if (null !== $this->extensions xor null !== $result->extensions) {
167
            return false;
168
        }
169
170
        if (null !== $this->extensions && null !== $result->extensions && !$this->extensions->equals($result->extensions)) {
171
            return false;
172
        }
173
174
        return true;
175
    }
176
}
177