Issues (245)

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/Utils/PhpLint.php (2 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
 * \AppserverIo\Doppelgaenger\Utils\PhpLint
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Bernhard Wick <[email protected]>
15
 * @copyright 2015 TechDivision GmbH - <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io/doppelgaenger
18
 * @link      http://www.appserver.io/
19
 */
20
21
namespace AppserverIo\Doppelgaenger\Utils;
22
23
/**
24
 * Will provide a basic linting function for php code
25
 *
26
 * @author    Bernhard Wick <[email protected]>
27
 * @copyright 2015 TechDivision GmbH - <[email protected]>
28
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
 * @link      https://github.com/appserver-io/doppelgaenger
30
 * @link      http://www.appserver.io/
31
 */
32
class PhpLint
33
{
34
35
    /**
36
     * Will remove any PHP start or end tags from the code.
37
     *
38
     * @param string $code The to strip from the tags
39
     *
40
     * @return mixed
41
     */
42
    protected function removePhpTags($code)
43
    {
44
        return str_replace(array('<?php', '?>', '<?', '<?='), '', $code);
45
    }
46
47
    /**
48
     * Will check if code is PHP syntax conform.
49
     *
50
     * @param string $code The code to check for syntax errors
51
     *
52
     * @throws \Exception
53
     *
54
     * @return boolean
55
     */
56
    public function check($code)
57
    {
58
        // Save the current error reporting level and set level to 0.
59
        // We would get errors shown to the use if we did not do that.
60
        $level = error_reporting();
61
        error_reporting(0);
62
63
        try {
64
            // Eval the passed code inside a never entered if clause.
65
            // That way we can make sure to not execute any bogus code
66
            $result = eval('if (false){' . $this->removePhpTags($code) . '}');
0 ignored issues
show
It is generally not recommended to use eval unless absolutely required.

On one hand, eval might be exploited by malicious users if they somehow manage to inject dynamic content. On the other hand, with the emergence of faster PHP runtimes like the HHVM, eval prevents some optimization that they perform.

Loading history...
67
68
            // eval does not return true if there was no error, but we want to
69
            if ($result === null) {
70
                $result = true;
71
            }
72
0 ignored issues
show
Blank line found at end of control structure
Loading history...
73
        } catch (\Exception $e) {
74
            // Set the error reporting to the intended level and fail
75
            error_reporting($level);
76
            throw $e;
77
        }
78
79
        // Reset the error reporting level to the original value
80
        error_reporting($level);
81
82
        // Return our result
83
        return $result;
84
    }
85
}
86