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/AffiliateFuture.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
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 AffiliateFuture
17
 * @package Padosoft\AffiliateNetwork\Networks
18
 */
19
class AffiliateFuture 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    = 'tracking';
30
31
    /**
32
     * @method __construct
33
     */
34
    public function __construct(string $username, string $password)
35
    {
36
        $this->_network = new \Oara\Network\Publisher\AffiliateFuture();
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["user"] = $this->_username;
53
        $credentials["password"] = $this->_password;
54
        $this->_network->login( $credentials );
55
        if ($this->_network->checkConnection()) {
56
            $this->_logged = true;
57
        }
58
        return $this->_logged;
59
    }
60
61
    /**
62
     * @return bool
63
     */
64
    public function checkLogin() : bool
65
    {
66
        return $this->_logged;
67
    }
68
69
    /**
70
     * @return array of Merchants
71
     */
72
    public function getMerchants() : array
73
    {
74
        if (!$this->checkLogin()) {
75
            return array();
76
        }
77
        $arrResult = array();
78
        $merchantList = $this->_network->getMerchantList();
79
        foreach($merchantList as $merchant) {
80
            $Merchant = Merchant::createInstance();
81
            $Merchant->merchant_ID = $merchant['cid'];
82
            $Merchant->name = $merchant['name'];
83
            $Merchant->url = $merchant['url'];
84
            $Merchant->status = $merchant['joined'] == 'no' ? 'notjoined' : 'joined';
85
            $arrResult[] = $Merchant;
86
        }
87
        return $arrResult;
88
    }
89
90
    /**
91
     * @param int|null $merchantID
92
     * @param int $page
93
     * @param int $items_per_page
94
     *
95
     * @return DealsResultset
96
     */
97
    public function getDeals($merchantID,int $page=0,int $items_per_page=10) : DealsResultset
98
    {
99
        // TODO: Implement getDeals() method.
100
        throw new \Exception("Not implemented yet");
101
    }
102
103
    /**
104
     * @param \DateTime $dateFrom
105
     * @param \DateTime $dateTo
106
     * @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...
107
     * @return array of Transaction
108
     */
109 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...
110
    {
111
        $arrResult = array();
112
113
        try {
114
            // Added timezone parameter
115
            $transactionList = $this->_network->getTransactionList($arrMerchantID, $dateFrom, $dateTo, 'UTC');
116
117
            if (is_array($transactionList)) {
118
                foreach ($transactionList as $transaction) {
119
                    try {
120
121
                        $myTransaction = Transaction::createInstance();
122
123
                        $myTransaction->merchant_ID = $transaction['merchantId'];
124
                        $myTransaction->date = $transaction['date'];
125
                        if (!empty($transaction['date'])) {
126
                            $date = new \DateTime($transaction['date'], new \DateTimeZone('UTC'));
127
                            $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...
128
                        }
129
                        $myTransaction->unique_ID = $transaction['unique_id'];
130
                        if (isset($transaction['custom_id'])) {
131
                            $myTransaction->custom_ID = $transaction['custom_id'];
132
                        }
133
                        $myTransaction->status = $transaction['status'];
134
                        $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...
135
                        $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...
136
                        $myTransaction->currency = $transaction['currency'];
137
                        $arrResult[] = $myTransaction;
138
                    } catch (\Exception $e) {
139
                        echo "[AffiliateFuture][Error] id: " . $myTransaction['unique_id'] . " msg: ".$e->getMessage();
140
                        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...
141
                    }
142
                }
143
            }
144
        } catch (\Exception $e) {
145
            echo "[AffiliateFuture][Error] ". $e->getMessage();
146
            var_dump($e->getTraceAsString());
147
            throw new \Exception($e);
148
        }
149
        return $arrResult;
150
    }
151
152
    /**
153
     * @param \DateTime $dateFrom
154
     * @param \DateTime $dateTo
155
     * @param int $merchantID
156
     * @return array of Stat
157
     */
158
    public function getStats(\DateTime $dateFrom, \DateTime $dateTo, int $merchantID = 0) : array
159
    {
160
        return array();
161
    }
162
163
164
    /**
165
     * @param  array $params
166
     *
167
     * @return ProductsResultset
168
     */
169
    public function getProducts(array $params = []): ProductsResultset
170
    {
171
        // TODO: Implement getProducts() method.
172
        throw new \Exception("Not implemented yet");
173
    }
174
175
    public function getTrackingParameter(){
176
        return $this->_tracking_parameter;
177
    }
178
}
179