Issues (43)

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.

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 florinp\messenger;
4
5
6
class ext extends \phpbb\extension\base
7
{
8
9
    public function enable_step($old_state)
10
    {
11
        global $phpbb_root_path;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
12
13
        switch ($old_state) {
14
            case '':
15
                $db = new \florinp\messenger\libs\database();
16
                $db->exec("
17
          CREATE TABLE IF NOT EXISTS messages (
18
            `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
19
            `sender_id` INTEGER NOT NULL,
20
            `receiver_id` INTEGER NOT NULL,
21
            `text` TEXT NOT NULL,
22
            `newMsg` INTEGER DEFAULT 0,
23
            `sentAt` INTEGER NOT NULL
24
          );
25
          CREATE TABLE IF NOT EXISTS files (
26
            `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
27
            `sender_id` INTEGER NOT NULL,
28
            `receiver_id` INTEGER NOT NULL,
29
            `fileName` VARCHAR(255) NOT NULL,
30
            `file` VARCHAR(255) NOT NULL,
31
            `type` VARCHAR(255) NOT NULL,
32
            `sentAt` INTEGER NOT NULL
33
          );
34
        ");
35
36
                $messengerDir = $phpbb_root_path . 'store/messenger';
37
                if (!is_dir($messengerDir)) {
38
                    mkdir($messengerDir, 0777);
39
                    $filesDir = $messengerDir . '/files';
40
                    if (!is_dir($filesDir)) {
41
                        mkdir($filesDir, 0777);
42
                    }
43
                }
44
                return 'notifications';
45
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
46
47
            case 'notifications':
48
                $phpbb_notifications = $this->container->get('notification_manager');
49
                $phpbb_notifications->enable_notifications('florinp.messenger.notification.type.friend_request');
50
                return 'step2';
51
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
52
53
            default:
54
                return parent::enable_step($old_state);
55
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
56
        }
57
58
    }
59
60
    public function disable_step($old_state)
61
    {
62
        switch ($old_state) {
63
            case '':
64
                $phpbb_notifications = $this->container->get('notification_manager');
65
                $phpbb_notifications->disable_notifications('florinp.messenger.notification.type.friend_request');
66
                return 'notifications';
67
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
68
69
            default:
0 ignored issues
show
The default body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a default statement must start on the line immediately following the statement.

switch ($expr) {
    default:
        doSomething(); //right
        break;
}


switch ($expr) {
    default:

        doSomething(); //wrong
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
70
71
                return parent::disable_step($old_state);
72
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
73
        }
74
    }
75
76
    public function purge_step($old_state)
77
    {
78
        global $phpbb_root_path;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
79
80
        $database = $phpbb_root_path . 'store/messenger.db';
81
        if (is_file($database)) {
82
            unlink($database);
83
        }
84
85
        $messengerDir = $phpbb_root_path . 'store/messenger';
86
        if (is_dir($messengerDir)) {
87
            $objects = scandir($messengerDir);
88
            foreach ($objects as $object) {
89
                if ($object != '.' && $object != '..') {
90
                    if (filetype($messengerDir . "/" . $object) == "dir") {
91
                        $dir = $messengerDir . "/" . $object;
92
                        $subObjects = scandir($dir);
93
                        if(count($subObjects) > 0) {
94
                            foreach($subObjects as $subObject) {
95
                                if($subObject != '.' && $subObject != '..') {
96
                                    if(filetype($dir . '/' . $subObject) != 'dir') {
97
                                        unlink($dir . '/' . $subObject);
98
                                    }
99
                                } else {
100
                                    continue;
101
                                }
102
                            }
103
104
                        }
105
                        rmdir($messengerDir . "/" . $object);
106
                    } else {
107
                        unlink($messengerDir . "/" . $object);
108
                    }
109
                }
110
            }
111
            reset($objects);
112
            rmdir($messengerDir);
113
        }
114
115
        return parent::purge_step($old_state);
116
117
    }
118
119
}
120