Issues (132)

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/Analyzer/Helper/ResolveExpressionTrait.php (1 issue)

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
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA\Analyzer\Helper;
7
8
use PhpParser\Node;
9
use PhpParser\Node\Expr\FuncCall;
10
use PhpParser\Node\Expr\Yield_;
11
use PhpParser\Node\Stmt\Return_;
12
use PHPSA\Context;
13
14
trait ResolveExpressionTrait
15
{
16
    /**
17
     * @param FuncCall $funcCall
18
     * @param Context $context
19
     * @return string|bool
20
     */
21
    public function resolveFunctionName(FuncCall $funcCall, Context $context)
22
    {
23
        $funcNameCompiledExpression = $context->getExpressionCompiler()->compile($funcCall->name);
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $funcNameCompiledExpression exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
24
25
        if ($funcNameCompiledExpression->isString() && $funcNameCompiledExpression->isCorrectValue()) {
26
            return $funcNameCompiledExpression->getValue();
27
        } elseif (!$funcNameCompiledExpression->isCallable()) {
28
            $context->debug(
29
                'Unexpected function name type ' . $funcNameCompiledExpression->getTypeName(),
30
                $funcCall->name
31
            );
32
        }
33
34
        return false;
35
    }
36
37
    /**
38
     * @param array $nodes
39
     * @param string $nodeName Class name of Node(s) what We should return
40
     * @return \Generator
41
     */
42
    protected function findNode(array $nodes, $nodeName)
43
    {
44
        foreach ($this->traverseArray($nodes) as $node) {
45
            if (get_class($node) === $nodeName) {
46
                yield $node;
47
            }
48
        }
49
    }
50
51
    /**
52
     * For the code above
53
     * Я атеист, но когда я начинал это писать, только Бог и я понимали, что я делаю
54
     * Сейчас остался только Бог
55
     *
56
     * @param Node $node
57
     * @return \Generator
58
     *
59
     * @todo After move to PHP 7.0+ use yield from
60
     */
61
    protected function traverseNode(Node $node)
62
    {
63
        // Skip inherits nodes
64
        if ($node instanceof Node\FunctionLike || $node instanceof Node\Stmt\ClassLike) {
65
            return;
66
        }
67
68
        foreach ($node->getSubNodeNames() as $name) {
69
            $subNode = &$node->$name;
70
71
            if (is_array($subNode)) {
72
                foreach ($this->traverseArray($subNode) as $rNode) {
73
                    yield $rNode;
74
                }
75
            } elseif ($subNode instanceof Node) {
76
                yield $subNode;
77
78
                foreach ($this->traverseNode($subNode) as $rNode) {
79
                    yield $rNode;
80
                }
81
            }
82
        }
83
    }
84
85
    /**
86
     * @param array $nodes
87
     * @return \Generator
88
     */
89
    protected function traverseArray(array $nodes)
90
    {
91
        foreach ($nodes as $node) {
92
            if (is_array($node)) {
93
                foreach ($this->traverseArray($node) as $rNode) {
94
                    yield $rNode;
95
                }
96
            } elseif ($node instanceof Node) {
97
                yield $node;
98
99
                foreach ($this->traverseNode($node) as $rNode) {
100
                    yield $rNode;
101
                }
102
            }
103
        }
104
    }
105
}
106