Issues (18)

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/Utility/TranslateUtility.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
/**
4
 * TranslateUtility.
5
 */
6
declare(strict_types = 1);
7
8
namespace HDNET\Autoloader\Utility;
9
10
use TYPO3\CMS\Core\Utility\GeneralUtility;
11
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
12
13
/**
14
 * TranslateUtility.
15
 */
16
class TranslateUtility
17
{
18
    /**
19
     * Assure the translation for the given key.
20
     * If not exists create the label in the xml/xlf file.
21
     * Returns the localization.
22
     *
23
     * Use the Slot to handle the label
24
     *
25
     * @see LocalizationUtility::translate
26
     *
27
     * @param string $key           key in the localization file
28
     * @param string $extensionName
29
     * @param string $default       default value of the label
30
     * @param array  $arguments     arguments are being passed over to vsprintf
31
     * @param string $tableName
32
     *
33
     * @return string
34
     */
35
    public static function assureLabel($key, $extensionName, $default = null, $arguments = null, $tableName = null)
36
    {
37
        if (\is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['autoloader']['assureLabel'])) {
38
            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['autoloader']['assureLabel'] as $classConfig) {
39
                $object = GeneralUtility::makeInstance($classConfig);
40
                if (\is_object($object) && method_exists($object, 'assureLabel')) {
41
                    $object->assureLabel($key, $extensionName, $default, $arguments, $tableName);
42
                }
43
            }
44
        }
45
46
        return (string)$default;
47
    }
48
49
    /**
50
     * Get the given LLL String or render a help message for the user.
51
     *
52
     * @param string $key
53
     * @param string $extensionKey
54
     * @param string $tableName
55
     *
56
     * @return string
57
     */
58
    public static function getLllOrHelpMessage($key, $extensionKey, $tableName = null)
59
    {
60
        $lllString = self::getLllString($key, $extensionKey, null, $tableName);
61
        if (TYPO3_MODE === 'BE' && !isset($GLOBALS['LANG'])) {
62
            $GLOBALS['LANG'] = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageService::class);
63
            $GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc['lang']);
64
        }
65
        if (TYPO3_MODE === 'BE' && null === self::getLll($key, $extensionKey, $tableName)) {
66
            $lllString = self::getLll('pleaseSet', 'autoloader') . $lllString;
67
            if (isset($GLOBALS['LANG'])) {
68
                self::assureLabel($key, $extensionKey, $key, null, $tableName);
69
            }
70
        }
71
72
        return $lllString;
73
    }
74
75
    /**
76
     * Get the correct LLL string for the given key and extension.
77
     *
78
     * @param string $key
79
     * @param        $extensionKey
80
     * @param string $file
81
     * @param string $tableName
82
     *
83
     * @return string
84
     */
85
    public static function getLllString($key, $extensionKey, $file = null, $tableName = null)
86
    {
87
        if (null === $file) {
88
            $file = 'locallang.xlf';
89
        }
90
        if (self::useTableNameFileBase() && null !== $tableName) {
91
            $file = $tableName . '.xlf';
92
        }
93
94
        return 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/' . $file . ':' . $key;
95
    }
96
97
    /**
98
     * Get the translation for the given key.
99
     *
100
     * @param string $key
101
     * @param string $extensionKey
102
     * @param string $tableName
103
     *
104
     * @return string
105
     */
106
    public static function getLll($key, $extensionKey, $tableName = null)
107
    {
108
        $file = self::getLllString($key, $extensionKey, null, $tableName);
109
110
        if (\defined('TYPO3_REQUESTTYPE') && TYPO3_REQUESTTYPE === 16) {
111
            // Do not call the translation workflow in install tool
112
            return $file;
113
        }
114
        if (GeneralUtility::getApplicationContext()->isTesting()) {
0 ignored issues
show
Deprecated Code introduced by
The method TYPO3\CMS\Core\Utility\G...getApplicationContext() has been deprecated with message: since TYPO3 v10.2, will be removed in TYPO3 v11, use Environment::getContext() 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...
115
            // Do not call translation workflow in testinng
116
            return $file;
117
        }
118
119
        return LocalizationUtility::translate($file, $extensionKey);
120
    }
121
122
    /**
123
     * Check if table name file base is used.
124
     *
125
     * @return bool
126
     */
127
    protected static function useTableNameFileBase()
128
    {
129
        $configuration = unserialize((string)$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['autoloader']);
130
131
        return isset($configuration['enableLanguageFileOnTableBase']) ? (bool)$configuration['enableLanguageFileOnTableBase'] : false;
132
    }
133
}
134