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/Service/CacheService.php (1 issue)

Labels
Severity

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\Service;
15
16
use Romm\Formz\Exceptions\ClassNotFoundException;
17
use Romm\Formz\Exceptions\InvalidOptionValueException;
18
use Romm\Formz\Service\Traits\ExtendedSelfInstantiateTrait;
19
use TYPO3\CMS\Core\Cache\Backend\BackendInterface;
20
use TYPO3\CMS\Core\Cache\CacheManager;
21
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
22
use TYPO3\CMS\Core\SingletonInterface;
23
use TYPO3\CMS\Core\Utility\GeneralUtility;
24
25
class CacheService implements SingletonInterface
26
{
27
    use ExtendedSelfInstantiateTrait;
28
29
    const CACHE_IDENTIFIER = 'cache_formz';
30
    const CONFIGURATION_OBJECT_CACHE_IDENTIFIER = 'cache_formz_configuration_object';
31
    const GENERATED_FILES_PATH = 'typo3temp/FormZ/';
32
33
    /**
34
     * @var TypoScriptService
35
     */
36
    protected $typoScriptService;
37
38
    /**
39
     * @var FrontendInterface
40
     */
41
    protected $cacheInstance;
42
43
    /**
44
     * @var CacheManager
45
     */
46
    protected $cacheManager;
47
48
    /**
49
     * Returns the type of backend cache defined in TypoScript at the path:
50
     * `settings.defaultBackendCache`.
51
     *
52
     * @return string
53
     * @throws ClassNotFoundException
54
     * @throws InvalidOptionValueException
55
     */
56
    public function getBackendCache()
57
    {
58
        $backendCache = $this->typoScriptService->getExtensionConfigurationFromPath('settings.defaultBackendCache');
59
60
        if (false === class_exists($backendCache)) {
61
            throw ClassNotFoundException::backendCacheClassNameNotFound($backendCache);
62
        }
63
64
        if (false === in_array(BackendInterface::class, class_implements($backendCache))) {
65
            throw InvalidOptionValueException::wrongBackendCacheType($backendCache);
66
        }
67
68
        return $backendCache;
69
    }
70
71
    /**
72
     * Returns the cache instance used by this extension.
73
     *
74
     * @return FrontendInterface
75
     */
76
    public function getCacheInstance()
77
    {
78
        if (null === $this->cacheInstance) {
79
            $this->cacheInstance = $this->cacheManager->getCache(self::CACHE_IDENTIFIER);
80
        }
81
82
        return $this->cacheInstance;
83
    }
84
85
    /**
86
     * Generic cache identifier creation for usages in the extension.
87
     *
88
     * @param string $formClassName
89
     * @param string $formName
90
     * @return string
91
     */
92
    public function getFormCacheIdentifier($formClassName, $formName)
93
    {
94
        $shortClassName = end(explode('\\', $formClassName));
0 ignored issues
show
explode('\\', $formClassName) cannot be passed to end() as the parameter $array expects a reference.
Loading history...
95
96
        return StringService::get()->sanitizeString($shortClassName . '-' . $formName);
97
    }
98
99
    /**
100
     * Function called when clearing TYPO3 caches. It will remove the temporary
101
     * asset files created by FormZ.
102
     *
103
     * @param array $parameters
104
     */
105
    public function clearCacheCommand($parameters)
106
    {
107
        if (in_array($parameters['cacheCmd'], ['all', 'system'])) {
108
            $files = $this->getFilesInPath(self::GENERATED_FILES_PATH . '*');
109
110
            foreach ($files as $file) {
111
                $this->clearFile($file);
112
            }
113
        }
114
    }
115
116
    /**
117
     * @param string $path
118
     * @return array
119
     */
120
    protected function getFilesInPath($path)
121
    {
122
        $files = glob(GeneralUtility::getFileAbsFileName($path));
123
124
        return (false === $files)
125
            ? []
126
            : $files;
127
    }
128
129
    /**
130
     * @param string $file
131
     */
132
    protected function clearFile($file)
133
    {
134
        touch($file, 0);
135
    }
136
137
    /**
138
     * @param CacheManager $cacheManager
139
     */
140
    public function injectCacheManager(CacheManager $cacheManager)
141
    {
142
        $this->cacheManager = $cacheManager;
143
    }
144
145
    /**
146
     * @param TypoScriptService $typoScriptService
147
     */
148
    public function injectTypoScriptService(TypoScriptService $typoScriptService)
149
    {
150
        $this->typoScriptService = $typoScriptService;
151
    }
152
}
153