Issues (1446)

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.

ProxyManagerTest/Autoloader/AutoloaderTest.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
declare(strict_types=1);
4
5
namespace ProxyManagerTest\Autoloader;
6
7
use PHPUnit\Framework\MockObject\MockObject;
8
use PHPUnit\Framework\TestCase;
9
use ProxyManager\Autoloader\Autoloader;
10
use ProxyManager\FileLocator\FileLocatorInterface;
11
use ProxyManager\Generator\Util\UniqueIdentifierGenerator;
12
use ProxyManager\Inflector\ClassNameInflectorInterface;
13
use function class_exists;
14
use function file_put_contents;
15
use function spl_autoload_register;
16
use function spl_autoload_unregister;
17
use function sprintf;
18
use function sys_get_temp_dir;
19
use function uniqid;
20
21
/**
22
 * Tests for {@see \ProxyManager\Autoloader\Autoloader}
23
 *
24
 * @covers \ProxyManager\Autoloader\Autoloader
25
 * @group Coverage
26
 */
27
final class AutoloaderTest extends TestCase
28
{
29
    private Autoloader $autoloader;
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
30
31
    /** @var FileLocatorInterface&MockObject */
32
    private FileLocatorInterface $fileLocator;
33
34
    /** @var ClassNameInflectorInterface&MockObject */
35
    private ClassNameInflectorInterface $classNameInflector;
36
37
    /**
38
     * @covers \ProxyManager\Autoloader\Autoloader::__construct
39
     */
40
    protected function setUp() : void
41
    {
42
        $this->fileLocator        = $this->createMock(FileLocatorInterface::class);
43
        $this->classNameInflector = $this->createMock(ClassNameInflectorInterface::class);
44
        $this->autoloader         = new Autoloader($this->fileLocator, $this->classNameInflector);
45
    }
46
47
    /**
48
     * @covers \ProxyManager\Autoloader\Autoloader::__invoke
49
     */
50
    public function testWillNotAutoloadUserClasses() : void
51
    {
52
        /** @var class-string $className */
53
        $className = 'Foo\\' . UniqueIdentifierGenerator::getIdentifier('Bar');
54
        $this
55
            ->classNameInflector
56
            ->expects(self::once())
57
            ->method('isProxyClassName')
58
            ->with($className)
59
            ->willReturn(false);
60
61
        self::assertFalse($this->autoloadWithoutFurtherAutoloaders($className));
62
    }
63
64
    /**
65
     * @covers \ProxyManager\Autoloader\Autoloader::__invoke
66
     */
67
    public function testWillNotAutoloadNonExistingClass() : void
68
    {
69
        /** @var class-string $className */
70
        $className = 'Foo\\' . UniqueIdentifierGenerator::getIdentifier('Bar');
71
        $this
72
            ->classNameInflector
73
            ->expects(self::once())
74
            ->method('isProxyClassName')
75
            ->with($className)
76
            ->willReturn(true);
77
        $this
78
            ->fileLocator
79
            ->expects(self::once())
80
            ->method('getProxyFileName')
81
            ->willReturn(__DIR__ . '/non-existing');
82
83
        self::assertFalse($this->autoloadWithoutFurtherAutoloaders($className));
84
    }
85
86
    /**
87
     * @covers \ProxyManager\Autoloader\Autoloader::__invoke
88
     */
89
    public function testWillNotAutoloadExistingClass() : void
90
    {
91
        self::assertFalse($this->autoloadWithoutFurtherAutoloaders(self::class));
92
    }
93
94
    /**
95
     * @covers \ProxyManager\Autoloader\Autoloader::__invoke
96
     */
97
    public function testWillAutoloadExistingFile() : void
98
    {
99
        $namespace = 'Foo';
100
        $className = UniqueIdentifierGenerator::getIdentifier('Bar');
101
        /** @var class-string $fqcn */
102
        $fqcn     = $namespace . '\\' . $className;
103
        $fileName = sys_get_temp_dir() . '/foo_' . uniqid('file', true) . '.php';
104
105
        file_put_contents($fileName, '<?php namespace ' . $namespace . '; class ' . $className . '{}');
106
107
        $this
108
            ->classNameInflector
109
            ->expects(self::once())
110
            ->method('isProxyClassName')
111
            ->with($fqcn)
112
            ->willReturn(true);
113
        $this
114
            ->fileLocator
115
            ->expects(self::once())
116
            ->method('getProxyFileName')
117
            ->willReturn($fileName);
118
119
        self::assertTrue($this->autoloadWithoutFurtherAutoloaders($fqcn));
120
        self::assertTrue(class_exists($fqcn, false));
121
    }
122
123
    /** @psalm-param class-string $className */
124
    private function autoloadWithoutFurtherAutoloaders(string $className) : bool
125
    {
126
        $failingAutoloader = null;
127
        $failingAutoloader = function (string $className) use (& $failingAutoloader) : void {
128
            spl_autoload_unregister($failingAutoloader);
129
130
            $this->fail(sprintf('Fallback autoloading was triggered to load "%s"', $className));
131
        };
132
133
        spl_autoload_register($failingAutoloader);
134
135
        $result = $this->autoloader->__invoke($className);
136
137
        spl_autoload_unregister($failingAutoloader);
138
139
        return $result;
140
    }
141
}
142