GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (8)

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/Rule/CleanCode/DataStructureMethods.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
namespace MS\PHPMD\Rule\CleanCode;
4
5
use MS\PHPMD\Guesser\TestGuesser;
6
use PDepend\Source\AST\ASTMethod;
7
use PHPMD\AbstractNode;
8
use PHPMD\Node\ClassNode;
9
use PHPMD\Node\MethodNode;
10
11
/**
12
 * The data structure have to contain only simple getter and setter.
13
 */
14
class DataStructureMethods extends AbstractDataStructure
15
{
16
    use TestGuesser;
17
18
    /**
19
     * @var array
20
     */
21
    private $allowedPrefixes;
22
23
    /**
24
     * @var array
25
     */
26
    private $whitelist;
27
28
    /**
29
     * @param AbstractNode|ClassNode $node
30
     */
31 25
    public function apply(AbstractNode $node)
32
    {
33 25
        if (false === $this->isDataStructure($node) || true === $this->isTest($node)) {
0 ignored issues
show
$node of type object<PHPMD\AbstractNode> is not a sub-type of object<PHPMD\Node\ClassNode>. It seems like you assume a child class of the class PHPMD\AbstractNode to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
34 19
            return;
35
        }
36
37 6
        $prefixes = $this->getStringProperty('prefixes');
38 6
        $this->allowedPrefixes = explode($this->getStringProperty('delimiter'), $prefixes);
39 6
        $this->whitelist = explode($this->getStringProperty('delimiter'), $this->getStringProperty('whitelist'));
40
41
        /** @var MethodNode $method */
42 6
        foreach ($node->getMethods() as $method) {
43 6
            if (true === $this->isMethodNameOnWhitelist($method)) {
44 5
                continue;
45
            }
46
47 6
            if (true === $this->hasCorrectPrefix($method) && true === $this->isSimpleMethod($method)) {
48 6
                continue;
49
            }
50
51 5
            $this->addViolation($method, [$prefixes]);
52 6
        }
53 6
    }
54
55
    /**
56
     * @param MethodNode $method
57
     *
58
     * @return bool
59
     */
60 6
    private function isMethodNameOnWhitelist(MethodNode $method)
61
    {
62 6
        return in_array($method->getImage(), $this->whitelist);
63
    }
64
65
    /**
66
     * @param MethodNode|ASTMethod $node
67
     *
68
     * @return bool
69
     */
70 6
    private function hasCorrectPrefix(MethodNode $node)
71
    {
72 6
        foreach ($this->allowedPrefixes as $prefix) {
73 6
            if ($prefix === substr($node->getImage(), 0, strlen($prefix))) {
74 6
                return true;
75
            }
76 6
        }
77
78 5
        return false;
79
    }
80
81
    /**
82
     * @param MethodNode|ASTMethod $node
83
     *
84
     * @return bool
85
     */
86 6
    private function isSimpleMethod(MethodNode $node)
87
    {
88 6
        $countScope = count($node->findChildrenOfType('ScopeStatement'));
89
90 6
        if (0 !== $countScope) {
91 5
            return false;
92
        }
93
94 6
        $countReturn = count($node->findChildrenOfType('ReturnStatement'));
95 6
        $countThis = $this->countThis($node);
96 6
        $countSetter = $this->countSetter($node);
97
98 6
        if (1 < $countReturn) {
99
            return false;
100
        }
101
102 6
        if (($countReturn + 1) < $countThis - $countSetter) {
103 5
            return false;
104
        }
105
106 6
        return true;
107
    }
108
109
    /**
110
     * @param MethodNode $node
111
     *
112
     * @return int
113
     */
114 6
    private function countThis(MethodNode $node)
115
    {
116 6
        $count = 0;
117 6
        $variables = $node->findChildrenOfType('Variable');
118
119 6
        foreach ($variables as $variable) {
120 6
            if ('$this' === $variable->getImage()) {
121 6
                $count++;
122 6
            }
123 6
        }
124
125 6
        return $count;
126
    }
127
128 6
    private function countSetter(MethodNode $node)
129
    {
130 6
        $count = 0;
131 6
        $methods = $node->findChildrenOfType('MethodPostfix');
132
133 6
        foreach ($methods as $method) {
134 5
            if ('set' === substr($method->getImage(), 0, 3)) {
135 4
                $child = $method->getFirstChildOfType('Variable');
136 4
                if($child && '$this' === $child->getImage()) {
137 4
                    $count++;
138 4
                }
139 4
            }
140 6
        }
141
142 6
        return $count;
143
    }
144
}
145