Issues (64)

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.

src/Commands/AdminCommands/DebugCommand.php (1 issue)

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 is part of the TelegramBot package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\TelegramBot\Commands\AdminCommands;
12
13
use Longman\TelegramBot\Commands\AdminCommand;
14
use Longman\TelegramBot\DB;
15
use Longman\TelegramBot\Request;
16
17
/**
18
 * Admin "/debug" command
19
 */
20
class DebugCommand extends AdminCommand
21
{
22
    /**
23
     * @var string
24
     */
25
    protected $name = 'debug';
26
27
    /**
28
     * @var string
29
     */
30
    protected $description = 'Debug command to help find issues';
31
32
    /**
33
     * @var string
34
     */
35
    protected $usage = '/debug';
36
37
    /**
38
     * @var string
39
     */
40
    protected $version = '1.1.0';
41
42
    /**
43
     * Command execute method
44
     *
45
     * @return mixed
46
     * @throws \Longman\TelegramBot\Exception\TelegramException
47
     */
48
    public function execute()
0 ignored issues
show
execute uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
49
    {
50
        $pdo = DB::getPdo();
51
        $message = $this->getMessage();
52
        $chat = $message->getChat();
53
        $text = strtolower($message->getText(true));
54
55
        $data = ['chat_id' => $chat->getId()];
56
57
        if ($text !== 'glasnost' && !$chat->isPrivateChat()) {
58
            $data['text'] = 'Only available in a private chat.';
59
60
            return Request::sendMessage($data);
61
        }
62
63
        $debug_info = [];
64
65
        $debug_info[] = sprintf('*TelegramBot version:* `%s`', $this->telegram->getVersion());
66
        $debug_info[] = sprintf('*Download path:* `%s`', $this->telegram->getDownloadPath());
67
        $debug_info[] = sprintf('*Upload path:* `%s`', $this->telegram->getUploadPath());
68
69
        // Commands paths.
70
        $debug_info[] = '*Commands paths:*';
71
        $debug_info[] = sprintf(
72
            '```' . PHP_EOL . '%s```',
73
            json_encode($this->telegram->getCommandsPaths(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
74
        );
75
76
        $php_bit = '';
77
        PHP_INT_SIZE === 4 && $php_bit = ' (32bit)';
78
        PHP_INT_SIZE === 8 && $php_bit = ' (64bit)';
79
        $debug_info[] = sprintf('*PHP version:* `%1$s%2$s; %3$s; %4$s`', PHP_VERSION, $php_bit, PHP_SAPI, PHP_OS);
80
        $debug_info[] = sprintf('*Maximum PHP script execution time:* `%d seconds`', ini_get('max_execution_time'));
81
82
        $mysql_version = $pdo ? $pdo->query('SELECT VERSION() AS version')->fetchColumn() : null;
83
        $debug_info[] = sprintf('*MySQL version:* `%s`', $mysql_version ?: 'disabled');
84
85
        $debug_info[] = sprintf('*Operating System:* `%s`', php_uname());
86
87
        if (isset($_SERVER['SERVER_SOFTWARE'])) {
88
            $debug_info[] = sprintf('*Web Server:* `%s`', $_SERVER['SERVER_SOFTWARE']);
89
        }
90
        if (function_exists('curl_init')) {
91
            $curlversion = curl_version();
92
            $debug_info[] = sprintf('*curl version:* `%1$s; %2$s`', $curlversion['version'], $curlversion['ssl_version']);
93
        }
94
95
        $webhook_info_title = '*Webhook Info:*';
96
        try {
97
            // Check if we're actually using the Webhook method.
98
            if (Request::getInput() === '') {
99
                $debug_info[] = $webhook_info_title . ' `Using getUpdates method, not Webhook.`';
100
            } else {
101
                $webhook_info_result = json_encode(json_decode(Request::getWebhookInfo(), true)['result'], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
102
                $debug_info[] = $webhook_info_title;
103
                $debug_info[] = sprintf(
104
                    '```' . PHP_EOL . '%s```',
105
                    $webhook_info_result
106
                );
107
            }
108
        } catch (\Exception $e) {
109
            $debug_info[] = $webhook_info_title . sprintf(' `Failed to get webhook info! (%s)`', $e->getMessage());
110
        }
111
112
        $data['parse_mode'] = 'Markdown';
113
        $data['text'] = implode(PHP_EOL, $debug_info);
114
115
        return Request::sendMessage($data);
116
    }
117
}
118