This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 Defuse\Crypto\Exception\EnvironmentIsBrokenException; |
||
16 | use Mes\Security\CryptoBundle\Exception\CryptoException; |
||
17 | use Mes\Security\CryptoBundle\KeyManagerInterface; |
||
18 | use Mes\Security\CryptoBundle\KeyManagerWrapper; |
||
19 | use Mes\Security\CryptoBundle\Model\KeySecretAwareInterface; |
||
20 | |||
21 | /** |
||
22 | * Class KeyManagerWrapperTest. |
||
23 | */ |
||
24 | class KeyManagerWrapperTest extends \PHPUnit_Framework_TestCase |
||
25 | { |
||
26 | /** |
||
27 | * @var KeyManagerInterface|KeySecretAwareInterface |
||
28 | */ |
||
29 | private $wrapper; |
||
30 | |||
31 | /** |
||
32 | * @var \PHPUnit_Framework_MockObject_MockObject |
||
33 | */ |
||
34 | private $keyManager; |
||
35 | |||
36 | protected function setUp() |
||
37 | { |
||
38 | $this->keyManager = $this->getMockBuilder('\Mes\Security\CryptoBundle\KeyManagerInterface') |
||
39 | ->getMock(); |
||
40 | $this->wrapper = new KeyManagerWrapper($this->keyManager); |
||
41 | } |
||
42 | |||
43 | protected function tearDown() |
||
44 | { |
||
45 | $this->wrapper = null; |
||
46 | } |
||
47 | |||
48 | View Code Duplication | public function testGenerateCreatesKey() |
|
49 | { |
||
50 | $this->keyManager->expects($this->once()) |
||
51 | ->method('generate') |
||
52 | ->with(null) |
||
53 | ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())); |
||
54 | |||
55 | $key = $this->wrapper->generate(); |
||
0 ignored issues
–
show
|
|||
56 | |||
57 | $this->assertInstanceOf('Mes\Security\CryptoBundle\Model\KeyInterface', $key); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |
||
62 | */ |
||
63 | public function testGenerateThrowsException() |
||
64 | { |
||
65 | try { |
||
66 | $this->keyManager->expects($this->once()) |
||
67 | ->method('generate') |
||
68 | ->with(null) |
||
69 | ->will($this->throwException(new EnvironmentIsBrokenException())); |
||
70 | } catch (EnvironmentIsBrokenException $ex) { |
||
71 | $this->throwException(new CryptoException()); |
||
72 | } |
||
73 | |||
74 | $this->wrapper->generate(); |
||
0 ignored issues
–
show
The method
generate does only exist in Mes\Security\CryptoBundle\KeyManagerInterface , but not in Mes\Security\CryptoBundl...KeySecretAwareInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
75 | } |
||
76 | |||
77 | View Code Duplication | public function testGenerateFromAsciiCreatesKeyFromAscii() |
|
78 | { |
||
79 | $key_encoded = 'key_encoded'; |
||
80 | $secret = 'ThisIsASecretPassword'; |
||
81 | |||
82 | $this->keyManager->expects($this->once()) |
||
83 | ->method('generateFromAscii') |
||
84 | ->with($key_encoded, $secret) |
||
85 | ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())); |
||
86 | |||
87 | $key = $this->wrapper->generateFromAscii($key_encoded, $secret); |
||
0 ignored issues
–
show
The method
generateFromAscii does only exist in Mes\Security\CryptoBundle\KeyManagerInterface , but not in Mes\Security\CryptoBundl...KeySecretAwareInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
88 | |||
89 | $this->assertInstanceOf('Mes\Security\CryptoBundle\Model\KeyInterface', $key); |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * @expectedException \Mes\Security\CryptoBundle\Exception\CryptoException |
||
94 | */ |
||
95 | public function testGenerateFromAsciiThrowsException() |
||
96 | { |
||
97 | $key_encoded = 'key_encoded'; |
||
98 | $secret = 'ThisIsASecretPassword'; |
||
99 | |||
100 | try { |
||
101 | $this->keyManager->expects($this->once()) |
||
102 | ->method('generateFromAscii') |
||
103 | ->with($key_encoded, $secret) |
||
104 | ->will($this->throwException(new BaseCryptoException())); |
||
105 | } catch (CryptoException $ex) { |
||
106 | $this->throwException(new CryptoException()); |
||
107 | } |
||
108 | |||
109 | $this->wrapper->generateFromAscii($key_encoded, $secret); |
||
0 ignored issues
–
show
The method
generateFromAscii does only exist in Mes\Security\CryptoBundle\KeyManagerInterface , but not in Mes\Security\CryptoBundl...KeySecretAwareInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
110 | } |
||
111 | |||
112 | View Code Duplication | public function testGetKeyReadsKey() |
|
113 | { |
||
114 | $this->keyManager->expects($this->once()) |
||
115 | ->method('getKey') |
||
116 | ->will($this->returnValue($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock())); |
||
117 | |||
118 | $key = $this->wrapper->getKey(); |
||
0 ignored issues
–
show
The method
getKey does only exist in Mes\Security\CryptoBundle\KeyManagerInterface , but not in Mes\Security\CryptoBundl...KeySecretAwareInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
119 | |||
120 | $this->assertInstanceOf('Mes\Security\CryptoBundle\Model\KeyInterface', $key); |
||
121 | } |
||
122 | |||
123 | public function testSetKeyStoresKey() |
||
124 | { |
||
125 | $this->keyManager->expects($this->once()) |
||
126 | ->method('setKey') |
||
127 | ->with($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()); |
||
128 | |||
129 | $this->wrapper->setKey($this->getMockBuilder('Mes\Security\CryptoBundle\Model\KeyInterface')->getMock()); |
||
0 ignored issues
–
show
The method
setKey does only exist in Mes\Security\CryptoBundle\KeyManagerInterface , but not in Mes\Security\CryptoBundl...KeySecretAwareInterface .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
130 | } |
||
131 | |||
132 | public function testSetSecretStoresSecret() |
||
133 | { |
||
134 | $this->keyManager->expects($this->once()) |
||
135 | ->method('setSecret') |
||
136 | ->with('ThisIsASecret'); |
||
137 | |||
138 | $this->wrapper->setSecret('ThisIsASecret'); |
||
139 | } |
||
140 | |||
141 | public function testGetSecretReadsSecret() |
||
142 | { |
||
143 | $this->keyManager->expects($this->once()) |
||
144 | ->method('getSecret') |
||
145 | ->will($this->returnValue('ThisIsYourSecret')); |
||
146 | |||
147 | $secret = $this->wrapper->getSecret(); |
||
148 | |||
149 | $this->assertSame('ThisIsYourSecret', $secret); |
||
150 | } |
||
151 | } |
||
152 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: