Issues (90)

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/Receiver.php (3 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
 * Receiver Class Doc Comment
4
 *
5
 * PHP version 5
6
 *
7
 * @category PHP
8
 * @package  OpenChat
9
 * @author   Ankit Jain <[email protected]>
10
 * @license  The MIT License (MIT)
11
 * @link     https://github.com/ankitjain28may/openchat
12
 */
13
namespace ChatApp;
14
15
require_once dirname(__DIR__).'/vendor/autoload.php';
16
use ChatApp\User;
17
use ChatApp\Conversation;
18
use mysqli;
19
use Dotenv\Dotenv;
20
$dotenv = new Dotenv(dirname(__DIR__));
21
$dotenv->load();
22
23
/**
24
 * Send message to other user
25
 *
26
 * @category PHP
27
 * @package  OpenChat
28
 * @author   Ankit Jain <[email protected]>
29
 * @license  The MIT License (MIT)
30
 * @link     https://github.com/ankitjain28may/openchat
31
 */
32
class Receiver
33
{
34
    /*
35
    |--------------------------------------------------------------------------
36
    | Receiver Class
37
    |--------------------------------------------------------------------------
38
    |
39
    | Send message to other user.
40
    |
41
    */
42
43
    protected $obUser;
44
    protected $conversation;
45
    protected $messages;
46
47
    /**
48
     * Create a new class instance.
49
     *
50
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
51
     */
52
    public function __construct()
53
    {
54
        $this->obUser = new User();
55
        $this->conversation = new Conversation();
56
    }
57
58
    /**
59
     * Swaping value of conversation class to modify them for receiver
60
     *
61
     * @param string  $msg  To store message
62
     * @param boolean $para To store True/False
63
     *
64
     * @return string
65
     */
66
    public function receiverLoad($msg, $para)
67
    {
68
        $msg = json_decode($msg);
69
        $id2 = $msg->userId;
70
        $this->messages = $this->obUser->userDetails($id2, $para);
0 ignored issues
show
$para is of type boolean, but the function expects a object<ChatApp\boollen>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
71
        $username = $this->messages['username'];
72
        $name = $this->messages['name'];
73
        $id1 = $msg->details;
74
        $msg->details = bin2hex(convert_uuencode($msg->details));
75
        $msg = json_encode($msg);
76
        $this->messages = json_decode(
77
            $this->conversation->conversationLoad($msg, $para)
78
        );
79
        // $id1 = json_decode($msg)->details;
80
        for ($i = 1; $i < count($this->messages); $i++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
81
            $this->messages[$i]->start = $id1;
82
        }
83
        $id2 = bin2hex(convert_uuencode($id2));
84
85
        $this->messages[0]->username = $username;
86
        $this->messages[0]->name = $name;
87
        $this->messages[0]->id = $id2;
88
        return json_encode($this->messages);
89
    }
90
}
91