Issues (2687)

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.

src/Eccube/Form/Type/TelType.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
 * This file is part of EC-CUBE
4
 *
5
 * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
6
 *
7
 * http://www.lockon.co.jp/
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
 */
23
namespace Eccube\Form\Type;
24
use Symfony\Component\Form\AbstractType;
25
use Symfony\Component\Form\FormBuilderInterface;
26
use Symfony\Component\Form\FormError;
27
use Symfony\Component\Form\FormEvents;
28
use Symfony\Component\Form\FormInterface;
29
use Symfony\Component\Form\FormView;
30
use Symfony\Component\OptionsResolver\OptionsResolver;
31
use Symfony\Component\Validator\Constraints as Assert;
32
33
class TelType extends AbstractType
34
{
35
    /**
36
     * {@inheritdoc}
37
     */
38 703
    public function __construct($config = array('tel_len' => 5, 'tel_len_min' => 2))
39
    {
40 703
        $this->config = $config;
41
    }
42
    /**
43
     * {@inheritdoc}
44
     */
45 242
    public function buildForm(FormBuilderInterface $builder, array $options)
46
    {
47 242
        $options['tel01_options']['required'] = $options['required'];
48 242
        $options['tel02_options']['required'] = $options['required'];
49 242
        $options['tel03_options']['required'] = $options['required'];
50
        // required の場合は NotBlank も追加する
51 242 View Code Duplication
        if ($options['required']) {
52 160
            $options['options']['constraints'] = array_merge(array(
53 160
                new Assert\NotBlank(array()),
54 160
            ), $options['options']['constraints']);
55
        }
56 242 View Code Duplication
        if (!isset($options['options']['error_bubbling'])) {
57 242
            $options['options']['error_bubbling'] = $options['error_bubbling'];
58
        }
59
        // nameは呼び出しもので定義したものを使う
60 242
        if (empty($options['tel01_name'])) {
61 242
            $options['tel01_name'] = $builder->getName().'01';
62
        }
63 242
        if (empty($options['tel02_name'])) {
64 242
            $options['tel02_name'] = $builder->getName().'02';
65
        }
66 242
        if (empty($options['tel03_name'])) {
67 242
            $options['tel03_name'] = $builder->getName().'03';
68
        }
69
        // 全角英数を事前に半角にする
70 242
        $builder->addEventSubscriber(new \Eccube\EventListener\ConvertKanaListener());
71
        $builder
72 242
            ->add($options['tel01_name'], 'text', array_merge_recursive($options['options'], $options['tel01_options']))
73 242
            ->add($options['tel02_name'], 'text', array_merge_recursive($options['options'], $options['tel02_options']))
74 242
            ->add($options['tel03_name'], 'text', array_merge_recursive($options['options'], $options['tel03_options']))
75
        ;
76 242
        $builder->setAttribute('tel01_name', $options['tel01_name']);
77 242
        $builder->setAttribute('tel02_name', $options['tel02_name']);
78 242
        $builder->setAttribute('tel03_name', $options['tel03_name']);
79
        // todo 変
80 242
        $builder->addEventListener(FormEvents::POST_BIND, function ($event) use ($builder) {
0 ignored issues
show
Deprecated Code introduced by
The constant Symfony\Component\Form\FormEvents::POST_BIND has been deprecated with message: since version 2.3, to be removed in 3.0. Use {@link POST_SUBMIT} instead.

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
81 215
            $form = $event->getForm();
82 215
            $count = 0;
83 215
            if ($form[$builder->getName().'01']->getData() != '') {
84 205
                $count++;
85
            }
86 215
            if ($form[$builder->getName().'02']->getData() != '') {
87 207
                $count++;
88
            }
89 215
            if ($form[$builder->getName().'03']->getData() != '') {
90 207
                $count++;
91
            }
92 215
            if ($count != 0 && $count != 3) {
93
                // todo メッセージをymlに入れる
94 5
                $form[$builder->getName().'01']->addError(new FormError('全て入力してください。'));
95
            }
96 242
        });
97
    }
98
    /**
99
     * {@inheritdoc}
100
     */
101 39
    public function buildView(FormView $view, FormInterface $form, array $options)
102
    {
103 39
        $builder = $form->getConfig();
104 39
        $view->vars['tel01_name'] = $builder->getAttribute('tel01_name');
105 39
        $view->vars['tel02_name'] = $builder->getAttribute('tel02_name');
106 39
        $view->vars['tel03_name'] = $builder->getAttribute('tel03_name');
107
    }
108
    /**
109
     * {@inheritdoc}
110
     */
111 242
    public function configureOptions(OptionsResolver $resolver)
112
    {
113 242
        $resolver->setDefaults(array(
114 242
            'options' => array('constraints' => array()),
115
            'tel01_options' => array(
116
                'constraints' => array(
117 242
                    new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')), //todo  messageは汎用的に出来ないものか?
118 242
                    new Assert\Length(array('max' => $this->config['tel_len'], 'min' => $this->config['tel_len_min'])),
119
                ),
120
            ),
121
            'tel02_options' => array(
122
                'constraints' => array(
123 242
                    new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')),
124 242
                    new Assert\Length(array('max' => $this->config['tel_len'], 'min' => $this->config['tel_len_min'])),
125
                ),
126
            ),
127
            'tel03_options' => array(
128
                'constraints' => array(
129 242
                    new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')),
130 242
                    new Assert\Length(array('max' => $this->config['tel_len'], 'min' => $this->config['tel_len_min'])),
131
                ),
132
            ),
133 242
            'tel01_name' => '',
134 242
            'tel02_name' => '',
135 242
            'tel03_name' => '',
136
            'error_bubbling' => false,
137
            'inherit_data' => true,
138
            'trim' => true,
139
        ));
140
    }
141
    /**
142
     * {@inheritdoc}
143
     */
144 703
    public function getName()
145
    {
146 703
        return 'tel';
147
    }
148
}
149