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/deprecated/Table.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
//[PHPCOMPRESSOR(remove,start)]
3
/**
4
 * Created by PhpStorm.
5
 * User: nazarenko
6
 * Date: 29.03.2016
7
 * Time: 11:11
8
 */
9
namespace samsoncms\api\generator;
10
11
use samsoncms\api\generator\metadata\VirtualMetadata;
12
use samsonphp\generator\Generator;
13
14
/**
15
 * Table class generator.
16
 *
17
 * @package samsoncms\api\generator
18
 * @deprecated
19
 */
20
class Table extends Generic
21
{
22
    /**
23
     * Query constructor.
24
     *
25
     * @param Generator $generator
26
     * @param           $metadata
27
     */
28
    public function __construct(Generator $generator, $metadata)
29
    {
30
        parent::__construct($generator, $metadata);
31
32
        $this->className = preg_replace('/Table$/i', '', $this->className) . 'Table';
33
    }
34
35
    /**
36
     * Class uses generation part.
37
     *
38
     * @param \samsoncms\api\generator\metadata\GalleryMetadata $metadata Entity metadata
39
     */
40
    protected function createUses($metadata)
41
    {
42
        $this->generator
43
            ->newLine('use samsonframework\core\ViewInterface;')
44
            ->newLine('use samsonframework\orm\QueryInterface;')
45
            ->newLine('use samson\activerecord\dbQuery;')
46
            ->newLine();
47
    }
48
49
    /**
50
     * Class definition generation part.
51
     *
52
     * @param VirtualMetadata $metadata Entity metadata
53
     */
54 View Code Duplication
    protected function createDefinition($metadata)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
55
    {
56
        $this->generator
57
            ->multiComment(array(
58
                'Class for rendering "' . $metadata->entityRealName . '" table',
59
                '@deprecated Use ' . $this->className . 'Collection instead'
60
            ))
61
            ->defClass($this->className, '\\'.\samsoncms\api\field\Table::class)
62
            ->newLine('use \\'.\samsoncms\api\Renderable::class.';')
63
            ->newLine();
64
    }
65
66
    /**
67
     * Class constants generation part.
68
     *
69
     * @param VirtualMetadata $metadata Entity metadata
70
     */
71
    protected function createConstants($metadata)
72
    {
73
        $this->generator
74
            ->commentVar('string', 'Entity full class name, use ::class instead')
75
            ->defClassConst('ENTITY', $metadata->entityClassName)
76
            ->commentVar('string', 'Entity database identifier')
77
            ->defClassConst('IDENTIFIER', $metadata->entityID)
78
            ->commentVar('string', 'Not transliterated entity name')
79
            ->defClassConst('NAME', $metadata->entityRealName);
80
    }
81
82
    /**
83
     * Class static fields generation part.
84
     *
85
     * @param VirtualMetadata $metadata Entity metadata
86
     */
87
    protected function createStaticFields($metadata)
88
    {
89
        $this->generator
90
            ->commentVar('array', 'Collection of real additional field names')
91
            ->defClassVar('$fieldsRealNames', 'public static', $metadata->realNames);
92
    }
93
94
    /**
95
     * Class methods generation part.
96
     *
97
     * @param VirtualMetadata $metadata Entity metadata
98
     */
99
    protected function createMethods($metadata)
100
    {
101
        $methods = [];
102
        // TODO: Add different method generation depending on their field type
103
        // Generate Query::where() analog for specific field.
104
        foreach ($metadata->fields as $fieldID => $fieldName) {
105
            $code = "\n\t" . '/**';
106
            $code .= "\n\t" . ' * Get collection of ' . $fieldName . '(#' . $fieldID . ') table column values.';
107
            $code .= "\n\t" . ' * @see \samsoncms\api\field\Table::values($fieldID)';
108
            $code .= "\n\t" . ' * @param string $relation Field to value condition relation';
109
            $code .= "\n\t" . ' *';
110
            $code .= "\n\t" . ' * @return ' . $metadata->types[$fieldID] . '[] ' . $fieldName . ' values collection';
111
            $code .= "\n\t" . ' */';
112
            $code .= "\n\t" . 'public function ' . $fieldName . '()';
113
            $code .= "\n\t" . '{';
114
            $code .= "\n\t\t" . 'return $this->values(' . $fieldID . ');';
115
            $code .= "\n\t" . '}';
116
117
            $methods[] = $code;
118
        }
119
120
        // Add method text to generator
121
        $this->generator->text(implode("\n", $methods));
122
    }
123
124
    /**
125
     * Class constructor generation part.
126
     *
127
     * @param VirtualMetadata $metadata Entity metadata
128
     */
129
    protected function createConstructor($metadata)
130
    {
131
        $class = "\n\t" . '/**';
132
        $class .= "\n\t" . ' * @param ViewInterface $renderer Rendering instance';
133
        $class .= "\n\t" . ' * @param int $materialID material identifier';
134
        $class .= "\n\t" . ' * @param QueryInterface $query Database query instance';
135
        $class .= "\n\t" . ' * @param string $locale locale';
136
        $class .= "\n\t" . ' * @deprecated Use ' . $this->className . 'Collection instead';
137
        $class .= "\n\t" . ' */';
138
        $class .= "\n\t" . 'public function __construct(ViewInterface $renderer, $materialID, QueryInterface $query = null, $locale = null)';
139
        $class .= "\n\t" . '{';
140
        $class .= "\n\t\t" . '$this->renderer = $renderer;';
141
        $class .= "\n\t\t" . 'parent::__construct(null !== $query ? $query : new dbQuery(), array('. $metadata->entityID .'), $materialID, $locale);';
142
        $class .= "\n\t" . '}' . "\n";
143
144
        $this->generator->text($class);
145
    }
146
}
147
//[PHPCOMPRESSOR(remove,end)]
148