Issues (168)

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/generator/analyzer/GenericAnalyzer.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
//[PHPCOMPRESSOR(remove,start)]
3
/**
4
 * Created by Vitaly Iegorov <[email protected]>.
5
 * on 23.03.16 at 11:45
6
 */
7
namespace samsoncms\api\generator\analyzer;
8
9
use samsonframework\orm\DatabaseInterface;
10
11
/**
12
 * Generic entities metadata analyzer.
13
 *
14
 * @package samsoncms\api\analyzer
15
 */
16
class GenericAnalyzer
17
{
18
    /** @var DatabaseInterface */
19
    protected $database;
20
21
    /** @var string Metadata class */
22
    protected $metadataClass = \samsoncms\api\generator\metadata\GenericMetadata::class;
23
24
    /**
25
     * Generator constructor.
26
     * @param DatabaseInterface $database Database instance
27
     */
28
    public function __construct(DatabaseInterface $database)
29
    {
30
        $this->database = $database;
31
    }
32
33
    /**
34
     * @return \samsoncms\api\generator\metadata\GenericMetadata[]
35
     */
36
    public function analyze()
37
    {
38
39
    }
40
41
    /**
42
     * Get correct field name.
43
     *
44
     * @param string $fieldName Original field name
45
     *
46
     * @return string Correct PHP-supported field name
47
     */
48
    protected function fieldName($fieldName)
49
    {
50
        return $fieldName = lcfirst($this->transliterated($fieldName));
0 ignored issues
show
$fieldName is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
51
    }
52
53
    /**
54
     * Transliterate string to english.
55
     *
56
     * @param string $string Source string
57
     *
58
     * @return string Transliterated string
59
     */
60
    protected function transliterated($string)
61
    {
62
        return str_replace(
63
            ' ',
64
            '',
65
            ucwords(iconv("UTF-8", "UTF-8//IGNORE", strtr($string, array(
66
                            "'" => "",
67
                            "`" => "",
68
                            "-" => " ",
69
                            "_" => " ",
70
                            "а" => "a", "А" => "a",
71
                            "б" => "b", "Б" => "b",
72
                            "в" => "v", "В" => "v",
73
                            "г" => "g", "Г" => "g",
74
                            "д" => "d", "Д" => "d",
75
                            "е" => "e", "Е" => "e",
76
                            "ж" => "zh", "Ж" => "zh",
77
                            "з" => "z", "З" => "z",
78
                            "и" => "i", "И" => "i",
79
                            "й" => "y", "Й" => "y",
80
                            "к" => "k", "К" => "k",
81
                            "л" => "l", "Л" => "l",
82
                            "м" => "m", "М" => "m",
83
                            "н" => "n", "Н" => "n",
84
                            "о" => "o", "О" => "o",
85
                            "п" => "p", "П" => "p",
86
                            "р" => "r", "Р" => "r",
87
                            "с" => "s", "С" => "s",
88
                            "т" => "t", "Т" => "t",
89
                            "у" => "u", "У" => "u",
90
                            "ф" => "f", "Ф" => "f",
91
                            "х" => "h", "Х" => "h",
92
                            "ц" => "c", "Ц" => "c",
93
                            "ч" => "ch", "Ч" => "ch",
94
                            "ш" => "sh", "Ш" => "sh",
95
                            "щ" => "sch", "Щ" => "sch",
96
                            "ъ" => "", "Ъ" => "",
97
                            "ы" => "y", "Ы" => "y",
98
                            "ь" => "", "Ь" => "",
99
                            "э" => "e", "Э" => "e",
100
                            "ю" => "yu", "Ю" => "yu",
101
                            "я" => "ya", "Я" => "ya",
102
                            "і" => "i", "І" => "i",
103
                            "ї" => "yi", "Ї" => "yi",
104
                            "є" => "e", "Є" => "e"
105
                        )
106
                    )
107
                )
108
            )
109
        );
110
    }
111
112
    /**
113
     * Get correct full entity name with name space.
114
     *
115
     * @param string $navigationName Original navigation entity name
116
     * @param string $namespace      Namespace
117
     *
118
*@return string Correct PHP-supported entity name
119
     */
120
    protected function fullEntityName($navigationName, $namespace = __NAMESPACE__)
0 ignored issues
show
The parameter $namespace is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
121
    {
122
        return '\samsoncms\api\generated\\' . $this->entityName($navigationName);
123
    }
124
125
    /**
126
     * Get correct entity name.
127
     *
128
     * @param string $navigationName Original navigation entity name
129
     *
130
*@return string Correct PHP-supported entity name
131
     */
132
    protected function entityName($navigationName)
133
    {
134
        return ucfirst($this->getValidName($this->transliterated($navigationName)));
135
    }
136
137
    /**
138
     * Remove all wrong characters from entity name
139
     *
140
     * @param string $navigationName Original navigation entity name
141
     *
142
     * @return string Correct PHP-supported entity name
143
     */
144
    protected function getValidName($navigationName)
145
    {
146
        return preg_replace('/(^\d*)|([^\w\d_])/', '', $navigationName);
147
    }
148
149
    /**
150
     * Get additional field type in form of Field constant name
151
     * by database additional field type identifier.
152
     *
153
     * @param integer $fieldType Additional field type identifier
154
     *
155
     * @return string Additional field type constant
156
     */
157
    protected function additionalFieldType($fieldType)
158
    {
159
        return 'Field::' . $this->constantNameByValue($fieldType);
160
    }
161
162
    /**
163
     * Get class constant name by its value.
164
     *
165
     * @param string $value     Constant value
166
     * @param string $className Class name
167
     *
168
     * @return string Full constant name
169
     */
170
    protected function constantNameByValue($value, $className = Field::ENTITY)
171
    {
172
        // Get array where class constants are values and their values are keys
173
        $nameByValue = array_flip((new \ReflectionClass($className))->getConstants());
174
175
        // Try to find constant by its value
176
        if (null !== $nameByValue[$value]) {
177
            // Return constant name
178
            return $nameByValue[$value];
179
        }
180
181
        return '';
182
    }
183
}
184
//[PHPCOMPRESSOR(remove,end)]