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.

Integrations/Breakdance/ElementControlsTrait.php (4 issues)

Labels
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Integrations\Breakdance;
4
5
use GeminiLabs\SiteReviews\Contracts\ShortcodeContract;
6
use GeminiLabs\SiteReviews\Helpers\Arr;
7
use GeminiLabs\SiteReviews\Helpers\Str;
8
9
trait ElementControlsTrait
10
{
11
    public static function bdShortcode(): ShortcodeContract
12
    {
13
        static $shortcode;
14
        if (empty($shortcode)) {
15
            $shortcode = glsr(static::bdShortcodeClass());
16
        }
17
        return $shortcode;
18
    }
19
20
    abstract public static function bdShortcodeClass(): string;
21
22
    /**
23
     * @return array[]
24
     */
25
    public static function contentControls()
26
    {
27
        $controls = [];
28
        $settings = [];
29
        $shortcode = static::bdShortcode();
30
        $transformer = new Transformer($shortcode->settings(), $shortcode->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...
31
        foreach ($transformer as $item) {
32
            $controls[$item['path']] = $item['control'];
33
        }
34
        $controls = Arr::unflatten(array_filter($controls));
35
        foreach ($controls as $slug => $children) {
36
            $section = $transformer->section($slug);
37
            foreach ($children as $key => $child) {
38
                if (!str_starts_with($key, 'popout_')) {
39
                    $section['children'][] = $child;
40
                    continue;
41
                }
42
                $slug = Str::removePrefix($key, 'popout_');
43
                $section['children'][] = $transformer->popout($slug, array_values($child));
44
            }
45
            $settings[] = $section;
46
        }
47
        return $settings;
48
    }
49
50
    /**
51
     * This must return false if the element has no default properties
52
     * otherwise SSR will not trigger when control values are changed.
53
     *
54
     * @return array|false
55
     */
56
    public static function defaultProperties()
57
    {
58
        $properties = [];
59
        $shortcode = static::bdShortcode();
60
        $config = $shortcode->settings();
61
        $defaults = array_filter($config, fn ($args) => isset($args['default']));
62
        $transformer = new Transformer($config, $shortcode->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...
63
        foreach ($transformer as $item) {
64
            $slug = $item['control']['slug'] ?? '';
65
            if (empty($slug) || !array_key_exists($slug, $defaults)) {
66
                continue;
67
            }
68
            $path = "content.{$item['path']}";
69
            $properties[$path] = $defaults[$slug]['default'];
70
        }
71
        if (empty($properties)) {
72
            return false;
73
        }
74
        return Arr::unflatten($defaults);
75
    }
76
77
    /**
78
     * Return an array of saved keyed values.
79
     */
80
    public static function ssrArgs(array $data): array
81
    {
82
        $args = [];
83
        $arrayIterator = new \RecursiveArrayIterator($data);
84
        $iterator = new \RecursiveIteratorIterator($arrayIterator, \RecursiveIteratorIterator::SELF_FIRST);
85
        $keys = array_keys(static::bdShortcode()->settings());
86
        $mappedKeys = [
87
            'attr_class' => 'class',
88
            'attr_id' => 'id',
89
        ];
90
        foreach ($iterator as $key => $value) {
91
            if (array_key_exists($key, $mappedKeys)) {
0 ignored issues
show
It seems like $key can also be of type true; however, parameter $key of array_key_exists() does only seem to accept integer|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

91
            if (array_key_exists(/** @scrutinizer ignore-type */ $key, $mappedKeys)) {
Loading history...
92
                $args[$mappedKeys[$key]] = $value;
93
                continue;
94
            }
95
            if (in_array($key, $mappedKeys)) {
96
                continue;
97
            }
98
            if (in_array($key, $keys)) {
99
                $args[$key] = $value;
100
            }
101
        }
102
        $replacements = [ // the post_chooser control requires integer keys
103
            -10 => 'post_id',
104
            -20 => 'parent_id',
105
            -30 => 'user_id',
106
            -40 => 'author_id',
107
            -50 => 'profile_id',
108
        ];
109
        foreach ($args as $key => $value) {
110
            if (!is_array($value)) {
111
                continue;
112
            }
113
            if (wp_is_numeric_array($value)) {
114
                $args[$key] = array_map(fn ($id) => $replacements[$id] ?? $id, $value);
115
            } else {
116
                $args[$key] = array_keys(array_filter($value));
117
            }
118
        }
119
        $args = glsr()->filterArray('breakdance/ssr', $args, $data, static::bdShortcode()->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...
120
        return $args;
121
    }
122
}
123