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.

Tests/Units/RealTests.php (4 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 Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Cubiche\Domain\System\Tests\Units;
12
13
use Cubiche\Domain\System\Real;
14
15
/**
16
 * RealTests class.
17
 *
18
 * @author Ivannis Suárez Jerez <[email protected]>
19
 */
20
class RealTests extends RealTestCase
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function positiveInfiniteNativeNumber()
26
    {
27
        return INF;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    protected function negativeInfiniteNativeNumber()
34
    {
35
        return -INF;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    protected function randomNativeNumber()
42
    {
43
        return (rand(1, 10) / 10) + 1;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    protected function uniqueNativeNumber()
50
    {
51
        return 20.32;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    protected function negativeNativeNumber()
58
    {
59
        return (rand(-1, -10) / 10) - 1;
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    protected function invalidNativeNumber()
66
    {
67
        return NAN;
68
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73
    protected function fromNative($value)
74
    {
75
        return Real::fromNative($value);
76
    }
77
78
    /*
79
     * Test add.
80
     */
81 View Code Duplication
    public function testAdd()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
82
    {
83
        parent::testAdd();
84
85
        $this
86
            ->given(
87
                $a = $this->fromNative($this->randomNativeNumber()),
88
                $b = $this->fromNative($this->randomNativeNumber())
89
            )
90
            ->when($c = $a->add($b->toInteger()))
91
            ->then
92
                ->object($c)
93
                    ->isInstanceOf(Real::class)
94
        ;
95
    }
96
97
    /*
98
     * Test sub.
99
     */
100 View Code Duplication
    public function testSub()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
101
    {
102
        parent::testSub();
103
104
        $this
105
            ->given(
106
                $a = $this->fromNative($this->randomNativeNumber()),
107
                $b = $this->fromNative($this->randomNativeNumber())
108
            )
109
            ->when($c = $a->sub($b->toInteger()))
110
            ->then
111
                ->object($c)
112
                    ->isInstanceOf(Real::class)
113
        ;
114
    }
115
116
    /*
117
     * Test mult.
118
     */
119 View Code Duplication
    public function testMult()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
120
    {
121
        parent::testMult();
122
123
        $this
124
            ->given(
125
                $a = $this->fromNative($this->randomNativeNumber()),
126
                $b = $this->fromNative($this->randomNativeNumber())
127
            )
128
            ->when($c = $a->mult($b->toInteger()))
129
            ->then
130
                ->object($c)
131
                    ->isInstanceOf(Real::class)
132
        ;
133
    }
134
135
    /*
136
     * Test div.
137
     */
138 View Code Duplication
    public function testDiv()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
139
    {
140
        parent::testDiv();
141
142
        $this
143
            ->given(
144
                $a = $this->fromNative($this->randomNativeNumber()),
145
                $b = $this->fromNative($this->randomNativeNumber())
146
            )
147
            ->when($c = $a->div($b->toInteger()))
148
            ->then
149
                ->object($c)
150
                    ->isInstanceOf(Real::class)
151
        ;
152
    }
153
154
    /*
155
     * Test sqrt.
156
     */
157
    public function testSqrt()
158
    {
159
        $this
160
            ->given(
161
                $native = $this->randomNativeNumber(),
162
                $invalidScale = -1.34,
163
                $a = $this->fromNative($native)
164
            )
165
            ->when(
166
                $b = $a->sqrt(),
167
                $c = $a->sqrt(2)
168
            )
169
            ->then
170
                ->object($b)
171
                    ->isInstanceOf(Real::class)
172
                ->variable($b->toNative())
173
                    ->isEqualTo(\sqrt($native))
174
                ->variable($c->toNative())
175
                    ->isEqualTo(\bcsqrt($native, 2))
176
                ->exception(function () use ($a, $invalidScale) {
177
                    $a->sqrt($invalidScale);
178
                })->isInstanceOf(\InvalidArgumentException::class)
179
        ;
180
    }
181
}
182