Issues (180)

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/BasicEntityRelationsTest.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
namespace Fwk\Db;
4
5
class User extends \stdClass
6
{
7
    public $emails;
8
9
    public $metas;
10
11
    public $phone;
12
13
    public function __construct()
14
    {
15
        $this->emails = new Relations\Many2Many(
16
                'id',
17
                'user_id',
18
                'fwkdb_test_emails',
19
                'fwkdb_test_users_emails',
20
                'id',
21
                'email_id',
22
                'Fwk\Db\Email'
23
        );
24
25
        $this->metas = new Relations\One2Many(
26
                'id',
27
                'user_id',
28
                'fwkdb_test_users_metas'
29
        );
30
        $this->metas->setReference('name');
31
32
        $this->phone = new Relations\One2One('phone_id', 'id', 'fwkdb_test_phones');
33
    }
34
}
35
36
class Email extends \stdClass
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
37
{
38
}
39
40
/**
41
 * Test class for Accessor.
42
 * Generated by PHPUnit on 2012-05-27 at 17:46:42.
43
 */
44
class BasicEntityRelationsTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
45
{
46
    /**
47
     *
48
     * @var \Fwk\Db\Connection
49
     */
50
    protected $connection;
51
52
    /**
53
     * Sets up the fixture, for example, opens a network connection.
54
     * This method is called before a test is executed.
55
     */
56
    protected function setUp()
57
    {
58
        $this->connection = new Connection(array(
59
            'memory'    => true,
60
            'driver'    => 'pdo_sqlite'
61
        ));
62
63
        \FwkDbTestUtil::createTestDb($this->connection);
64
    }
65
66
    protected function tearDown()
67
    {
68
        \FwkDbTestUtil::dropTestDb($this->connection);
69
    }
70
71
    public function testM2MSave()
72
    {
73
        $u = new User;
74
        $u->username = "joebar";
75
76
        $e = new Email();
77
        $e->email = "[email protected]";
78
        $e->verified = 1;
79
80
        $this->assertEquals(0, count($this->connection->table('fwkdb_test_users')->finder()->all()));
81
        $this->assertEquals(0, count($this->connection->table('fwkdb_test_emails')->finder()->all()));
82
83
        $u->emails[] = $e;
84
        $this->connection->table('fwkdb_test_users')->save($u);
85
86
        $this->assertEquals(1, count($this->connection->table('fwkdb_test_users')->finder()->all()));
87
        $this->assertEquals(1, count($this->connection->table('fwkdb_test_emails')->finder()->all()));
88
        $this->assertEquals(1, count($this->connection->table('fwkdb_test_users_emails')->finder()->all()));
89
    }
90
91
    public function testM2MRemoveChild()
92
    {
93
        $u = new User;
94
        $u->username = "joebar";
95
96
        $e = new Email();
97
        $e->email = "[email protected]";
98
        $e->verified = 1;
99
100
        $u->emails[] = $e;
101
        $this->connection->table('fwkdb_test_users')->save($u);
102
103
        $user = $this->connection->table('fwkdb_test_users')->finder('Fwk\Db\User')->one(1);
104
        $this->assertNotNull($user);
105
        $this->assertInstanceOf('\Fwk\Db\Email', $user->emails[0]);
106
107
        unset($user->emails[0]);
108
        $this->connection->table('fwkdb_test_users')->save($user);
109
110
        $this->assertNull($user->emails[0]);
111
        $this->assertEquals(1, count($this->connection->table('fwkdb_test_emails')->finder()->all()));
112
        $this->assertEquals(0, count($this->connection->table('fwkdb_test_users_emails')->finder()->all()));
113
    }
114
115
    public function testO2MSave()
116
    {
117
        $u = new User;
118
        $u->username = "joebar";
119
120
        $m = new \stdClass;
121
        $m->name = "param";
122
        $m->value = "value";
123
124
        $u->metas[] = $m;
125
126
        $this->assertEquals($m, $u->metas['param']); // test the reference
127
        $this->assertEquals(0, count($this->connection->table('fwkdb_test_users')->finder()->all()));
128
        $this->assertEquals(0, count($this->connection->table('fwkdb_test_users_metas')->finder()->all()));
129
130
        $this->connection->table('fwkdb_test_users')->save($u);
131
132
        $this->assertEquals(1, count($this->connection->table('fwkdb_test_users')->finder()->all()));
133
        $this->assertEquals(1, count($this->connection->table('fwkdb_test_users_metas')->finder()->all()));
134
        $this->assertEquals($u->id, $u->metas['param']->user_id);
135
    }
136
137
    public function testO2MRemoveChild()
138
    {
139
        $u = new User;
140
        $u->username = "joebar";
141
142
        $m = new \stdClass;
143
        $m->name = "param";
144
        $m->value = "value";
145
146
        $u->metas[] = $m;
147
        $this->connection->table('fwkdb_test_users')->save($u);
148
149
        $user = $this->connection->table('fwkdb_test_users')->finder('Fwk\Db\User')->one(1);
150
        $this->assertNotNull($user);
151
        $this->assertInstanceOf('\stdClass', $user->metas['param']);
152
153
        unset($user->metas['param']);
154
        $this->connection->table('fwkdb_test_users')->save($user);
155
156
        $this->assertEquals(1, count($this->connection->table('fwkdb_test_users')->finder()->all()));
157
        $this->assertEquals(0, count($this->connection->table('fwkdb_test_users_metas')->finder()->all()));
158
        $this->assertNull($user->metas['param']);
159
    }
160
161
    public function testO2OSave()
162
    {
163
        $u = new User;
164
        $u->username = "joebar";
165
166
        $m = new \stdClass;
167
        $m->number = "0467010506";
168
169
        $u->phone->set($m);
170
171
        $this->assertEquals(0, count($this->connection->table('fwkdb_test_users')->finder()->all()));
172
        $this->assertEquals(0, count($this->connection->table('fwkdb_test_phones')->finder()->all()));
173
174
        $this->connection->table('fwkdb_test_users')->save($u);
175
176
        $this->assertEquals(1, count($this->connection->table('fwkdb_test_users')->finder()->all()));
177
        $this->assertEquals(1, count($this->connection->table('fwkdb_test_phones')->finder()->all()));
178
        $this->assertEquals($m->id, $u->phone_id);
179
    }
180
181
    public function testO2ORemoveChild()
182
    {
183
        $u = new User;
184
        $u->username = "joebar";
185
186
        $m = new \stdClass;
187
        $m->number = "0467010506";
188
189
        $u->phone->set($m);
190
191
        $this->connection->table('fwkdb_test_users')->save($u);
192
193
        $user = $this->connection->table('fwkdb_test_users')->finder('Fwk\Db\User')->one(1);
194
        $this->assertNotNull($user);
195
        $this->assertInstanceOf('\stdClass', $user->phone->get());
196
197
        $user->phone->set();
198
        $this->connection->table('fwkdb_test_users')->save($user);
199
200
        $this->assertEquals(1, count($this->connection->table('fwkdb_test_users')->finder()->all()));
201
        $this->assertEquals(1, count($this->connection->table('fwkdb_test_phones')->finder()->all()));
202
        $this->assertNull($user->phone_id);
203
    }
204
}
205