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/TkeyTest.php (8 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\Parser\Tokens;
17
use Badcow\DNS\Rdata\Factory;
18
use Badcow\DNS\Rdata\TKEY;
19
use PHPUnit\Framework\TestCase;
20
21
class TkeyTest extends TestCase
22
{
23
    private $dummyKeyData = <<<DATA
24
BAcIAwcAAAQGAQMGBwEFBwEGBAgGBwUFBwAIBwIDAwUEBgYIBQQBAwYIBQgFBQY
25
DAggDBgUCAgIBCAMDAwgDBQIFAggABggIAwMFBgABBwYDBAYHAwUEAAUIAgIICA
26
EHAAMIAAYBAAUEBggGAAMAAQMGAwAHAwUEAQQDBAgCCAAABQUAAQUCAAYEAAUHB
27
AMHAwYDAgQHBQEHAQcBAAQECAcEBQcHBwMBBAIIAQIGAAYCAAcDBwUIAQEBAwgI
28
BgQDBgECBQgGAQQGAQABAQUGAAUCBwQGAAQGCAUHBwMGAQcCAwcAAAIEAgECAQI
29
ECAgHBQQHAQgHBgAHCAIBAwUCAQMCAAEFBQMBAgcCAgIACAMECAEFCAUIBQEFAg
30
YGAgUIBQEHAggBCAcEBgMGAQYIAAAAAwQDAgUHCAUBAggDAgUAAAUBBwcBAwYEC
31
AIABAgIBwMEAggGAwUFAQAEBAQAAgIIBwgFBgMDCAABBggCAgcCBQYEBgIAAgIG
32
AwUFBAAFBQgGBwgGBwYBAQAGAQMHBwEICAYBBAMGAwEIBgIDAwgABAUCBwAIBAc
33
GAwcGBQEDAQcBBAMIAgUCAAUGAAgFBAQIBQcEBgAFAgUIAAcABggCAAcHBAgCBw
34
MIAAQIBwgBBAAIAAMDAQQBAwACAQUCAgQABgIICAMIBAAABgYBBAAAAwAICAUEA
35
QAFBAEFBQIGAQcHAAMECAMAAwUICAgFBQAHBgEBBgMCBgQABwUHCAACCAAGAgAC
36
BAAABAMHBQcEAAAFBwIEC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BAcIBQACAQUIAwYACAMDAgUGAAUFAAQCAAgCAwgDBgIHAgUIA
56
gMABwcEAQQEAwgIBQgCAQIIAwAHBQgFAwMGCAgGAAADBggHAAcIAgcBBwgIAQEE
57
AAYFCAAIBQUECAYBAgYACAcCAAAGAwIEAQEFCAcDAwIGBgcEBwAIBAYIBgEFBgM
58
DBgEACAcDAAEFCAQDAQQHBwgCAwIECAUHAgMFBgQDAggHAwMDBgUCCAYABwEBAw
59
MDAwQDBAUHAQMCBwgEAQEABgYIAQcGCAYIAgUABwIHAAAABQcIBAIBBwQHAQUDB
60
wADAwQDBQUABwQEBQEAAAIGAgMBBQUIBQYDAAcHAQUBBAIHBwYIBgUHAAYCAAIB
61
BgMFAggAAQQDAgQABAUIAAYEAgEIAQgIAwACAQgCBwEDBAIFBQgEAQYFAgECAAM
62
GCAgBBwEGAwcFBwcABgUGAgUFAgYEAAIFBgcEBwcGAQgDAAcBAgMDAQAHBQYCBQ
63
MBBAYBAgEBBgYFBgIFBQUDBwIDBQcCAwUHBwgDBQAEBwUFAQAFBAMCBwUDAwQCB
64
gAGBAACCAIFBgcABQEECAcIBQgCBQgDBwAHBwMABQUEAQMIBQYDAwgABAQIBwEA
65
CAUABAQEBgQEBgQDAAYBBAAFAwEDBwcEBQIAAAQFAAYAAgUDAQAECAUEBAICBQg
66
EBQEHAwYABgAEAgIAAAEEAQMAAAUBBQcEAgUHBQcCAQcIAwMCBQMEAgYBAAcFAg
67
IDAAMEBQIBCAEACAYABggEAwMABwYCAQgGAQUBBwQFAgUFBQgFAAMCAAMABwIEB
68
ggCBQMBBQABBgQHAgUCBAcCAwYHCAcGBgAEBgYAAQYIBwQBBAECCAICAQEIAQEI
69
BAICBQcHCAAFBAcBAQQDBgYCBggAAggEAgMEAwIDBwgFAwIBBAAIAQAFAwACCAg
70
CAwgFCAcBCAUBAAYFAAQGBwUGBwYABQQIBQYHAAUIBg==
71
DATA;
72
73
    public function testGetType(): void
74
    {
75
        $tkey = new TKEY();
76
        $this->assertEquals('TKEY', $tkey->getType());
77
    }
78
79
    public function testGetTypeCode(): void
80
    {
81
        $tkey = new TKEY();
82
        $this->assertEquals(249, $tkey->getTypeCode());
83
    }
84
85
    public function testToText(): void
86
    {
87
        $tkey = new TKEY();
88
        $tkey->setAlgorithm('alg-xx.iana.');
89
        $tkey->setInception(\DateTime::createFromFormat('YmdHis', '20191118000000'));
0 ignored issues
show
It seems like \DateTime::createFromFor...His', '20191118000000') targeting DateTime::createFromFormat() can also be of type false; however, Badcow\DNS\Rdata\TKEY::setInception() does only seem to accept object<DateTime>, did you maybe forget to handle an error condition?
Loading history...
90
        $tkey->setExpiration(\DateTime::createFromFormat('YmdHis', '20251118000000'));
0 ignored issues
show
It seems like \DateTime::createFromFor...His', '20251118000000') targeting DateTime::createFromFormat() can also be of type false; however, Badcow\DNS\Rdata\TKEY::setExpiration() does only seem to accept object<DateTime>, did you maybe forget to handle an error condition?
Loading history...
91
        $tkey->setMode(2);
92
        $tkey->setError(0);
93
        $tkey->setKeyData(base64_decode($this->dummyKeyData));
94
        $tkey->setOtherData(base64_decode($this->dummyOtherData));
95
96
        $expectation = 'alg-xx.iana. 1574035200 1763424000 2 0 ';
97
        $expectation .= str_replace([Tokens::CARRIAGE_RETURN, Tokens::LINE_FEED], '', $this->dummyKeyData).' ';
98
        $expectation .= str_replace([Tokens::CARRIAGE_RETURN, Tokens::LINE_FEED], '', $this->dummyOtherData);
99
100
        $this->assertEquals($expectation, $tkey->toText());
101
    }
102
103
    public function testWire(): void
104
    {
105
        $tkey = new TKEY();
106
        $tkey->setAlgorithm('alg-xx.iana.');
107
        $tkey->setInception(\DateTime::createFromFormat('YmdHis', '20191118000000'));
0 ignored issues
show
It seems like \DateTime::createFromFor...His', '20191118000000') targeting DateTime::createFromFormat() can also be of type false; however, Badcow\DNS\Rdata\TKEY::setInception() does only seem to accept object<DateTime>, did you maybe forget to handle an error condition?
Loading history...
108
        $tkey->setExpiration(\DateTime::createFromFormat('YmdHis', '20251118000000'));
0 ignored issues
show
It seems like \DateTime::createFromFor...His', '20251118000000') targeting DateTime::createFromFormat() can also be of type false; however, Badcow\DNS\Rdata\TKEY::setExpiration() does only seem to accept object<DateTime>, did you maybe forget to handle an error condition?
Loading history...
109
        $tkey->setMode(2);
110
        $tkey->setError(0);
111
        $tkey->setKeyData(base64_decode($this->dummyKeyData));
112
        $tkey->setOtherData(base64_decode($this->dummyOtherData));
113
114
        $wireFormat = $tkey->toWire();
115
        $rdLength = strlen($wireFormat);
116
        $wireFormat = 'abcdefg'.$wireFormat;
117
        $offset = 7;
118
        $fromWire = new TKEY();
119
        $fromWire->fromWire($wireFormat, $offset, $rdLength);
120
        $this->assertEquals($tkey, $fromWire);
121
        $this->assertEquals(7 + $rdLength, $offset);
122
    }
123
124
    public function testFromText(): void
125
    {
126
        $expectation = new TKEY();
127
        $expectation->setAlgorithm('alg-xx.iana.');
128
        $expectation->setInception(\DateTime::createFromFormat('YmdHis', '20191118000000'));
0 ignored issues
show
It seems like \DateTime::createFromFor...His', '20191118000000') targeting DateTime::createFromFormat() can also be of type false; however, Badcow\DNS\Rdata\TKEY::setInception() does only seem to accept object<DateTime>, did you maybe forget to handle an error condition?
Loading history...
129
        $expectation->setExpiration(\DateTime::createFromFormat('YmdHis', '20251118000000'));
0 ignored issues
show
It seems like \DateTime::createFromFor...His', '20251118000000') targeting DateTime::createFromFormat() can also be of type false; however, Badcow\DNS\Rdata\TKEY::setExpiration() does only seem to accept object<DateTime>, did you maybe forget to handle an error condition?
Loading history...
130
        $expectation->setMode(2);
131
        $expectation->setError(0);
132
        $expectation->setKeyData(base64_decode($this->dummyKeyData));
133
        $expectation->setOtherData(base64_decode($this->dummyOtherData));
134
135
        $text = 'alg-xx.iana. 1574035200 1763424000 2 0 ';
136
        $text .= str_replace([Tokens::CARRIAGE_RETURN, Tokens::LINE_FEED], '', $this->dummyKeyData).' ';
137
        $text .= str_replace([Tokens::CARRIAGE_RETURN, Tokens::LINE_FEED], '', $this->dummyOtherData);
138
139
        $fromText = new TKEY();
140
        $fromText->fromText($text);
141
        $this->assertEquals($expectation, $fromText);
142
    }
143
144
    public function testFactory(): void
145
    {
146
        $tkey = Factory::TKEY(
147
            'alg-xx.iana.',
148
            \DateTime::createFromFormat('YmdHis', '20191118000000'),
0 ignored issues
show
It seems like \DateTime::createFromFor...His', '20191118000000') targeting DateTime::createFromFormat() can also be of type false; however, Badcow\DNS\Rdata\Factory::TKEY() does only seem to accept object<DateTime>, did you maybe forget to handle an error condition?
Loading history...
149
            \DateTime::createFromFormat('YmdHis', '20251118000000'),
0 ignored issues
show
It seems like \DateTime::createFromFor...His', '20251118000000') targeting DateTime::createFromFormat() can also be of type false; however, Badcow\DNS\Rdata\Factory::TKEY() does only seem to accept object<DateTime>, did you maybe forget to handle an error condition?
Loading history...
150
            2,
151
            0,
152
            base64_decode($this->dummyKeyData),
153
            base64_decode($this->dummyOtherData)
154
        );
155
156
        $this->assertEquals('alg-xx.iana.', $tkey->getAlgorithm());
157
        $this->assertEquals('2019-11-18', $tkey->getInception()->format('Y-m-d'));
158
        $this->assertEquals('2025-11-18', $tkey->getExpiration()->format('Y-m-d'));
159
        $this->assertEquals(2, $tkey->getMode());
160
        $this->assertEquals(0, $tkey->getError());
161
        $this->assertEquals(base64_decode($this->dummyKeyData), $tkey->getKeyData());
162
        $this->assertEquals(base64_decode($this->dummyOtherData), $tkey->getOtherData());
163
    }
164
}
165