Issues (2366)

Branch: master

Security Analysis    not enabled

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.

GeneratorCommand/EntityFromYamlGenerator.php (6 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
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * This program is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU General Public License
12
 * as published by the Free Software Foundation; either version 2
13
 * of the License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23
 */
24
25
namespace Eccube\Command\GeneratorCommand;
26
27
use Doctrine\ORM\Mapping\ClassMetadataInfo;
28
use Eccube\Doctrine\ORM\Mapping\Driver\YamlDriver;
29
use Symfony\Component\Finder\Finder;
30
use Symfony\Component\Yaml\Yaml;
31
32
class EntityFromYamlGenerator extends AbstractPluginGenerator
0 ignored issues
show
Missing class doc comment
Loading history...
33
{
34
35
    /**
36
     * Yamlリスト
37
     *
38
     * @var array
39
     */
40
    private $ymlList = null;
41
42 View Code Duplication
    protected function getHeader()
43
    {
44
        $this->output->writeln('------------------------------------------------------');
45
        $this->output->writeln('---Plugin Generator for Entity');
46
        $this->output->writeln('---[*]You need to create yml file first.');
47
        $this->output->writeln('---[*]You can exit from Console Application, by typing '.self::STOP_PROCESS.' instead of typing another word.');
48
        $this->output->writeln('------------------------------------------------------');
49
        $this->output->writeln('');
50
    }
51
52 View Code Duplication
    protected function initFieldSet()
53
    {
54
        $this->paramList = array(
0 ignored issues
show
Add a comma after each item in a multi-line array
Loading history...
55
            'pluginCode' => array(
0 ignored issues
show
Add a comma after each item in a multi-line array
Loading history...
56
                'no' => 1,
57
                'label' => '[+]Plugin Code: ',
58
                'value' => null,
59
                'name' => '[+]Please enter Plugin Code (First letter is uppercase alphabet only. alphabet and numbers are allowed.)',
60
                'validation' => array(
61
                    'isRequired' => true,
62
                    'isNotCode' => $this->getPluginCodes(),
63
                )
64
            ),
65
            'ymlList' => array(
0 ignored issues
show
Add a comma after each item in a multi-line array
Loading history...
66
                'no' => 2,
67
                'label' => '[+]Yml file name: ',
68
                'value' => array(),
69
                'name' => '[+]Plese enter yml file name',
70
                'validation' => array(
71
                    'isRequired' => false,
72
                    'inArray' => 'getYamlList',
73
                )
74
            ),
75
            'supportFlag' => array(
0 ignored issues
show
Add a comma after each item in a multi-line array
Loading history...
76
                'no' => 3,
77
                'label' => '[+]Old version support: ',
78
                'value' => null,
79
                'name' => '[+]Do you want to support old versions too? [y/n]',
80
                'show' => array(1 => 'Yes', 0 => 'No'),
81
                'validation' => array(
82
                    'isRequired' => true,
83
                    'choice' => array('y' => 1, 'n' => 0),
84
                )
85
            )
86
        );
87
    }
88
89
    protected function getYamlList()
90
    {
91
92
        $pluginCode = $this->paramList['pluginCode']['value'];
93
94
        if (!$pluginCode) {
95
            return array();
96
        }
97
98
        if ($this->ymlList === null) {
99
            $this->ymlList = array();
100
101
            $finder = new Finder();
102
            $finder->files()->depth('== 0');
103
            $files = $finder->in($this->app['config']['root_dir'].'/app/Plugin/'.$pluginCode.'/Resource/doctrine/');
104
105
            foreach ($files as $item) {
106
                $this->ymlList[$item->getFilename()] = $item->getRealPath();
107
            }
108
0 ignored issues
show
Blank line found at end of control structure
Loading history...
109
        }
110
111
        return $this->ymlList;
112
    }
113
114
    protected function start()
115
    {
116
        $pluginCode = $this->paramList['pluginCode']['value'];
117
118
        $codes = $this->getPluginCodes();
119
        if (!in_array($pluginCode, $codes)) {
120
            $this->exitGenerator('<error>This plugin code does not exist.</error>');
121
122
            return;
123
        }
124
125
        $fsList = array(
126
            'dir' => array(),
127
            'file' => array(),
128
        );
129
130
        $pluginCode = $this->paramList['pluginCode']['value'];
131
        $ymlList = $this->paramList['ymlList']['value'];
132
133
        $codePath = $this->app['config']['root_dir'].'/app/Plugin/'.$pluginCode;
134
135
        $dirList = array('Entity', 'Repository', 'Resource/doctrine/migration');
136 View Code Duplication
        foreach ($dirList as $dirName) {
137
            $dirPath = $codePath.'/'.$dirName;
138
            if (!is_dir($dirPath)) {
139
                mkdir($dirPath);
140
            }
141
            if (is_dir($dirPath)) {
142
                $fsList['dir'][$dirPath] = true;
143
            } else {
144
                $fsList['dir'][$dirPath] = false;
145
            }
146
        }
147
148
        // metadataの設定
149
        $classNames = array();
150
        foreach ($ymlList as $item) {
151
            $yml = Yaml::parse(file_get_contents($item));
152
            $classNames[] = key($yml);
153
        }
154
155
        $YamlDriver = new YamlDriver(array($codePath.'/Resource/doctrine'));
156
        $metadatas = array();
157
        foreach ($classNames as $className) {
158
            $ClassMetadataInfo = new ClassMetadataInfo($className);
159
            $YamlDriver->loadMetadataForClass($className, $ClassMetadataInfo);
160
            $metadatas[] = $ClassMetadataInfo;
161
        }
162
163
        // Entity、Repositoryファイルの作成
164
        $this->generateEntities($metadatas, $fsList);
165
166
        // migrationファイルの作成
167
        $this->generateMigration($metadatas, $fsList, $pluginCode, $codePath);
168
169
        // 完了メッセージ
170
        $this->completeMessage($fsList);
171
172
    }
173
}
174