Issues (48)

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.

Classes/Configuration/Configuration.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
 * 2017 Romain CANON <[email protected]>
4
 *
5
 * This file is part of the TYPO3 FormZ project.
6
 * It is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU General Public License, either
8
 * version 3 of the License, or any later version.
9
 *
10
 * For the full copyright and license information, see:
11
 * http://www.gnu.org/licenses/gpl-3.0.html
12
 */
13
14
namespace Romm\Formz\Configuration;
15
16
use Romm\ConfigurationObject\ConfigurationObjectInterface;
17
use Romm\ConfigurationObject\Service\Items\Cache\CacheService;
18
use Romm\ConfigurationObject\Service\ServiceFactory;
19
use Romm\ConfigurationObject\Service\ServiceInterface;
20
use Romm\ConfigurationObject\Traits\ConfigurationObject\ArrayConversionTrait;
21
use Romm\ConfigurationObject\Traits\ConfigurationObject\DefaultConfigurationObjectTrait;
22
use Romm\Formz\Configuration\Form\Form;
23
use Romm\Formz\Configuration\Settings\Settings;
24
use Romm\Formz\Configuration\View\View;
25
use Romm\Formz\Exceptions\DuplicateEntryException;
26
use Romm\Formz\Form\FormObject;
27
use Romm\Formz\Service\CacheService as InternalCacheService;
28
use Romm\Formz\Service\HashService;
29
use TYPO3\CMS\Core\Utility\GeneralUtility;
30
31
class Configuration extends AbstractFormzConfiguration implements ConfigurationObjectInterface
32
{
33
    use DefaultConfigurationObjectTrait;
34
    use ArrayConversionTrait;
35
36
    /**
37
     * @var \Romm\Formz\Configuration\Settings\Settings
38
     */
39
    protected $settings;
40
41
    /**
42
     * @var FormObject[]
43
     */
44
    protected $forms = [];
45
46
    /**
47
     * @var \Romm\Formz\Configuration\View\View
48
     */
49
    protected $view;
50
51
    /**
52
     * @var string
53
     */
54
    protected $hash;
55
56
    /**
57
     * Constructor.
58
     */
59
    public function __construct()
60
    {
61
        $this->settings = GeneralUtility::makeInstance(Settings::class);
62
        $this->view = GeneralUtility::makeInstance(View::class);
63
    }
64
65
    /**
66
     * Will initialize correctly the configuration object settings.
67
     *
68
     * @return ServiceFactory
69
     */
70
    public static function getConfigurationObjectServices()
71
    {
72
        return ServiceFactory::getInstance()
73
            ->attach(ServiceInterface::SERVICE_CACHE)
74
            ->with(ServiceInterface::SERVICE_CACHE)
75
            ->setOption(CacheService::OPTION_CACHE_NAME, InternalCacheService::CONFIGURATION_OBJECT_CACHE_IDENTIFIER)
76
            ->setOption(CacheService::OPTION_CACHE_BACKEND, InternalCacheService::get()->getBackendCache())
77
            ->attach(ServiceInterface::SERVICE_PARENTS)
78
            ->attach(ServiceInterface::SERVICE_DATA_PRE_PROCESSOR)
79
            ->attach(ServiceInterface::SERVICE_MIXED_TYPES);
80
    }
81
82
    /**
83
     * @return Settings
84
     */
85
    public function getSettings()
86
    {
87
        return $this->settings;
88
    }
89
90
    /**
91
     * Adds a form to the forms list of this FormZ configuration. Note that this
92
     * function will also handle the parent service from the
93
     * `configuration_object` extension.
94
     *
95
     * @param FormObject $form
96
     * @throws DuplicateEntryException
97
     */
98
    public function addForm(FormObject $form)
99
    {
100
        if (true === $this->hasForm($form->getClassName(), $form->getName())) {
101
            throw DuplicateEntryException::formWasAlreadyRegistered($form);
102
        }
103
104
        $form->getConfiguration()->setParents([$this]);
0 ignored issues
show
Deprecated Code introduced by
The method Romm\ConfigurationObject...entsTrait::setParents() has been deprecated with message: This function is deprecated and will be removed in v2! Use function `addParents()` instead.

This method 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 method will be removed from the class and what other method or class to use instead.

Loading history...
105
106
        $this->forms[$form->getClassName()][$form->getName()] = $form;
107
    }
108
109
    /**
110
     * @param string $className
111
     * @param string $name
112
     * @return bool
113
     */
114
    public function hasForm($className, $name)
115
    {
116
        return true === isset($this->forms[$className][$name]);
117
    }
118
119
    /**
120
     * @param string $className
121
     * @param string $name
122
     * @return null|Form
123
     */
124
    public function getForm($className, $name)
125
    {
126
        return ($this->hasForm($className, $name))
127
            ? $this->forms[$className][$name]
128
            : null;
129
    }
130
131
    /**
132
     * @return View
133
     */
134
    public function getView()
135
    {
136
        return $this->view;
137
    }
138
139
    /**
140
     * Calculates a hash for this configuration, which can be used as a unique
141
     * identifier. It should be called once, before the configuration is put in
142
     * cache, so it is not needed to call it again after being fetched from
143
     * cache.
144
     */
145
    public function calculateHash()
146
    {
147
        $fullArray = $this->toArray();
148
        $configurationArray = [
149
            'view'     => $fullArray['view'],
150
            'settings' => $fullArray['settings']
151
        ];
152
153
        $this->hash = HashService::get()->getHash(serialize($configurationArray));
154
    }
155
156
    /**
157
     * @return string
158
     */
159
    public function getHash()
160
    {
161
        return $this->hash;
162
    }
163
}
164