Issues (102)

Security Analysis    no vulnerabilities found

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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.

plugin/Integrations/Bricks/BricksElement.php (11 issues)

1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Bricks;
4
5
use GeminiLabs\SiteReviews\Helper;
6
use GeminiLabs\SiteReviews\Helpers\Cast;
7
use GeminiLabs\SiteReviews\Integrations\IntegrationShortcode;
8
9
abstract class BricksElement extends \Bricks\Element
0 ignored issues
show
The type Bricks\Element was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
{
11
    use IntegrationShortcode;
12
13
    public $nestable = false;
14
    public $scripts = ['GLSR_init'];
15
16
    public function __construct($element = null)
17
    {
18
        $this->category = glsr()->id;
0 ignored issues
show
Bug Best Practice introduced by
The property category does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
19
        $this->icon = "ti-{$this->shortcodeInstance()->tag}";
0 ignored issues
show
Accessing tag on the interface GeminiLabs\SiteReviews\Contracts\ShortcodeContract suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
Bug Best Practice introduced by
The property icon does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
20
        $this->name = $this->shortcodeInstance()->tag;
0 ignored issues
show
Bug Best Practice introduced by
The property name does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
21
        parent::__construct($element);
22
    }
23
24
    public function add_actions()
25
    {
26
        add_action('wp_enqueue_scripts', function () {
27
            wp_add_inline_style('bricks-frontend', ".brxe-{$this->name} {width: 100%}");
28
        });
29
    }
30
31
    public function designConfig(): array
32
    {
33
        return [];
34
    }
35
36
    public function elementConfig(): array
37
    {
38
        return $this->shortcodeInstance()->settings();
39
    }
40
41
    public function get_keywords()
42
    {
43
        return ['review', 'reviews', 'site reviews'];
44
    }
45
46
    public function get_label()
47
    {
48
        return $this->shortcodeInstance()->name;
49
    }
50
51
    public function load()
52
    {
53
        parent::load();
54
        $groups = array_map(fn ($args) => $args['group'] ?? '', $this->controls);
55
        $groups = array_filter($groups, fn ($value) => !str_starts_with($value, '_'));
56
        $groups = array_values(array_filter(array_unique($groups)));
57
        foreach ($this->control_groups as $key => $value) {
58
            if (str_starts_with($key, '_')) {
59
                continue;
60
            }
61
            if (in_array($key, $groups)) {
62
                continue;
63
            }
64
            unset($this->control_groups[$key]);
65
        }
66
    }
67
68
    public static function registerElement(): void
69
    {
70
        $reflection = new \ReflectionClass(static::class);
71
        $file = $reflection->getFileName();
72
        $className = $reflection->getName();
73
        \Bricks\Elements::register_element($file, '', $className);
0 ignored issues
show
The type Bricks\Elements was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
74
    }
75
76
    public function render()
77
    {
78
        $buttonClasses = ['bricks-button'];
79
        if ($buttonStyle = $this->styledSetting('style_button_preset')) {
80
            $buttonClasses[] = "bricks-background-{$buttonStyle}";
81
        }
82
        if ($buttonSize = $this->styledSetting('style_button_size')) {
83
            $buttonClasses[] = $buttonSize;
84
        }
85
        $buttonClasses = implode(' ', $buttonClasses);
86
        $html = $this->shortcodeInstance()->build($this->settings, 'bricks');
87
        $html = str_replace('glsr-button', "glsr-button {$buttonClasses}", $html);
88
        echo "<{$this->get_tag()} {$this->render_attributes('_root')}>";
89
        echo $html;
90
        echo "</{$this->get_tag()}>";
91
    }
92
93
    /**
94
     * @see https://academy.bricksbuilder.io/article/filter-bricks-elements-element_name-control_groups/
95
     */
96
    public function set_control_groups()
97
    {
98
        $groups = [ // order is intentional
99
            'general' => esc_html_x('General', 'admin-text', 'site-reviews'),
100
            'design' => esc_html_x('Design', 'admin-text', 'site-reviews'),
101
            'advanced' => esc_html_x('Advanced', 'admin-text', 'site-reviews'),
102
        ];
103
        foreach ($groups as $key => $title) {
104
            $this->control_groups[$key] = [
0 ignored issues
show
Bug Best Practice introduced by
The property control_groups does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
105
                'tab' => 'content',
106
                'title' => $title,
107
            ];
108
        }
109
    }
110
111
    /**
112
     * @see https://academy.bricksbuilder.io/article/filter-bricks-elements-element_name-controls
113
     */
114
    public function set_controls()
115
    {
116
        $this->controls ??= [];
117
        $this->control_groups ??= [];
118
        $config = array_merge($this->elementConfig(), $this->designConfig());
119
        foreach ($config as $key => $args) {
120
            $args = wp_parse_args($args, [
121
                'group' => 'general',
122
                'tab' => 'content',
123
                'type' => 'text',
124
            ]);
125
            $method = Helper::buildMethodName('set', $args['type'], 'control');
126
            if (!method_exists($this, $method)) {
127
                $this->controls[$key] = $args;
0 ignored issues
show
Bug Best Practice introduced by
The property controls does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
128
                continue;
129
            }
130
            call_user_func([$this, $method], $key, $args);
131
        }
132
        if (count(glsr()->retrieveAs('array', 'review_types', [])) < 2) {
133
            unset($this->controls['type']);
134
        }
135
    }
136
137
    public function styledClasses(array $classes = []): array
138
    {
139
        if ($align = $this->styledSetting('style_align')) {
140
            $classes[] = "items-justified-{$align}";
141
        }
142
        return $classes;
143
    }
144
145
    public function styledSetting(string $key): string
146
    {
147
        $value = $this->settings[$key] ?? '';
148
        $value = $value ?: $this->theme_styles[$key] ?? '';
149
        return Cast::toString($value);
150
    }
151
152
    protected function setCheckboxControl(string $key, array $args): void
153
    {
154
        if (empty($args['options'])) {
155
            $this->controls[$key] = $args;
0 ignored issues
show
Bug Best Practice introduced by
The property controls does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
156
            return;
157
        }
158
        foreach ($args['options'] as $value => $label) {
159
            $this->controls["{$key}_{$value}"] = [
160
                'default' => false,
161
                'group' => $args['group'],
162
                'label' => $label,
163
                'tab' => 'content',
164
                'type' => 'checkbox',
165
            ];
166
        }
167
    }
168
169
    protected function setNumberControl(string $key, array $args): void
170
    {
171
        if (isset($args['css'])) {
172
            $this->controls[$key] = $args;
0 ignored issues
show
Bug Best Practice introduced by
The property controls does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
173
            return;
174
        }
175
        $control = [
176
            // 'small' => true,
177
            'type' => 'slider',
178
            'units' => false,
179
        ];
180
        $this->controls[$key] = wp_parse_args($control, $args);
181
    }
182
183
    protected function setSelectControl(string $key, array $args): void
184
    {
185
        if (!in_array($key, ['assigned_posts', 'assigned_terms', 'assigned_users', 'author', 'post_id'])) {
186
            $this->controls[$key] = $args;
0 ignored issues
show
Bug Best Practice introduced by
The property controls does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
187
            return;
188
        }
189
        $control = [
190
            'type' => 'select',
191
            'searchable' => true,
192
            'optionsAjax' => ['action' => "bricks_glsr_{$key}"],
193
        ];
194
        if (in_array($key, ['assigned_posts', 'assigned_terms', 'assigned_users'])) {
195
            $control['multiple'] = true;
196
        }
197
        $this->controls[$key] = wp_parse_args($control, $args);
198
    }
199
}
200