Issues (315)

Security Analysis    no request data  

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.

src/GrouponEx.php (7 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
 * Copyright (c) Padosoft.com 2017.
4
 * Created by Paolo Nardini - 2018-03-02
5
 */
6
namespace Padosoft\AffiliateNetwork;
7
8
use Oara\Network\Publisher\Groupon as GrouponOara;
9
10
class GrouponEx extends GrouponOara
11
{
12
    protected $_merchantIdList = array();     // To avoid repeated calls to \Oara\Utilities::getMerchantIdMapFromMerchantList
13
    protected $_countryIsoCode;               // Iso code of country to filter transactions
14
15
    /**
16
     * @param $credentials
17
     */
18
    public function login($credentials)
19
    {
20
        $this->_credentials = $credentials;
0 ignored issues
show
The property _credentials does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
21
        $this->_client = new \Oara\Curl\Access($credentials);
0 ignored issues
show
The property _client does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
22
    }
23
24
    /**
25
     * @return array
26
     */
27 View Code Duplication
    public function getNeededCredentials()
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...
28
    {
29
        $credentials = array();
30
31
        $parameter = array();
32
        $parameter["description"] = "User Log in";
33
        $parameter["required"] = true;
34
        $parameter["name"] = "User";
35
        $credentials["user"] = $parameter;
36
37
        $parameter = array();
38
        $parameter["description"] = "Password to Log in";
39
        $parameter["required"] = true;
40
        $parameter["name"] = "Password";
41
        $credentials["password"] = $parameter;
42
43
        return $credentials;
44
    }
45
46
    /**
47
     * @return bool
48
     */
49
    public function checkConnection()
50
    {
51
        // Groupon don't need to check connection
52
        $connection = true;
53
        return $connection;
54
    }
55
56
    /**
57
     * @param string $idSite
58
     */
59
    public function addAllowedSite(string $idSite){
60
        $this->_sitesAllowed[] = $idSite;
0 ignored issues
show
The property _sitesAllowed does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
61
    }
62
63
    /**
64
     * @param string $countryIsoCode
65
     */
66
    public function addCountry(string $countryIsoCode){
67
        $this->_countryIsoCode = $countryIsoCode;
68
    }
69
70
    /**
71
     * @return array
72
     */
73 View Code Duplication
    public function getMerchantList()
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...
74
    {
75
        $merchants = array();
76
77
        $obj = array();
78
        $obj['cid'] = "1";
79
        $obj['name'] = "Groupon";
80
        $obj['url'] = "";
81
        $merchants[] = $obj;
82
83
        return $merchants;
84
    }
85
86
87
    /**
88
     * @param null $merchantList
89
     * @param \DateTime|null $dStartDate
90
     * @param \DateTime|null $dEndDate
91
     * @return array
92
     * @throws \Exception
93
     */
94
    public function getTransactionList($merchantList = null, \DateTime $dStartDate = null, \DateTime $dEndDate = null)
95
    {
96
        $totalTransactions = array();
97
        $auxDate = clone $dStartDate;
98
        $amountDays = $dStartDate->diff($dEndDate)->days;
0 ignored issues
show
It seems like $dStartDate is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
99
        for ($j = 0; $j < $amountDays; $j++) {
100
101
            // Getting the csv by curl can throw an exception if the csv size is 0 bytes. So, first of all, get the json. If total is 0, continue, else, get the csv.
102
            $valuesFormExport = array();
103
            $url = "https://partner-int-api.groupon.com/reporting/v2/order.json?clientId={$this->_credentials['apipassword']}&group=order&date={$auxDate->format("Y-m-d")}";
104
            if (!empty($this->_countryIsoCode)) {
105
                $url .= '&order.country=' . $this->_countryIsoCode;
106
            }
107
            $urls = array();
108
            $urls[] = new \Oara\Curl\Request($url, $valuesFormExport);
109
            $exportReport = $this->_client->get($urls);
110
            $jsonExportReport = json_decode($exportReport[0], true);
111
112
            if ($jsonExportReport['total'] != 0) {
113
114
                $valuesFormExport = array();
115
                $url = "https://partner-int-api.groupon.com/reporting/v2/order.csv?clientId={$this->_credentials['apipassword']}&group=order&date={$auxDate->format("Y-m-d")}";
116
                if (!empty($this->_countryIsoCode)) {
117
                    $url .= '&order.country=' . $this->_countryIsoCode;
118
                }
119
                $urls = array();
120
                $urls[] = new \Oara\Curl\Request($url, $valuesFormExport);
121
                $exportReport = $this->_client->get($urls);
122
                $exportData = \str_getcsv($exportReport[0], "\n");
123
                $num = \count($exportData);
124
                for ($i = 1; $i < $num; $i++) {
125
                    $transactionExportArray = \str_getcsv($exportData[$i], ",");
126
                    $transaction = Array();
127
                    $transaction['merchantId'] = "1";
128
                    $transaction['date'] = $auxDate->format("Y-m-d H:i:s");
129
                    $transaction['unique_id'] = $transactionExportArray[0];
130
                    $transaction['currency'] = $transactionExportArray[4];
131
132
                    if ($transactionExportArray[1] != null) {
133
                        $transaction['custom_id'] = $transactionExportArray[1];
134
                    }
135
136 View Code Duplication
                    if ($transactionExportArray[5] == 'VALID') {
0 ignored issues
show
This code seems to be duplicated across 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...
137
                        $transaction['status'] = \Oara\Utilities::STATUS_CONFIRMED;
138
                    } else if ($transactionExportArray[5] == 'INVALID' || $transactionExportArray[5] == 'REFUNDED') {
139
                        $transaction['status'] = \Oara\Utilities::STATUS_DECLINED;
140
                    } else {
141
                        throw new \Exception("Status {$transactionExportArray[5]} unknown");
142
                    }
143
144
                    $transaction['amount'] = \Oara\Utilities::parseDouble((double)$transactionExportArray[8]);
145
                    $transaction['commission'] = \Oara\Utilities::parseDouble((double)$transactionExportArray[12]);
146
                    $totalTransactions[] = $transaction;
147
                }
148
            }
149
            $auxDate->add(new \DateInterval('P1D'));
150
        }
151
152
        return $totalTransactions;
153
    }
154
155
}
156