Issues (58)

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.

code/LangEditor.php (14 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
 * @author    Donatas Navidonskis <[email protected]>
5
 * @since     2017
6
 * @class     LangEditor
7
 *
8
 */
9
class LangEditor extends LeftAndMain implements PermissionProvider {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
10
11
    /**
12
     * @var string
13
     * @config
14
     */
15
    private static $menu_title = 'Lang Editor';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
The property $menu_title is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
16
17
    /**
18
     * @var string
19
     * @config
20
     */
21
    private static $url_segment = 'lang-editor';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
The property $url_segment is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
22
23
    /**
24
     * @var float
25
     * @config
26
     */
27
    private static $menu_priority = -0.6;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
The property $menu_priority is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
28
29
    /**
30
     * @var array
31
     * @config
32
     */
33
    private static $allowed_actions = [
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
The property $allowed_actions is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
34
        'FormEntities',
35
    ];
36
37
    /**
38
     * Default configuration of items per page.
39
     * Set "null" if unlimited.
40
     *
41
     * @var int
42
     * @config
43
     */
44
    private static $items_per_page = 30;
0 ignored issues
show
The property $items_per_page is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
45
46
    /**
47
     * @return array
48
     */
49
    public function providePermissions() {
50
        $title = _t('LangEditor.MENU_TITLE', 'Lang Editor');
51
52
        return [
53
            "CMS_ACCESS_LangEditorAdmin" => [
54
                'name'     => _t('CMSMain.ACCESS', "Access to '{title}' section", ['title' => $title]),
0 ignored issues
show
array('title' => $title) is of type array<string,string,{"title":"string"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
55
                'category' => _t('Permission.CMS_ACCESS_CATEGORY', 'CMS Access'),
56
            ],
57
        ];
58
    }
59
60
    /**
61
     *
62
     * @param Member $member
63
     *
64
     * @return int|bool
65
     */
66
    public function canView($member = null) {
67
        return Permission::check('CMS_ACCESS_LangEditorAdmin', 'any', $member);
0 ignored issues
show
Bug Compatibility introduced by
The expression \Permission::check('CMS_...dmin', 'any', $member); of type boolean|string|null adds the type string to the return on line 67 which is incompatible with the return type of the parent method LeftAndMain::canView of type boolean.
Loading history...
68
    }
69
70
    public function init() {
71
        static::config()->menu_title = _t('LangEditor.MENU_TITLE', 'Lang Editor');
72
73
        return parent::init();
74
    }
75
76
    public static function flushCache() {
77
        $cache = SS_Cache::factory(static::class);
78
        $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
79
    }
80
81
    public function getModules() {
82
        $list = new ArrayList();
83
        $parameters = $this->getRequest()->getVars();
84
85
        unset($parameters['url']);
86
        unset($parameters['start']);
87
        unset($parameters['search']);
88
89
        LangModule::get()->each(function (LangModule $module) use ($parameters, &$list) {
90
            if (array_key_exists('moduleId', $parameters) && $parameters['moduleId'] == $module->ID) {
91
                $module->Current = true;
0 ignored issues
show
The property Current does not exist on object<LangModule>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
92
            }
93
94
            $parameters['moduleId'] = $module->ID;
95
96
            $module->Link = Controller::join_links(
0 ignored issues
show
The property Link does not exist on object<LangModule>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
97
                Controller::curr()->Link(),
98
                "?".http_build_query($parameters)
99
            );
100
101
            $list->push($module);
102
        });
103
104
        if (! $list->filter('Current', true)->first() && $list->count() > 0) {
105
            $list->first()->Current = true;
106
        }
107
108
        return $list;
109
    }
110
111
    public function getCurrentModule() {
112
        return $this->getModules()->filter('Current', true)->first();
113
    }
114
115
    public function getCurrentSearchTerm() {
116
        return $this->getRequest()->getVar('search');
117
    }
118
119
    public function FormEntities() {
120
        /** @var LangModule $module */
121
        if ($module = $this->getModules()->filter('Current', true)->first()) {
122
            $entities = $module->Entities();
123
            $searchTerm = $this->getRequest()->getVar('search');
124
125
            if (! empty($searchTerm)) {
126
                $entities = $entities->filter('SearchFields:LangFulltextBoolean', $searchTerm);
127
            }
128
129
            $parameters = $this->getRequest()->getVars();
130
131
            unset($parameters['url']);
132
133
            $parameters = count($parameters) > 0 ? '?'.http_build_query($parameters) : '';
134
135
            $form = new FormEntities(Controller::curr(), __FUNCTION__, $entities);
136
            $form->clearMessage();
137
            $form->setFormAction(Controller::join_links(
138
                $this->Link('FormEntities'),
139
                $parameters
140
            ));
141
142
            return $form;
143
        }
144
145
        return false;
146
    }
147
}