Issues (434)

Security Analysis    not enabled

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/providers/FormulaExamplesProvider.php (2 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
 * Finance module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-finance
6
 * @package   hipanel-module-finance
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\finance\providers;
12
13
use Yii;
14
15
/**
16
 * Class FormulaExamplesProvider.
17
 *
18
 * @author Dmytro Naumenko <[email protected]>
19
 */
20
class FormulaExamplesProvider
21
{
22
    public function getGroups()
23
    {
24
        $result[] = $this->groupOf(Yii::t('hipanel.finance.price', 'Fixed discount'), $this->fixedDiscountFormulas());
0 ignored issues
show
Coding Style Comprehensibility introduced by
$result was never initialized. Although not strictly required by PHP, it is generally a good practice to add $result = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
25
        $result[] = $this->groupOf(Yii::t('hipanel.finance.price', 'Growing discount'), $this->growingDiscountFormulas());
26
        $result[] = $this->groupOf(Yii::t('hipanel.finance.price', 'Leasing'), $this->leasingFormulas());
27
        $result[] = $this->groupOf(Yii::t('hipanel.finance.price', 'Monthly Cap'), $this->leasingFormulas());
28
29
        return $result;
30
    }
31
32
    private function fixedDiscountFormulas()
33
    {
34
        return [
35
            sprintf("discount.fixed('10%%').since('%s').reason('because')", date('m.Y')),
36
            sprintf("discount.fixed('11 USD').since('%s').reason('agreed')", date('m.Y')),
37
            sprintf("discount.fixed('20%%').till('%s').reason('loyalty')", date('m.Y', strtotime('+6 months'))),
38
            sprintf("discount.fixed('5 tb').since('%s').reason('bonus')", date('m.Y')) => Yii::t('hipanel.finance.price', 'Applicable for overuse prices. The example will compensate up to 5 TB of overuse as discount. Make sure to use appropriate unit, such as <code>items</code>, <code>gbps</code> or <code>hours</code>.'),
39
            sprintf("discount.fixed('5 tb').as('deposit,compensation').since('%s').reason('bonus')", date('m.Y')) => Yii::t('hipanel.finance.price', 'Applicable for overuse prices. Will compensate up to 5 TB of overuse as a separate Compensation bill. You can use any other bill type in option <code>.as()</code>, such as <code>deposit,creditnote</code> or <code>correction,positive</code>.'),
40
        ];
41
    }
42
43
    private function growingDiscountFormulas()
44
    {
45
        return [
46
            sprintf("discount.since('%s').grows('10pp').every('month').reason('because')", date('m.Y')) => Yii::t('hipanel.finance.price', '<code>10pp</code> means "10 percent points". A percent point is the arithmetic difference of two percentages. For example, moving up from 40% to 50% is a 10 percentage point increase, but is an actual 25% percent increase in what is being measured.'),
47
            sprintf("discount.since('%s').grows('10%%').every('month').max('100%%').reason('because')", date('m.Y')),
48
            sprintf("discount.since('%s').grows('20 USD').every('2 months').min('30 USD').max('80 USD')", date('m.Y')),
49
            sprintf("discount.since('%s').grows('1%%').every('1 months').min('5%%').max('25%%')", date('m.Y')),
50
        ];
51
    }
52
53
    private function leasingFormulas()
54
    {
55
        return [
56
            sprintf("leasing.since('%s').lasts('3 months').reason('TEST')", date('m.Y')),
57
        ];
58
    }
59
60
    private function mpnthlyCapFomulas()
0 ignored issues
show
This method is not used, and could be removed.
Loading history...
61
    {
62
        return [
63
            "cap.monthly('28 days')" => Yii::t('hipanel.finance.price',
64
                'The given formula is useful only for monthly prices. When the monthly invoice consumption exceeds the given cap, two charges will be produced: first at the price amount for 28 days, and second for 0 cents for the rest days of month.'
65
            ),
66
        ];
67
    }
68
69
    private function groupOf($name, $formulas)
70
    {
71
        return ['name' => $name, 'formulas' => $formulas];
72
    }
73
}
74