Issues (4714)

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.

tests/unit/Currency/CurrencyTest.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
Intraface_Doctrine_Intranet::singleton(1);
3
4
class CurrencyTest extends PHPUnit_Framework_TestCase
5
{
6
    private $object = null;
0 ignored issues
show
The property $object is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
7
8
    function setUp()
9
    {
10
        $db = MDB2::singleton(DB_DSN);
11
        $db->query('TRUNCATE currency');
12
        $db->query('TRUNCATE currency_exchangerate');
13
    }
14
15
    ///////////////////////////////////////////////////////
16
17
    function testConstruct()
18
    {
19
        $object = new Intraface_modules_currency_Currency;
20
        $this->assertTrue(is_object($object));
21
    }
22
23
    function testSave()
24
    {
25
        $object = new Intraface_modules_currency_Currency;
26
        $type = new Intraface_modules_currency_Currency_Type;
27
        $object->setType($type->getByIsoCode('EUR'));
28
        try {
29
            $object->save();
30
        } catch(Exception $e) {
31
            $this->assertTrue(false, $e->getMessage());
32
        }
33
    }
34
35
    function testGetType()
36
    {
37
        $object = new Intraface_modules_currency_Currency;
38
        $type = new Intraface_modules_currency_Currency_Type;
39
        $object->setType($type->getByIsoCode('EUR'));
40
        $object->save();
41
42
        $object = Doctrine::getTable('Intraface_modules_currency_Currency')->find(1);
43
        $this->assertEquals('Intraface_modules_currency_Currency_Type_Eur', get_class($object->getType()));
44
    }
45
46
    function testGetProductPriceExchangeRate()
47
    {
48
        $currency = new Intraface_modules_currency_Currency;
49
        $type = new Intraface_modules_currency_Currency_Type;
50
        $currency->setType($type->getByIsoCode('EUR'));
51
        $currency->save();
52
53
        $rate = new Intraface_modules_currency_Currency_ExchangeRate_ProductPrice;
54
        $rate->setRate(new Ilib_Variable_Float('745,21', 'da_dk'));
55
        $rate->setCurrency($currency);
56
        $rate->save();
57
58
        $rate = new Intraface_modules_currency_Currency_ExchangeRate_ProductPrice;
59
        $rate->setRate(new Ilib_Variable_Float('745,23', 'da_dk'));
60
        $rate->setCurrency($currency);
61
        $rate->save();
62
63
        $gateway = new Intraface_modules_currency_Currency_Gateway(Doctrine_Manager::connection());
64
        $currency = $gateway->findById(1);
65
66
        $rate = $currency->getProductPriceExchangeRate();
67
        $this->assertEquals('745,23', $rate->getRate()->getAsLocal('da_dk'));
68
    }
69
70
    function testGetProductPriceExchangeRateReturnsNewestWithTwoCurrencies()
71
    {
72
        /**
73
         * Of some strange reason with the following posts in the database it does not
74
         * return the latest exchange rate
75
         */
76
77
        # create Euro with exchange rate
78
        $currency_eur = new Intraface_modules_currency_Currency;
79
        $type = new Intraface_modules_currency_Currency_Type;
80
        $currency_eur->setType($type->getByIsoCode('EUR'));
81
        $currency_eur->save();
82
83
        $rate = new Intraface_modules_currency_Currency_ExchangeRate_ProductPrice;
84
        $rate->setRate(new Ilib_Variable_Float('7,21', 'da_dk'));
85
        $rate->setCurrency($currency_eur);
86
        $rate->save();
87
88
        $rate = new Intraface_modules_currency_Currency_ExchangeRate_Payment;
89
        $rate->setRate(new Ilib_Variable_Float('7,20', 'da_dk'));
90
        $rate->setCurrency($currency_eur);
91
        $rate->save();
92
93
94
        # create dollars with exchange rate
95
        $currency_usd = new Intraface_modules_currency_Currency;
96
        $type = new Intraface_modules_currency_Currency_Type;
97
        $currency_usd->setType($type->getByIsoCode('USD'));
98
        $currency_usd->save();
99
100
        $rate = new Intraface_modules_currency_Currency_ExchangeRate_ProductPrice;
101
        $rate->setRate(new Ilib_Variable_Float('530', 'da_dk'));
102
        $rate->setCurrency($currency_usd);
103
        $rate->save();
104
105
        $rate = new Intraface_modules_currency_Currency_ExchangeRate_Payment;
106
        $rate->setRate(new Ilib_Variable_Float('531', 'da_dk'));
107
        $rate->setCurrency($currency_usd);
108
        $rate->save();
109
110
111
        # Adds a new euro exchange rate
112
        $rate = new Intraface_modules_currency_Currency_ExchangeRate_ProductPrice;
113
        $rate->setRate(new Ilib_Variable_Float('745,23', 'da_dk'));
114
        $rate->setCurrency($currency_eur);
115
        $rate->save();
116
117
        $rate = new Intraface_modules_currency_Currency_ExchangeRate_Payment;
118
        $rate->setRate(new Ilib_Variable_Float('745,24', 'da_dk'));
119
        $rate->setCurrency($currency_eur);
120
        $rate->save();
121
122
        $gateway = new Intraface_modules_currency_Currency_Gateway(Doctrine_Manager::connection());
123
        // $currency = $gateway->findById(1);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
124
125
        $currencies = $gateway->findAllWithExchangeRate();
126
127
        foreach ($currencies as $currency) {
128
            if ($currency->getType()->getIsoCode() == 'EUR') {
129
                $rate = $currency->getProductPriceExchangeRate(0);
130
                $this->assertEquals('745,23', $rate->getRate()->getAsLocal('da_dk'));
131
            }
132
        }
133
    }
134
135
    function testGetProductPriceExchangeRateWithId()
136
    {
137
        $currency = new Intraface_modules_currency_Currency;
138
        $type = new Intraface_modules_currency_Currency_Type;
139
        $currency->setType($type->getByIsoCode('EUR'));
140
        $currency->save();
141
142
        $rate = new Intraface_modules_currency_Currency_ExchangeRate_ProductPrice;
143
        $rate->setRate(new Ilib_Variable_Float('745,21', 'da_dk'));
144
        $rate->setCurrency($currency);
145
        $rate->save();
146
147
        $rate = new Intraface_modules_currency_Currency_ExchangeRate_Payment;
148
        $rate->setRate(new Ilib_Variable_Float('745,80', 'da_dk'));
149
        $rate->setCurrency($currency);
150
        $rate->save();
151
152
        $rate = new Intraface_modules_currency_Currency_ExchangeRate_ProductPrice;
153
        $rate->setRate(new Ilib_Variable_Float('745,23', 'da_dk'));
154
        $rate->setCurrency($currency);
155
        $rate->save();
156
157
        $gateway = new Intraface_modules_currency_Currency_Gateway(Doctrine_Manager::connection());
158
        $currency = $gateway->findById(1);
159
160
        $this->assertEquals(1, $currency->getProductPriceExchangeRate(1)->getId());
161
        $this->assertEquals(3, $currency->getProductPriceExchangeRate(3)->getId());
162
        try {
163
            $currency->getProductPriceExchangeRate(2);
164
            $this->assertTrue(false);
165
        } catch (Intraface_Gateway_Exception $e) {
166
            $this->assertTrue(true);
167
        }
168
    }
169
}
170