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/EbayEx.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
 * Copyright (c) Padosoft.com 2017.
4
 * Created by Paolo Nardini - 2017-08-31
5
 */
6
7
8
namespace Padosoft\AffiliateNetwork;
9
use Oara\Network\Publisher\Ebay as EbayOara;
10
11
class EbayEx extends EbayOara
12
{
13
    protected $_serverNumber = 6;
14
    protected $_merchantIdList = array();     // To avoid repeated calls to \Oara\Utilities::getMerchantIdMapFromMerchantList
15
16
    /**
17
     * @param $credentials
18
     */
19
    public function login($credentials)
20
    {
21
        $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...
22
        $this->_client = new \Oara\Curl\Access($credentials);
23
24
        /*
25
        $valuesLogin = array(
26
            new \Oara\Curl\Parameter('login_username', $this->_credentials['user']),
27
            new \Oara\Curl\Parameter('login_password', $this->_credentials['password']),
28
            new \Oara\Curl\Parameter('submit_btn', 'GO'),
29
            new \Oara\Curl\Parameter('hubpage', 'y')
30
        );
31
        $loginUrl = 'https://ebaypartnernetwork.com/PublisherLogin?hubpage=y&lang=en-US?';
32
33
        $urls = array();
34
        $urls[] = new \Oara\Curl\Request($loginUrl, $valuesLogin);
35
        $this->_client->post($urls);
36
        */
37
    }
38
39
    /**
40
     * @return array
41
     */
42 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...
43
    {
44
        $credentials = array();
45
46
        $parameter = array();
47
        $parameter["description"] = "User Log in";
48
        $parameter["required"] = true;
49
        $parameter["name"] = "User";
50
        $credentials["user"] = $parameter;
51
52
        $parameter = array();
53
        $parameter["description"] = "Password to Log in";
54
        $parameter["required"] = true;
55
        $parameter["name"] = "Password";
56
        $credentials["password"] = $parameter;
57
58
        return $credentials;
59
    }
60
61
    /**
62
     * @return bool
63
     */
64
    public function checkConnection()
65
    {
66
        //If not login properly the construct launch an exception
67
        $connection = true;
68
        /*
69
        $yesterday = new \DateTime();
70
        $yesterday->sub(new \DateInterval('P2D'));
71
72
        $urls = array();
73
        $urls[] = new \Oara\Curl\Request("https://publisher.ebaypartnernetwork.com/PublisherReportsTx?pt=2&start_date={$yesterday->format("n/j/Y")}&end_date={$yesterday->format("n/j/Y")}&user_name={$this->_credentials['user']}&user_password={$this->_credentials['password']}&advIdProgIdCombo=&tx_fmt=2&submit_tx=Download", array());
74
        $exportReport = $this->_client->get($urls);
75
76
        if (\preg_match("/DOCTYPE html PUBLIC/", $exportReport[0])) {
77
            $connection = false;
78
        }
79
        */
80
        return $connection;
81
    }
82
83
    /**
84
     * @param string $idSite
85
     */
86
    public function addAllowedSite(string $idSite){
87
        $this->_sitesAllowed[]=$idSite;
88
    }
89
90
    /**
91
     * @return array
92
     */
93 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...
94
    {
95
        $merchants = array();
96
97
        $obj = array();
98
        $obj['cid'] = "1";
99
        $obj['name'] = "Ebay";
100
        $obj['url'] = "https://publisher.ebaypartnernetwork.com";
101
        $merchants[] = $obj;
102
103
        return $merchants;
104
    }
105
106
    /**
107
     * @param null $merchantList
108
     * @param \DateTime|null $dStartDate
109
     * @param \DateTime|null $dEndDate
110
     * @return array
111
     */
112
    public function getTransactionList($merchantList = null, \DateTime $dStartDate = null, \DateTime $dEndDate = null)
113
    {
114
        $totalTransactions = array();
115
116
        $urls = array();
117
118
        $postParams = array(
119
            new \Oara\Curl\Parameter('username', $this->_credentials['user']),
120
            new \Oara\Curl\Parameter('password', $this->_credentials['password']),
121
            new \Oara\Curl\Parameter('isEnc', 'false'),
122
            new \Oara\Curl\Parameter('fileFormat', 'txt'),
123
            new \Oara\Curl\Parameter('eventType', 'earnings'),  // use 'all' to download all events
124
            new \Oara\Curl\Parameter('startPostDate', $dStartDate->format('Y-m-d')),
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...
125
            new \Oara\Curl\Parameter('endPostDate', $dEndDate->format('Y-m-d')),
0 ignored issues
show
It seems like $dEndDate 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...
126
        );
127
        $url = new \Oara\Curl\Request("https://api.epn.ebay.com/rpt/events/v1/detail/tdr", $postParams );
128
129
130
        $urls[] = $url;
131
        $exportData = array();
132
133
        try {
134
            $exportReport = $this->_client->post($urls, 0);
135
            $exportData = \str_getcsv($exportReport[0], "\n");
136
        } catch (\Exception $e) {
137
            // ignore any error
138
        }
139
140
        // OLD Version - URL Doesn't work anymore - 2017-08-31 <PN>
141
        /*
142
        $urls = array();
143
        $urls[] = new \Oara\Curl\Request("https://publisher.ebaypartnernetwork.com/PublisherReportsTx?pt=2&start_date={$dStartDate->format("n/j/Y")}&end_date={$dEndDate->format("n/j/Y")}&user_name={$this->_credentials['user']}&user_password={$this->_credentials['password']}&advIdProgIdCombo=&tx_fmt=3&submit_tx=Download", array());
144
        $exportData = array();
145
        try {
146
            $exportReport = $this->_client->get($urls, 'content', 5);
147
            $exportData = \str_getcsv($exportReport[0], "\n");
148
        } catch (\Exception $e) {
149
150
        */
151
        $num = \count($exportData);
152
        for ($i = 1; $i < $num; $i++) {
153
            $transactionExportArray = \str_getcsv($exportData[$i], "\t");
154
155
            if ($transactionExportArray[2] == "Winning Bid (Revenue)" && (empty($this->_sitesAllowed) || \in_array($transactionExportArray[5], $this->_sitesAllowed))) {
156
                $transaction = Array();
157
                $transaction['merchantId'] = 0;
158
                $transaction['merchantName'] = '';
159
                $transaction['unique_id']  = $transactionExportArray[18];
160
                $transactionDate = \DateTime::createFromFormat("Y-m-d", $transactionExportArray[0]);
161
                $transaction['date'] = $transactionDate->format("Y-m-d") . ' 00:00:00';
162
                $postDate = \DateTime::createFromFormat("Y-m-d", $transactionExportArray[1]);
163
                $transaction['post_date'] = $postDate->format("Y-m-d") . ' 00:00:00';
164
                if ($transactionExportArray[10] != null) {
165
                    $transaction['custom_id'] = $transactionExportArray[10];
166
                }
167
                $transaction['click_date'] = $transactionExportArray[11];
168
                $transaction['ebay_amount'] = (float) $transactionExportArray[3];
169
                $transaction['amount'] = (float) $transactionExportArray[15];
170
                $transaction['commission'] = (float) $transactionExportArray[20];
171
                // Set status as Pending
172
                // ... real status (approved / denied) must be calculated by summing all negative/positive records
173
                // ... and checking final amount for a positive or zero value
174
                $transaction['status'] = \Oara\Utilities::STATUS_PENDING;
175
                $totalTransactions[] = $transaction;
176
            }
177
        }
178
        return $totalTransactions;
179
    }
180
}
181