Issues (273)

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/Migration/AbstractMigration.php (1 issue)

Labels
Severity

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
 * This file contains functionality relating to database migrations
4
 *
5
 * @license    https://github.com/allejo/bzion/blob/master/LICENSE.md GNU General Public License Version 3
6
 */
7
8
namespace BZIon\Migration;
9
10
use Phinx\Db\Table;
11
use Phinx\Migration\AbstractMigration as BaseMigration;
12
13
/**
14
 * An abstract database migration
15
 */
16
class AbstractMigration extends BaseMigration
17
{
18
    /**
19
     * Edit the serialized data of a conversation event
20
     *
21
     * @param string   $typeQuery The MySQL string for the event type
22
     * @param \Closure $callback  The callback function to edit the event. The
23
     *                            1st parameter should be the data array, while
24
     *                            the 2nd can be the name of the class. Both
25
     *                            parameters can be passed by reference and
26
     *                            altered. The return value can be the desired
27
     *                            BZIon\Migration\EditAction or null.
28
     */
29 1
    protected function editGroupEvent($typeQuery, $callback)
30
    {
31 1
        return $this->editSerializedData(
32 1
            "group_events",
33 1
            "event",
34 1
            "WHERE `type` = '$typeQuery'",
35 1
            $callback
36
        );
37
    }
38
39
    /**
40
     * Edit the serialized data of a conversation event
41
     *
42
     * @param string   $table      The name of the table to edit
43
     * @param string   $column     The name of the column to edit
44
     * @param string   $extraQuery An extra MySQL string for the query
45
     * @param \Closure $callback   The callback function to edit the event. The
46
     *                             1st parameter should be the data array, while
47
     *                             the 2nd can be the name of the class. Both
48
     *                             parameters can be passed by reference and
49
     *                             altered. The return value can be the desired
50
     *                             BZIon\Migration\EditAction or null.
51
     */
52 1
    protected function editSerializedData($table, $column, $extraQuery, $callback)
53
    {
54 1
        if ($table instanceof Table) {
55
            $table = $table->getName();
56
        }
57
58 1
        $query = "SELECT id, `$column` FROM $table $extraQuery";
59 1
        $rows = $this->fetchAll($query);
60
61 1
        foreach ($rows as $row) {
62
            list($class, $array) = $this->unserializeClass($row[$column]);
63
64
            $action = $callback($array, $class);
65
66
            if (!$action instanceof EditAction) {
67
                $data = $this->serializeClass($class, $array);
68
                $action = new Update($data);
69
            }
70
71
            $pdo = $this->getAdapter()->getConnection();
0 ignored issues
show
The method getConnection() does not exist on Phinx\Db\Adapter\AdapterInterface. Did you maybe mean connect()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
72
            $action->perform($pdo, $table, $column, $row['id']);
73
        }
74 1
    }
75
76
    /**
77
     * Given a serialized PHP class, unserialize it to its components
78
     *
79
     * @param  string $serialized The serialized class
80
     * @return array  An array containing the full name of the class and an
81
     *                array of its data
82
     */
83
    private function unserializeClass($serialized)
84
    {
85
        $matches = array();
86
        preg_match('/^C:\d+:"(.+)":\d+:{(.*)}$/', $serialized, $matches);
87
88
        $class = $matches[1];
89
        $array = unserialize($matches[2]);
90
91
        return array($class, $array);
92
    }
93
94
    /**
95
     * Serialize a PHP class given its name and data
96
     *
97
     * @param  string $class The full name of the class
98
     * @param  array  $array The data of the class
99
     * @return string The serialized class
100
     */
101
    private function serializeClass($class, $array)
102
    {
103
        $serialized = serialize($array);
104
105
        return sprintf('C:%d:"%s":%d:{%s}',
106
            strlen($class),
107
            $class,
108
            strlen($serialized),
109
            $serialized
110
        );
111
    }
112
}
113