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/EffiliationEx.php (3 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
 */
5
namespace Padosoft\AffiliateNetwork;
6
use Oara\Network\Publisher\Effiliation as EffiliationOara;
7
8
class EffiliationEx extends EffiliationOara{
9
    /**
10
     * @param null $merchantList
11
     * @param \DateTime|null $dStartDate
12
     * @param \DateTime|null $dEndDate
13
     * @return array
14
     */
15
    public function getTransactionList($merchantList = null, \DateTime $dStartDate = null, \DateTime $dEndDate = null)
16
    {
17
        try {
18
19
            $totalTransactions = array();
20
21
            $merchantIdList = \Oara\Utilities::getMerchantIdMapFromMerchantList($merchantList);
0 ignored issues
show
$merchantIdList is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
22
23
            // Retrieve by date transaction instead of date click (type=datetran)- <PN> 2017-07-05
24
            // Fixed endpoint to apiv2.effiliation.com <PN> 2020-08-12
25
            $url = 'https://apiv2.effiliation.com/apiv2/transaction.csv?key=' . $this->_credentials["apiPassword"] . '&start=' . $dStartDate->format("d/m/Y") . '&end=' . $dEndDate->format("d/m/Y") . '&type=datetran&all=yes&timestamp=' . time();
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...
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...
26
            // Set timeout to 300 secs. due to api delays - <PN> 2017-06-20
27
            $ctx = stream_context_create(array(
28
                    'http' => array(
29
                        'timeout' => 300
30
                    )
31
                )
32
            );
33
            // Log Debug info
34
            echo (New \DateTime())->format("d/m/Y H:i:s") . " - EffiliationEx getTransactionList from " . $dStartDate->format("d/m/Y") . " to " . $dEndDate->format("d/m/Y"),PHP_EOL;
35
36
            $content = \utf8_encode(\file_get_contents($url, 0, $ctx));
37
            $exportData = \str_getcsv($content, "\n");
38
            $num = \count($exportData);
39
40
            for ($i = 1; $i < $num; $i++) {
41
                $transactionExportArray = \str_getcsv($exportData[$i], "|");
42
                // We don't need to check whether the merchant id is valid or not ...
43
                // ... for old transactions may be expired and not included in current merchant list
44
                // <PN> 2017-06-22
45
                // if (isset($merchantIdList[(int)$transactionExportArray[2]])) {
46
47
                $transaction = Array();
48
                $merchantId = (int)$transactionExportArray[2];
49
                $transaction['merchantId'] = $merchantId;
50
                // Changed Transaction date index from 10 to 12 - 2018-01-01 <PN>
51
                $transaction['date'] = $transactionExportArray[12];
52
                $transaction["click_date"] = $transactionExportArray[11]; // Added <PN>
53
                $transaction['unique_id'] = $transactionExportArray[0];
54
                $transaction['custom_id'] = '';
55
                $transaction['status'] = \Oara\Utilities::STATUS_PENDING;
56
                if ($transactionExportArray[4] != null) {
57
                    $transaction['custom_id'] = $transactionExportArray[4];
58
                }
59
60
                switch ($transactionExportArray[9]) {
61
                    case 'Valide':
62
                        $transaction['status'] = \Oara\Utilities::STATUS_CONFIRMED;
63
                        break;
64
                    case 'Attente':
65
                        $transaction['status'] = \Oara\Utilities::STATUS_PENDING;
66
                        break;
67
                    case 'Refusé':
68
                    case 'Refuse':
69
                        // Handle both variations - <PN> - 2017-06-21
70
                        $transaction['status'] = \Oara\Utilities::STATUS_DECLINED;
71
                        break;
72
                    default:
73
                        // Invalid status
74
                        echo PHP_EOL."EffiliationEx - Invalid transaction status: " . $transactionExportArray[9] . " (transaction id = " . $transactionExportArray[0] . ")";
75
                        break;
76
                }
77
                $transaction['amount'] = \Oara\Utilities::parseDouble($transactionExportArray[7]);
78
                $transaction['commission'] = \Oara\Utilities::parseDouble($transactionExportArray[8]);
79
                // Get absolute values - 2017-12-13 <PN>
80
                $transaction ['amount'] = \abs($transaction ['amount']);
81
                $transaction ['commission'] = \abs($transaction ['commission']);
82
                $totalTransactions[] = $transaction;
83
                // }
84
            }
85
        } catch (\Exception $e) {
86
            // Avoid lost of transactions if one date failed - <PN> - 2017-06-20
87
            echo PHP_EOL."EffiliationEx - getTransactionList err: ".$e->getMessage().PHP_EOL;
88
            throw new \Exception($e);
89
        }
90
        echo (New \DateTime())->format("d/m/Y H:i:s") . " - EffiliationEx getTransactionList - return " . count($totalTransactions) . " transactions" . PHP_EOL;
91
        return $totalTransactions;
92
    }
93
}
94