Issues (12)

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/ClassDumper.php (2 issues)

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
 * Class Dumper
4
 *
5
 * @link      https://github.com/mtymek/class-dumper
6
 * @copyright Copyright (c) 2015 Mateusz Tymek
7
 * @license   BSD 2-Clause
8
 */
9
10
namespace ClassDumper;
11
12
use Zend\Code\Reflection\ClassReflection;
13
14
class ClassDumper
15
{
16
    /**
17
     * @var CodeGenerator
18
     */
19
    private $codeGenerator;
20
21
    /**
22
     * @var array
23
     */
24
    private $cache;
25
26
    /**
27
     * @var array
28
     */
29
    private $cachedClasses;
30
31
    /**
32
     * Class constructor
33
     */
34
    public function __construct()
35
    {
36
        $this->codeGenerator = new CodeGenerator();
37
    }
38
39
    /**
40
     * Returns class' code inside namespace
41
     *
42
     * @param ClassReflection $class
43
     */
44
    private function dumpClass(ClassReflection $class)
45
    {
46
        if (array_search($class->getName(), $this->cachedClasses) !== false) {
0 ignored issues
show
Consider using $class->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
47
            return;
48
        }
49
50
        if ($class->isInternal()) {
51
            return;
52
        }
53
54
        if ($class->getParentClass()) {
55
            $this->dumpClass($class->getParentClass());
56
        }
57
58
        foreach ($class->getInterfaces() as $interface) {
59
            $this->dumpClass($interface);
60
        }
61
62
        if ($class->getTraits()) {
63
            foreach ($class->getTraits() as $trait) {
64
                $this->dumpClass($trait);
65
            }
66
        }
67
68
        $classContents = $class->getContents(false);
69
        $classFileDir  = dirname($class->getFileName());
70
        $classContents = trim(str_replace('__DIR__', sprintf("'%s'", $classFileDir), $classContents));
71
72
        $uses = implode("\n", $this->codeGenerator->getUseLines($class));
73
74
        $this->cache[] = "namespace "
75
            . $class->getNamespaceName()
76
            . " {\n"
77
            . ($uses ? $uses . "\n" : '')
78
            . $this->codeGenerator->getDeclarationLine($class) . "\n"
79
            . $classContents
80
            . "\n}\n";
81
        $this->cachedClasses[] = $class->getName();
0 ignored issues
show
Consider using $class->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
82
    }
83
84
    /**
85
     * Generates merged code for specified classes
86
     *
87
     * @param array $classes
88
     * @param bool $minify
89
     * @return string
90
     */
91
    public function dump(array $classes, $minify = false)
92
    {
93
        $this->cache = [];
94
        $this->cachedClasses = [];
95
96
        foreach ($classes as $className) {
97
            $class = new ClassReflection($className);
98
            $this->dumpClass($class);
99
        }
100
101
        $code = implode("\n", $this->cache);
102
103
        if (!$minify) {
104
            return $code;
105
        }
106
107
        $tempFile = tempnam(sys_get_temp_dir(), 'class-dumper');
108
        file_put_contents($tempFile, "<?php\n" . $code);
109
        $stripped = php_strip_whitespace($tempFile);
110
        unlink($tempFile);
111
112
        // strip "<?php
113
        return trim(substr($stripped, strlen("<?php\n") - 1));
114
    }
115
}
116