Issues (166)

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/Rdata/LocTest.php (6 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
declare(strict_types=1);
4
5
/*
6
 * This file is part of Badcow DNS Library.
7
 *
8
 * (c) Samuel Williams <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Badcow\DNS\Tests\Rdata;
15
16
use Badcow\DNS\Rdata\LOC;
17
use PHPUnit\Framework\TestCase;
18
19
class LocTest extends TestCase
20
{
21
    public function testOutput(): void
22
    {
23
        $rdata = new LOC();
24
        $rdata->setLatitude(-35.3075);
25
        $rdata->setLongitude(149.1244);
26
        $rdata->setAltitude(500);
27
        $rdata->setSize(20.12);
28
        $rdata->setHorizontalPrecision(200.3);
29
        $rdata->setVerticalPrecision(300.1);
30
31
        $expected = '35 18 27.000 S 149 7 27.840 E 500.00m 20.12m 200.30m 300.10m';
32
        $this->assertEquals($expected, $rdata->toText());
33
    }
34
35 View Code Duplication
    public function testSetLatitude(): void
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...
36
    {
37
        $latitude = -35.3075;
38
        $lat_dms = '35 18 27.000 S';
39
40
        $rdata = new LOC();
41
        $rdata->setLatitude($latitude);
42
43
        $this->assertEquals($latitude, $rdata->getLatitude());
44
        $this->assertEquals($latitude, $rdata->getLatitude(LOC::FORMAT_DECIMAL));
45
        $this->assertEquals($lat_dms, $rdata->getLatitude(LOC::FORMAT_DMS));
46
    }
47
48 View Code Duplication
    public function testSetLongitude(): void
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...
49
    {
50
        $longitude = 149.1244;
51
        $lon_dms = '149 7 27.840 E';
52
53
        $rdata = new LOC();
54
        $rdata->setLongitude($longitude);
55
56
        $this->assertEquals($longitude, $rdata->getLongitude());
57
        $this->assertEquals($longitude, $rdata->getLongitude(LOC::FORMAT_DECIMAL));
58
        $this->assertEquals($lon_dms, $rdata->getLongitude(LOC::FORMAT_DMS));
59
    }
60
61
    /**
62
     * @throws \OutOfRangeException
63
     */
64 View Code Duplication
    public function testSetAltitude1(): void
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...
65
    {
66
        $this->expectException(\OutOfRangeException::class);
67
        $this->expectExceptionMessage('The altitude must be on [-100000.00, 42849672.95].');
68
69
        $rdata = new LOC();
70
        $rdata->setAltitude(-100001);
71
    }
72
73
    /**
74
     * @throws \OutOfRangeException
75
     */
76
    public function testSetAltitude2(): void
77
    {
78
        $this->expectException(\OutOfRangeException::class);
79
        $this->expectExceptionMessage('The altitude must be on [-100000.00, 42849672.95].');
80
81
        $rdata = new LOC();
82
        $rdata->setAltitude(42849673);
83
    }
84
85
    public function testGetAltitude(): void
86
    {
87
        $rdata = new LOC();
88
        $altitude = 12345;
89
        $rdata->setAltitude($altitude);
90
        $this->assertEquals($altitude, $rdata->getAltitude());
91
    }
92
93
    /**
94
     * @thows \OutOfRangeException
95
     */
96 View Code Duplication
    public function testSetSize1(): void
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...
97
    {
98
        $this->expectException(\OutOfRangeException::class);
99
        $this->expectExceptionMessage('The size must be on [0, 9e9].');
100
101
        $rdata = new LOC();
102
        $rdata->setSize(-1);
103
    }
104
105
    /**
106
     * @throws \OutOfRangeException
107
     */
108
    public function testSetSize2(): void
109
    {
110
        $this->expectException(\OutOfRangeException::class);
111
        $this->expectExceptionMessage('The size must be on [0, 9e9].');
112
113
        $rdata = new LOC();
114
        $rdata->setSize(9000000002);
115
    }
116
117
    public function testGetSize(): void
118
    {
119
        $size = 1231;
120
        $rdata = new LOC();
121
        $rdata->setSize($size);
122
        $this->assertEquals($size, $rdata->getSize());
123
    }
124
125
    /**
126
     * @throws \OutOfRangeException
127
     */
128 View Code Duplication
    public function testSetVerticalPrecision1(): void
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...
129
    {
130
        $this->expectException(\OutOfRangeException::class);
131
        $this->expectExceptionMessage('The vertical precision must be on [0, 9e9].');
132
133
        $rdata = new LOC();
134
        $rdata->setVerticalPrecision(-1);
135
    }
136
137
    /**
138
     * @throws \OutOfRangeException
139
     */
140
    public function testSetVerticalPrecision2(): void
141
    {
142
        $this->expectException(\OutOfRangeException::class);
143
        $this->expectExceptionMessage('The vertical precision must be on [0, 9e9].');
144
145
        $rdata = new LOC();
146
        $rdata->setVerticalPrecision(9000000002);
147
    }
148
149
    /**
150
     * @throws \OutOfRangeException
151
     */
152 View Code Duplication
    public function testSetHorizontalPrecision1(): void
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...
153
    {
154
        $this->expectException(\OutOfRangeException::class);
155
        $this->expectExceptionMessage('The horizontal precision must be on [0, 9e9].');
156
157
        $rdata = new LOC();
158
        $rdata->setHorizontalPrecision(-1);
159
    }
160
161
    /**
162
     * @throws \OutOfRangeException
163
     */
164
    public function testSetHorizontalPrecision2(): void
165
    {
166
        $this->expectException(\OutOfRangeException::class);
167
        $this->expectExceptionMessage('The horizontal precision must be on [0, 9e9].');
168
169
        $rdata = new LOC();
170
        $rdata->setHorizontalPrecision(9000000002);
171
    }
172
173
    public function testGetHorizontalPrecision(): void
174
    {
175
        $hp = 127835;
176
        $rdata = new LOC();
177
        $rdata->setHorizontalPrecision($hp);
178
        $this->assertEquals($hp, $rdata->getHorizontalPrecision());
179
    }
180
181
    public function testGetVerticalPrecision(): void
182
    {
183
        $vp = 127835;
184
        $rdata = new LOC();
185
        $rdata->setVerticalPrecision($vp);
186
        $this->assertEquals($vp, $rdata->getVerticalPrecision());
187
    }
188
189
    public function testWire(): void
190
    {
191
        $loc = new LOC();
192
        $loc->setLatitude(-35.3075);
193
        $loc->setLongitude(149.1244);
194
        $loc->setAltitude(500);
195
        $loc->setSize(200);
196
        $loc->setHorizontalPrecision(200);
197
        $loc->setVerticalPrecision(300);
198
199
        $wireFormat = 'abc'.$loc->toWire();
200
        $offset = 3;
201
202
        $fromWire = new LOC();
203
        $fromWire->fromWire($wireFormat, $offset);
204
        $this->assertEquals($loc, $fromWire);
205
        $this->assertEquals(19, $offset);
206
    }
207
}
208