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/ApplicationCollection.php (3 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 24.03.16 at 13:34
6
 */
7
namespace samsoncms\api\generator;
8
9
use samsonphp\generator\Generator;
10
11
/**
12
 * SamsonCMS application collection class generator.
13
 *
14
 * @package samsoncms\application\generator
15
 */
16
class ApplicationCollection extends \samsoncms\api\generator\Generic
17
{
18
    /** Default generic class name */
19
    const DEFAULT_GENERIC_TYPE = 'Generic';
20
21
    /** Default control class name */
22
    const DEFAULT_GENERIC_CONTROL_TYPE = 'Control';
23
24
    /** Custom css selector in generic constructor */
25
    const DEFAULT_CUSTOM_TYPE_CSS = '';
26
27
    /** User can edit field in list of application */
28
    const DEFAULT_CUSTOM_TYPE_EDITABLE = 'false';
29
30
    /** Field can be sortable in list of application */
31
    const DEFAULT_CUSTOM_TYPE_SORTABLE = 'false';
32
33
    /** Default namespace of custom types */
34
    const DEFAULT_CUSTOM_TYPE_NAMESPACE = '\\samsonphp\\cms\\types\\';
35
36
    /**
37
     * Query constructor.
38
     *
39
     * @param Generator $generator
40
     * @param           $metadata
41
     */
42
    public function __construct(Generator $generator, $metadata)
43
    {
44
        parent::__construct($generator, $metadata);
45
46
        $this->className .= 'ApplicationCollection';
47
    }
48
49
    /**
50
     * Class uses generation part.
51
     *
52
     * @param \samsoncms\api\generator\metadata\GenericMetadata $metadata Entity metadata
53
     */
54
    protected function createUses($metadata)
55
    {
56
        $this->generator
57
            ->text('use samsoncms\field\Control;')
58
            ->text('use samsoncms\field\Generic;')
59
            ->newLine();
60
    }
61
62
    /**
63
     * Class definition generation part.
64
     *
65
     * @param \samsoncms\api\generator\metadata\ApplicationMetadata $metadata Entity metadata
66
     */
67
    protected function createDefinition($metadata)
68
    {
69
        $this->generator
70
            ->multiComment(array('Collection for SamsonCMS application "'.$metadata->name.'"'))
71
            ->defClass($this->className, '\\'.\samsoncms\app\material\Collection::class);
72
    }
73
74
    /**
75
     * Class constructor generation part.
76
     *
77
     * @param \samsoncms\api\generator\metadata\ApplicationMetadata $metadata Entity metadata
78
     */
79
    protected function createConstructor($metadata)
80
    {
81
        $constructorCode = <<<'EOD'
82
    /**
83
     * Generic SamsonCMS application collection constructor
84
     *
85
     * @param RenderInterface $renderer View render object
86
     * @param QueryInterface $query Query object
87
     */
88
    public function __construct($renderer, $query = null, $pager = null)
89
    {
90
        parent::__construct($renderer, $query, $pager);
91
92
        // Generic of fields
93
        $this->fields = array({{fields}});
94
    }
95
EOD;
96
        // Iterate all application fields and create generic constructor for them
97
        $genericFields = [];
98
        foreach ($metadata->showFieldsInList as $fieldID) {
99
            // Create constructor for custom type or if it not exists then use cms defined type
100
            $genericFields[] = $this->createCollectionField(
101
                $metadata->customTypeFields[$fieldID],
102
                $metadata->fields[$fieldID],
103
                $metadata->fieldDescriptions[$fieldID],
104
                $metadata->allFieldCmsTypes[$fieldID],
105
                self::DEFAULT_CUSTOM_TYPE_CSS,
106
                self::DEFAULT_CUSTOM_TYPE_EDITABLE,
107
                self::DEFAULT_CUSTOM_TYPE_SORTABLE
108
            );
109
        }
110
111
        $constructorCode = str_replace(
112
            '{{fields}}',
113
            implode(',', array_merge(
114
                    $genericFields,
115
                    array("\n\t\t\t" . 'new ' . self::DEFAULT_GENERIC_CONTROL_TYPE . '()' . "\n\t\t"))
116
            ),
117
            $constructorCode);
118
119
        $this->generator->text($constructorCode);
120
    }
121
122
    /**
123
     * Create generic constructor for collection.
124
     *
125
     * @param        $customType
126
     * @param        $name
127
     * @param        $description
128
     * @param int    $type
129
     * @param string $css
130
     * @param string $editable
131
     * @param string $sortable
132
     *
133
     * @return string
134
     */
135
    public function createCollectionField(
136
        $customType,
137
        $name,
138
        $description,
139
        $type,
140
        $css = self::DEFAULT_CUSTOM_TYPE_CSS,
141
        $editable = self::DEFAULT_CUSTOM_TYPE_CSS,
142
        $sortable = self::DEFAULT_CUSTOM_TYPE_CSS
143
    )
144
    {
0 ignored issues
show
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Loading history...
145
146
        // If custom type is exists then use it or use default generic type
147
        if ($customType) {
0 ignored issues
show
Blank line found at start of control structure
Loading history...
148
149
            // If field has namespace then use it or use default namespace
150
            $class = preg_match('/\\\/', $customType) ? $customType : self::DEFAULT_CUSTOM_TYPE_NAMESPACE . $customType;
151
        } else {
0 ignored issues
show
Blank line found at start of control structure
Loading history...
152
153
            $class = self::DEFAULT_GENERIC_TYPE;
154
        }
155
156
157
        return "\n\t\t\tnew {$class}('$name', t('$description', true), $type, '$css', $editable, $sortable)";
158
    }
159
}
160
//[PHPCOMPRESSOR(remove,end)]
161