Issues (258)

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.

Components/TriggerService.php (6 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
 * (c) shopware AG <[email protected]>
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace ShopwarePlugins\Connect\Components;
9
10
use Doctrine\DBAL\Connection;
11
use Shopware\CustomModels\Connect\Attribute;
12
13
class TriggerService
14
{
15
    /**
16
     * @var Connection;
17
     */
18
    private $connection;
19
20
    /**
21
     * @param Connection $connection
22
     */
23
    public function __construct(Connection $connection)
24
    {
25
        $this->connection= $connection;
26
    }
27
28
    public function activateTriggers()
29
    {
30
        $this->createArticleTrigger();
31
        $this->createArticleDetailsTrigger();
32
        $this->createArticleAttributesTrigger();
33
        $this->createArticleImagesTrigger();
34
        $this->createArticleCategoriesTrigger();
35
        $this->createArticlePricesTrigger();
36
        $this->createArticleTranslationsTrigger();
37
        $this->createSupplierTrigger();
38
        $this->createTaxTrigger();
39
        $this->createCategoriesTrigger();
40
    }
41
42
    public function deactivateTriggers()
43
    {
44
        $this->connection->executeQuery('
45
            DROP TRIGGER IF EXISTS connect_article_trigger;
46
            DROP TRIGGER IF EXISTS connect_article_details_update_trigger;
47
            DROP TRIGGER IF EXISTS connect_article_details_insert_trigger;
48
            DROP TRIGGER IF EXISTS connect_article_details_delete_trigger;
49
            DROP TRIGGER IF EXISTS connect_article_attributes_update_trigger;
50
            DROP TRIGGER IF EXISTS connect_article_attributes_insert_trigger;
51
            DROP TRIGGER IF EXISTS connect_article_attributes_delete_trigger;
52
            DROP TRIGGER IF EXISTS connect_article_images_update_trigger;
53
            DROP TRIGGER IF EXISTS connect_article_images_insert_trigger;
54
            DROP TRIGGER IF EXISTS connect_article_images_delete_trigger;
55
            DROP TRIGGER IF EXISTS connect_article_categories_update_trigger;
56
            DROP TRIGGER IF EXISTS connect_article_categories_insert_trigger;
57
            DROP TRIGGER IF EXISTS connect_article_categories_delete_trigger;
58
            DROP TRIGGER IF EXISTS connect_article_prices_update_trigger;      
59
            DROP TRIGGER IF EXISTS connect_article_prices_insert_trigger;
60
            DROP TRIGGER IF EXISTS connect_article_prices_delete_trigger;
61
            DROP TRIGGER IF EXISTS connect_article_translations_update_trigger;
62
            DROP TRIGGER IF EXISTS connect_article_translations_insert_trigger;
63
            DROP TRIGGER IF EXISTS connect_article_translations_delete_trigger;
64
            DROP TRIGGER IF EXISTS connect_supplier_trigger;
65
            DROP TRIGGER IF EXISTS connect_tax_trigger;  
66
            DROP TRIGGER IF EXISTS connect_categories_trigger;  
67
        ');
68
    }
69
70
    private function createArticleTrigger()
71
    {
72
        $this->connection->executeQuery('
73
            CREATE TRIGGER connect_article_trigger
74
            AFTER UPDATE
75
            ON s_articles
76
            FOR EACH ROW
77
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = NEW.id
78
        ');
79
    }
80
81 View Code Duplication
    private function createArticleDetailsTrigger()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
82
    {
83
        $this->connection->executeQuery('
84
            CREATE TRIGGER connect_article_details_update_trigger
85
            AFTER UPDATE
86
            ON s_articles_details
87
            FOR EACH ROW
88
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = NEW.articleID
89
        ');
90
        $this->connection->executeQuery('
91
            CREATE TRIGGER connect_article_details_insert_trigger
92
            AFTER INSERT
93
            ON s_articles_details
94
            FOR EACH ROW
95
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = NEW.articleID
96
        ');
97
        $this->connection->executeQuery('
98
            CREATE TRIGGER connect_article_details_delete_trigger
99
            AFTER DELETE
100
            ON s_articles_details
101
            FOR EACH ROW
102
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_DELETE . '\' WHERE article_id = OLD.articleID
103
        ');
104
    }
105
106 View Code Duplication
    private function createArticleAttributesTrigger()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
107
    {
108
        $this->connection->executeQuery('
109
            CREATE TRIGGER connect_article_attributes_update_trigger
110
            AFTER UPDATE
111
            ON s_articles_attributes
112
            FOR EACH ROW
113
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = NEW.articleID
114
        ');
115
        $this->connection->executeQuery('
116
            CREATE TRIGGER connect_article_attributes_insert_trigger
117
            AFTER INSERT
118
            ON s_articles_attributes
119
            FOR EACH ROW
120
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = NEW.articleID
121
        ');
122
        $this->connection->executeQuery('
123
            CREATE TRIGGER connect_article_attributes_delete_trigger
124
            AFTER DELETE
125
            ON s_articles_attributes
126
            FOR EACH ROW
127
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = OLD.articleID
128
        ');
129
    }
130
131 View Code Duplication
    private function createArticleImagesTrigger()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
132
    {
133
        $this->connection->executeQuery('
134
            CREATE TRIGGER connect_article_images_update_trigger
135
            AFTER UPDATE
136
            ON s_articles_img
137
            FOR EACH ROW
138
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = NEW.articleID
139
        ');
140
        $this->connection->executeQuery('
141
            CREATE TRIGGER connect_article_images_insert_trigger
142
            AFTER INSERT
143
            ON s_articles_img
144
            FOR EACH ROW
145
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = NEW.articleID
146
        ');
147
        $this->connection->executeQuery('
148
            CREATE TRIGGER connect_article_images_delete_trigger
149
            AFTER DELETE
150
            ON s_articles_img
151
            FOR EACH ROW
152
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = OLD.articleID
153
        ');
154
    }
155
156 View Code Duplication
    private function createArticleCategoriesTrigger()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
157
    {
158
        $this->connection->executeQuery('
159
            CREATE TRIGGER connect_article_categories_update_trigger
160
            AFTER UPDATE
161
            ON s_articles_categories
162
            FOR EACH ROW
163
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = NEW.articleID
164
        ');
165
        $this->connection->executeQuery('
166
            CREATE TRIGGER connect_article_categories_insert_trigger
167
            AFTER INSERT
168
            ON s_articles_categories
169
            FOR EACH ROW
170
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = NEW.articleID
171
        ');
172
        $this->connection->executeQuery('
173
            CREATE TRIGGER connect_article_categories_delete_trigger
174
            AFTER DELETE
175
            ON s_articles_categories
176
            FOR EACH ROW
177
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = OLD.articleID
178
        ');
179
    }
180
181 View Code Duplication
    private function createArticlePricesTrigger()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
182
    {
183
        $this->connection->executeQuery('
184
            CREATE TRIGGER connect_article_prices_update_trigger
185
            AFTER UPDATE
186
            ON s_articles_prices
187
            FOR EACH ROW
188
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = NEW.articleID
189
        ');
190
        $this->connection->executeQuery('
191
            CREATE TRIGGER connect_article_prices_insert_trigger
192
            AFTER INSERT
193
            ON s_articles_prices
194
            FOR EACH ROW
195
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = NEW.articleID
196
        ');
197
        $this->connection->executeQuery('
198
            CREATE TRIGGER connect_article_prices_delete_trigger
199
            AFTER DELETE
200
            ON s_articles_prices
201
            FOR EACH ROW
202
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = OLD.articleID
203
        ');
204
    }
205
206 View Code Duplication
    private function createArticleTranslationsTrigger()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
207
    {
208
        $this->connection->executeQuery('
209
            CREATE TRIGGER connect_article_translations_update_trigger
210
            AFTER UPDATE
211
            ON s_articles_translations
212
            FOR EACH ROW
213
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = NEW.articleID
214
        ');
215
        $this->connection->executeQuery('
216
            CREATE TRIGGER connect_article_translations_insert_trigger
217
            AFTER INSERT
218
            ON s_articles_translations
219
            FOR EACH ROW
220
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = NEW.articleID
221
        ');
222
        $this->connection->executeQuery('
223
            CREATE TRIGGER connect_article_translations_delete_trigger
224
            AFTER DELETE
225
            ON s_articles_translations
226
            FOR EACH ROW
227
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id = OLD.articleID
228
        ');
229
    }
230
231
    private function createSupplierTrigger()
232
    {
233
        $this->connection->executeQuery('
234
            CREATE TRIGGER connect_supplier_trigger
235
            AFTER UPDATE
236
            ON s_articles_supplier
237
            FOR EACH ROW
238
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id IN 
239
                    (
240
                        SELECT id FROM s_articles WHERE supplierID = NEW.id
241
                    );
242
        ');
243
    }
244
245
    private function createTaxTrigger()
246
    {
247
        $this->connection->executeQuery('
248
            CREATE TRIGGER connect_tax_trigger
249
            AFTER UPDATE
250
            ON s_core_tax
251
            FOR EACH ROW
252
                IF (NEW.tax <> OLD.tax) THEN
253
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id IN 
254
                    (
255
                        SELECT id FROM s_articles WHERE taxID = NEW.id
256
                    );
257
                END IF;
258
        ');
259
    }
260
261
    private function createCategoriesTrigger()
262
    {
263
        $this->connection->executeQuery('
264
            CREATE TRIGGER connect_categories_trigger
265
            AFTER UPDATE
266
            ON s_categories
267
            FOR EACH ROW
268
                IF (NEW.description <> OLD.description) OR (NEW.parent <> OLD.parent) THEN
269
                UPDATE s_plugin_connect_items SET cron_update = 1, export_status = \'' . Attribute::STATUS_UPDATE . '\' WHERE article_id IN 
270
                    (
271
                        SELECT articleID FROM s_articles_categories WHERE categoryID = NEW.id
272
                    );
273
                END IF;
274
        ');
275
    }
276
}
277