Issues (10)

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/Commands/DownloadCsvTemplate.php (2 issues)

Severity
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Commands;
4
5
use GeminiLabs\League\Csv\CannotInsertRecord;
6
use GeminiLabs\League\Csv\EscapeFormula;
7
use GeminiLabs\League\Csv\Writer;
8
use GeminiLabs\SiteReviews\Modules\Notice;
9
use GeminiLabs\SiteReviews\Modules\Rating;
10
11
class DownloadCsvTemplate extends AbstractCommand
12
{
13
    public function data(): array
14
    {
15
        return [ // order is intentional
16
            'date' => '2023-01-13 12:01:13',
17
            'date_gmt' => '',
18
            'rating' => 5,
19
            'title' => 'Eclectic, Cozy, and Highly Recommended!',
20
            'content' => 'I will definitely stay here again. It was a wonderful experience!',
21
            'name' => 'Matt Mullenweg',
22
            'email' => '[email protected]',
23
            'avatar' => 'https://gravatar.com/avatar/767fc9c115a1b989744c755db47feb60?s=128',
24
            'ip_address' => '198.143.164.252',
25
            'terms' => 1,
26
            'author_id' => '',
27
            'is_approved' => 1,
28
            'is_pinned' => 0,
29
            'is_verified' => 0,
30
            'response' => '',
31
            'assigned_posts' => '',
32
            'assigned_terms' => '',
33
            'assigned_users' => '',
34
            'score' => 0,
35
        ];
36
    }
37
38
    public function handle(): void
39
    {
40
        try {
41
            $writer = Writer::createFromString('');
0 ignored issues
show
Deprecated Code introduced by
The function GeminiLabs\League\Csv\Ab...Csv::createFromString() has been deprecated: since version 9.27.0 ( Ignorable by Annotation )

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

41
            $writer = /** @scrutinizer ignore-deprecated */ Writer::createFromString('');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
42
            $writer->addFormatter(new EscapeFormula());
43
            $writer->insertOne(array_keys($this->data()));
44
            $writer->insertOne(array_values($this->data()));
45
            nocache_headers();
46
            $writer->output('reviews-template.csv');
0 ignored issues
show
Deprecated Code introduced by
The function GeminiLabs\League\Csv\AbstractCsv::output() has been deprecated: since version 9.18.0 ( Ignorable by Annotation )

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

46
            /** @scrutinizer ignore-deprecated */ $writer->output('reviews-template.csv');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
47
            exit;
48
        } catch (CannotInsertRecord $e) {
49
            $this->fail();
50
            glsr(Notice::class)->addError($e->getMessage());
51
            glsr_log()
52
                ->warning('Unable to insert row into CSV template file')
53
                ->debug($e->getRecord());
54
        }
55
    }
56
57
    public function required(): array
58
    {
59
        return [
60
            'date', 'rating',
61
        ];
62
    }
63
64
    public function tableColumns(): array
65
    {
66
        return [
67
            'default' => [
68
                'assigned_posts' => _x('The Post ID or "post_type:slug" of the page that the review is assigned to (separate multiple values with a comma)', 'admin-text', 'site-reviews'),
69
                'assigned_terms' => _x('The Term ID or "slug" of the category that the review is assigned to (separate multiple values with a comma)', 'admin-text', 'site-reviews'),
70
                'assigned_users' => _x('The User ID or "username" of the user that the review is assigned to (separate multiple values with a comma)', 'admin-text', 'site-reviews'),
71
                'author_id' => _x('The User ID or "username" of the reviewer', 'admin-text', 'site-reviews'),
72
                'avatar' => _x('The avatar URL of the reviewer', 'admin-text', 'site-reviews'),
73
                'content' => _x('The review', 'admin-text', 'site-reviews'),
74
                'date' => _x('The review date', 'admin-text', 'site-reviews'),
75
                'date_gmt' => _x('The review GMT date', 'admin-text', 'site-reviews'),
76
                'email' => _x('The reviewer\'s email', 'admin-text', 'site-reviews'),
77
                'ip_address' => _x('The IP address of the reviewer', 'admin-text', 'site-reviews'),
78
                'is_approved' => sprintf(_x('%s or %s', 'admin-text', 'site-reviews'), 'TRUE', 'FALSE'),
79
                'is_pinned' => sprintf(_x('%s or %s', 'admin-text', 'site-reviews'), 'TRUE', 'FALSE'),
80
                'is_verified' => sprintf(_x('%s or %s', 'admin-text', 'site-reviews'), 'TRUE', 'FALSE'),
81
                'name' => _x('The reviewer\'s name', 'admin-text', 'site-reviews'),
82
                'rating' => sprintf(_x('A number from %d-%d', 'admin-text', 'site-reviews'), Rating::min(), Rating::max()),
83
                'response' => _x('The review response', 'admin-text', 'site-reviews'),
84
                'terms' => sprintf(_x('%s or %s', 'admin-text', 'site-reviews'), 'TRUE', 'FALSE'),
85
                'title' => _x('The title of the review', 'admin-text', 'site-reviews'),
86
            ],
87
            'site-reviews-actions' => [
88
                'language' => sprintf(_x('The ISO 639-1 language code of the review. See %s for a list of all supported languages.', 'admin-text', 'site-reviews'), '<a href="https://developers.deepl.com/docs/getting-started/supported-languages#translation-source-languages" target="_blank">DeepL</a>'),
89
                'score' => _x('The number of times the review was upvoted.', 'admin-text', 'site-reviews'),
90
            ],
91
            'site-reviews-forms' => [
92
                'custom_*' => _x('The value of a custom review field (replace the asterisk <code>*</code> of the column name with the name of your custom field).', 'admin-text', 'site-reviews'),
93
                'form' => _x('The Post ID or slug of the Review Form used to submit the review', 'admin-text', 'site-reviews'),
94
            ],
95
            'site-reviews-images' => [
96
                'images' => _x('The URLs of the review images (separate multiple URLs with a pipe "|" character or comma)', 'admin-text', 'site-reviews'),
97
            ],
98
            'site-reviews-themes' => [
99
                'type' => _x('The lowercase name of the platform that the review was exported from (only use this if the review was exported from another review platform, i.e. google, tripadvisor, etc.)', 'admin-text', 'site-reviews'),
100
                'url' => _x('The review URL (only use this if the review was exported from another review platform, i.e. google, tripadvisor, etc.)', 'admin-text', 'site-reviews'),
101
            ],
102
        ];
103
    }
104
105
    public function tableData(): array
106
    {
107
        $data = [];
108
        foreach ($this->tableColumns() as $group => $columns) {
109
            foreach ($columns as $name => $description) {
110
                $required = in_array($name, $this->required())
111
                    ? sprintf('<span class="glsr-tag glsr-tag-required">%s</span>', _x('Yes', 'admin-text', 'site-reviews'))
112
                    : sprintf('<span class="glsr-tag">%s</span>', _x('No', 'admin-text', 'site-reviews'));
113
                $notice = '';
114
                if ('default' !== $group) {
115
                    $text = _x('%s addon required.', 'link to addon page (admin-text)', 'site-reviews');
116
                    $notice = sprintf('<div class="glsr-notice-inline components-notice is-warning">%s</div>',
117
                        sprintf($text, glsr_premium_link($group))
118
                    );
119
                }
120
                $data[$name] = compact('description', 'notice', 'required');
121
            }
122
        }
123
        ksort($data);
124
        return $data;
125
    }
126
}
127