Issues (65)

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.

Tests/EncryptionResourceWrapperTest.php (8 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
/*
4
 * This file is part of the MesCryptoBundle package.
5
 *
6
 * (c) Francesco Cartenì <http://www.multimediaexperiencestudio.it/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Mes\Security\CryptoBundle\Tests;
13
14
use Defuse\Crypto\Exception\CryptoException as BaseCryptoException;
15
use Mes\Security\CryptoBundle\EncryptionWrapper;
16
use Mes\Security\CryptoBundle\Exception\CryptoException;
17
18
/**
19
 * Class EncryptionResourceWrapperTest.
20
 */
21
class EncryptionResourceWrapperTest extends \PHPUnit_Framework_TestCase
22
{
23
    /**
24
     * @var EncryptionWrapper
25
     */
26
    private $wrapper;
27
28
    /**
29
     * @var \PHPUnit_Framework_MockObject_MockObject
30
     */
31
    private $encryption;
32
33
    protected function setUp()
34
    {
35
        $this->encryption = $this->getMockBuilder('Mes\Security\CryptoBundle\EncryptionInterface')
36
                                 ->getMock();
37
        $this->wrapper = new EncryptionWrapper($this->encryption);
38
    }
39
40
    protected function tearDown()
41
    {
42
        $this->wrapper = null;
43
        $this->encryption = null;
44
    }
45
46
    /* ===========================================
47
     *
48
     * EncryptionInterface::EncryptResourceWithKey
49
     *
50
     * ===========================================
51
     */
52
53
    /**
54
     * @throws CryptoException
55
     */
56 View Code Duplication
    public function testEncryptResourceWithKeyEncryptsHandle()
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...
57
    {
58
        $this->encryption->expects($this->once())
59
                         ->method('encryptResourceWithKey');
60
61
        $this->wrapper->encryptResourceWithKey(fopen('php://stdin', 'r'), fopen('php://memory', 'wb'), $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
62
                                                                                                            ->getMock());
63
    }
64
65
    /**
66
     * @throws CryptoException
67
     */
68 View Code Duplication
    public function testDecryptResourceWithKeyDecryptsEncryptedHandle()
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...
69
    {
70
        $this->encryption->expects($this->once())
71
                         ->method('decryptResourceWithKey');
72
73
        $this->wrapper->decryptResourceWithKey(fopen('php://stdin', 'r'), fopen('php://memory', 'wb'), $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
74
                                                                                                            ->getMock());
75
    }
76
77
    /**
78
     * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException
79
     */
80 View Code Duplication
    public function testEncryptResourceWithKeyThrowsException()
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...
81
    {
82
        try {
83
            $this->encryption->expects($this->once())
84
                             ->method('encryptResourceWithKey')
85
                             ->will($this->throwException(new BaseCryptoException()));
86
        } catch (BaseCryptoException $e) {
87
            $this->throwException(new CryptoException());
88
        }
89
90
        $this->wrapper->encryptResourceWithKey(fopen('php://stdin', 'r'), fopen('php://memory', 'wb'), $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
91
                                                                                                            ->getMock());
92
    }
93
94
    /**
95
     * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException
96
     */
97 View Code Duplication
    public function testDecryptResourceWithKeyThrowsException()
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...
98
    {
99
        try {
100
            $this->encryption->expects($this->once())
101
                             ->method('decryptResourceWithKey')
102
                             ->will($this->throwException(new BaseCryptoException()));
103
        } catch (BaseCryptoException $e) {
104
            $this->throwException(new CryptoException());
105
        }
106
107
        $this->wrapper->decryptResourceWithKey(fopen('php://stdin', 'r'), fopen('php://memory', 'wb'), $this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')
108
                                                                                                            ->getMock());
109
    }
110
111
    /* ================================================
112
     *
113
     * EncryptionInterface::EncryptResourceWithPassword
114
     *
115
     * ================================================
116
     */
117
118
    /**
119
     * @throws CryptoException
120
     */
121 View Code Duplication
    public function testEncryptResourceWithPasswordEncryptsHandle()
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...
122
    {
123
        $this->encryption->expects($this->once())
124
                         ->method('encryptResourceWithPassword');
125
126
        $this->wrapper->encryptResourceWithPassword(fopen('php://stdin', 'r'), fopen('php://memory', 'wb'), 'SecretPa$$word');
127
    }
128
129
    /**
130
     * @throws CryptoException
131
     */
132 View Code Duplication
    public function testDecryptResourceWithPasswordDecryptsEncryptedHandle()
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...
133
    {
134
        $this->encryption->expects($this->once())
135
                         ->method('decryptResourceWithPassword');
136
137
        $this->wrapper->decryptResourceWithPassword(fopen('php://stdin', 'r'), fopen('php://memory', 'wb'), 'SecretPa$$word');
138
    }
139
140
    /**
141
     * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException
142
     */
143 View Code Duplication
    public function testEncryptResourceWithPasswordThrowsException()
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...
144
    {
145
        try {
146
            $this->encryption->expects($this->once())
147
                             ->method('encryptResourceWithPassword')
148
                             ->will($this->throwException(new BaseCryptoException()));
149
        } catch (BaseCryptoException $e) {
150
            $this->throwException(new CryptoException());
151
        }
152
153
        $this->wrapper->encryptResourceWithPassword(fopen('php://stdin', 'r'), fopen('php://memory', 'wb'), 'SecretPa$$word');
154
    }
155
156
    /**
157
     * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException
158
     */
159 View Code Duplication
    public function testDecryptResourceWithPasswordThrowsException()
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...
160
    {
161
        try {
162
            $this->encryption->expects($this->once())
163
                             ->method('decryptResourceWithPassword')
164
                             ->will($this->throwException(new BaseCryptoException()));
165
        } catch (BaseCryptoException $e) {
166
            $this->throwException(new CryptoException());
167
        }
168
169
        $this->wrapper->decryptResourceWithPassword(fopen('php://stdin', 'r'), fopen('php://memory', 'wb'), 'SecretPa$$word');
170
    }
171
}
172