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/Networks/Partnerize.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
namespace Padosoft\AffiliateNetwork\Networks;
4
5
use Padosoft\AffiliateNetwork\Transaction;
6
use Padosoft\AffiliateNetwork\DealsResultset;
7
use Padosoft\AffiliateNetwork\Merchant;
8
use Padosoft\AffiliateNetwork\Stat;
9
use Padosoft\AffiliateNetwork\Deal;
10
use Padosoft\AffiliateNetwork\AbstractNetwork;
11
use Padosoft\AffiliateNetwork\NetworkInterface;
12
use Padosoft\AffiliateNetwork\AffiliateWindowEx;
13
use Padosoft\AffiliateNetwork\ProductsResultset;
14
15
/**
16
 * Class Partnerize
17
 * @package Padosoft\AffiliateNetwork\Networks
18
 */
19
class Partnerize extends AbstractNetwork implements NetworkInterface
20
{
21
    /**
22
     * @var object
23
     */
24
    private $_network = null;
25
    private $_apiClient = null;
26
    private $_username = '';
27
    private $_password = '';
28
    private $_logged    = false;
29
    protected $_tracking_parameter    = 'pubref';
30
31
    /**
32
     * @method __construct
33
     */
34
    public function __construct(string $username, string $password)
35
    {
36
        $this->_network = new \Oara\Network\Publisher\PerformanceHorizon();
37
        $this->_username = $username;
38
        $this->_password = $password;
39
        $this->_apiClient = null;
40
        $this->login( $this->_username, $this->_password );
41
    }
42
43
    public function login(string $username, string $password): bool
44
    {
45
        $this->_logged = false;
46
        if (isNullOrEmpty( $username ) || isNullOrEmpty( $password )) {
47
            return false;
48
        }
49
        $this->_username = $username;
50
        $this->_password = $password;
51
        $credentials = array();
52
        $credentials["accountid"] = $this->_username;
53
        $credentials["apipassword"] = $this->_password;
54
        $this->_network->login( $credentials );
55
        if ($this->_network->checkConnection()) {
56
            $this->_logged = true;
57
58
        }
59
60
        return $this->_logged;
61
    }
62
63
    /**
64
     * @return bool
65
     */
66
    public function checkLogin() : bool
67
    {
68
        return $this->_logged;
69
    }
70
71
    /**
72
     * @return array of Merchants
73
     */
74 View Code Duplication
    public function getMerchants() : array
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...
75
    {
76
        if (!$this->checkLogin()) {
77
            return array();
78
        }
79
        $arrResult = array();
80
        $merchantList = $this->_network->getMerchantList();
81
        foreach($merchantList as $merchant) {
82
            $Merchant = Merchant::createInstance();
83
            $Merchant->merchant_ID = $merchant['cid'];
84
            $Merchant->name = $merchant['name'];
85
            $Merchant->status = $merchant['status'];
86
            $arrResult[] = $Merchant;
87
        }
88
        return $arrResult;
89
    }
90
91
    /**
92
     * @param int|null $merchantID
93
     * @param int $page
94
     * @param int $items_per_page
95
     *
96
     * @return DealsResultset
97
     */
98
    public function getDeals($merchantID,int $page=0,int $items_per_page=10) : DealsResultset
99
    {
100
        // TODO: Implement getDeals() method.
101
        throw new \Exception("Not implemented yet");
102
    }
103
104
    /**
105
     * @param \DateTime $dateFrom
106
     * @param \DateTime $dateTo
107
     * @param int $merchantID
0 ignored issues
show
There is no parameter named $merchantID. Did you maybe mean $arrMerchantID?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
108
     * @return array of Transaction
109
     */
110 View Code Duplication
    public function getSales(\DateTime $dateFrom, \DateTime $dateTo, array $arrMerchantID = array()) : array
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...
111
    {
112
        $arrResult = array();
113
114
        try {
115
            // Added timezone parameter
116
            $transactionList = $this->_network->getTransactionList($arrMerchantID, $dateFrom, $dateTo, 'UTC');
117
118
            if (is_array($transactionList)) {
119
                foreach ($transactionList as $transaction) {
120
                    try {
121
122
                        $myTransaction = Transaction::createInstance();
123
124
                        $myTransaction->merchant_ID = $transaction['merchantId'];
125
                        $myTransaction->date = $transaction['date'];
126
                        if (!empty($transaction['date'])) {
127
                            $date = new \DateTime($transaction['date'], new \DateTimeZone('UTC'));
128
                            $myTransaction->date = $date;
0 ignored issues
show
Documentation Bug introduced by
It seems like $date of type object<DateTime> is incompatible with the declared type string of property $date.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
129
                        }
130
                        $myTransaction->unique_ID = $transaction['unique_id'];
131
                        if (isset($transaction['custom_id'])) {
132
                            $myTransaction->custom_ID = $transaction['custom_id'];
133
                        }
134
                        $myTransaction->status = $transaction['status'];
135
                        $myTransaction->amount = \Oara\Utilities::parseDouble($transaction['amount']);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Oara\Utilities::parseDo...$transaction['amount']) of type string or integer is incompatible with the declared type double of property $amount.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
136
                        $myTransaction->commission = \Oara\Utilities::parseDouble($transaction['commission']);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Oara\Utilities::parseDo...nsaction['commission']) of type string or integer is incompatible with the declared type double of property $commission.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
137
                        $myTransaction->currency = $transaction['currency'];
138
                        $arrResult[] = $myTransaction;
139
                    } catch (\Exception $e) {
140
                        echo "<br><br>Transaction Error Partnerize, id: " . $myTransaction['unique_id'] . " msg: ".$e->getMessage()."<br><br>";
141
                        var_dump($e->getTraceAsString());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($e->getTraceAsString()); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
142
                    }
143
                }
144
            }
145
        } catch (\Exception $e) {
146
            echo "<br><br>Generic Error Partnerize: ".$e->getMessage()."<br><br>";
147
            var_dump($e->getTraceAsString());
148
            throw new \Exception($e);
149
        }
150
        return $arrResult;
151
    }
152
153
    /**
154
     * @param \DateTime $dateFrom
155
     * @param \DateTime $dateTo
156
     * @param int $merchantID
157
     * @return array of Stat
158
     */
159
    public function getStats(\DateTime $dateFrom, \DateTime $dateTo, int $merchantID = 0) : array
160
    {
161
        return array();        
162
    }
163
164
165
    /**
166
     * @param  array $params
167
     *
168
     * @return ProductsResultset
169
     */
170
    public function getProducts(array $params = []): ProductsResultset
171
    {
172
        // TODO: Implement getProducts() method.
173
        throw new \Exception("Not implemented yet");
174
    }
175
176
    public function getTrackingParameter(){
177
        return $this->_tracking_parameter;
178
    }
179
}
180