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/PriceGateway.php (5 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 Shopware\Models\Customer\Group;
11
12
/**
13
 * Price gateway
14
 *
15
 * @category  Shopware
16
 * @package   Shopware\Components\Api
17
 * @copyright Copyright (c) shopware AG (http://www.shopware.de)
18
 */
19
class PriceGateway
20
{
21
    private $db;
22
23
    public function __construct(\Enlight_Components_Db_Adapter_Pdo_Mysql $db)
24
    {
25
        $this->db = $db;
26
    }
27
28
    /**
29
     * Returns count of product without
30
     * configured price
31
     *
32
     * @param Group $group
0 ignored issues
show
Should the type for parameter $group not be null|Group?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
33
     * @param $priceField
34
     * @throws \Zend_Db_Statement_Exception
35
     * @return array
36
     */
37 View Code Duplication
    public function countProductsWithoutConfiguredPrice(Group $group = null, $priceField)
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...
38
    {
39
        if ($priceField == 'detailPurchasePrice') {
40
            $query = $this->db->query('
41
                SELECT COUNT(sad.id)
42
                FROM s_articles_details sad
43
                LEFT JOIN s_plugin_connect_items spci ON sad.id = spci.article_detail_id
44
                WHERE spci.shop_id IS NULL AND sad.purchaseprice = 0
45
            ');
46
        } else {
47
            $query = $this->db->query("
48
                SELECT COUNT(sad.id)
49
                FROM s_articles_details sad
50
                LEFT JOIN s_articles_prices sap ON sad.id = sap.articledetailsID AND sap.pricegroup = ?
51
                LEFT JOIN s_plugin_connect_items spci ON sad.id = spci.article_detail_id
52
                WHERE spci.shop_id IS NULL AND sap.{$priceField} IS NULL OR sap.{$priceField} = 0
53
            ", [$group->getKey()]);
54
        }
55
56
        return (int) $query->fetchColumn();
57
    }
58
59
    /**
60
     * Returns count of product with
61
     * configured price
62
     *
63
     * @param Group $group
0 ignored issues
show
Should the type for parameter $group not be null|Group?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
64
     * @param $priceField
65
     * @throws \Zend_Db_Statement_Exception
66
     * @return array
67
     */
68 View Code Duplication
    public function countProductsWithConfiguredPrice(Group $group = null, $priceField)
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...
69
    {
70
        if ($priceField == 'detailPurchasePrice') {
71
            $query = $this->db->query('
72
                SELECT COUNT(sad.id)
73
                FROM s_articles_details sad
74
                LEFT JOIN s_plugin_connect_items spci ON sad.id = spci.article_detail_id
75
                WHERE spci.shop_id IS NULL AND sad.purchaseprice > 0
76
            ');
77
        } else {
78
            $query = $this->db->query("
79
                SELECT COUNT(sad.id)
80
                FROM s_articles_details sad
81
                LEFT JOIN s_articles_prices sap ON sad.id = sap.articledetailsID AND sap.pricegroup = ?
82
                LEFT JOIN s_plugin_connect_items spci ON sad.id = spci.article_detail_id
83
                WHERE spci.shop_id IS NULL AND sap.{$priceField} IS NOT NULL AND sap.{$priceField} > 0
84
            ", [$group->getKey()]);
85
        }
86
87
        return (int) $query->fetchColumn();
88
    }
89
90
    /**
91
     * Returns count of product including variants for a group
92
     *
93
     * @param Group $group
0 ignored issues
show
Should the type for parameter $group not be null|Group?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
94
     * @throws \Zend_Db_Statement_Exception
95
     * @return array
96
     */
97
    public function countProducts(Group $group = null)
98
    {
99
        $query = $this->db->query('
100
            SELECT COUNT(sad.id)
101
            FROM s_articles_details sad
102
            LEFT JOIN s_articles_prices sap ON sad.id = sap.articledetailsID AND sap.pricegroup = ?
103
            LEFT JOIN s_plugin_connect_items spci ON sad.id = spci.article_detail_id
104
            WHERE spci.shop_id IS NULL', [$group->getKey()]);
105
106
        return (int) $query->fetchColumn();
107
    }
108
}
109