Issues (94)

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/Localization/Button.php (6 issues)

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
/*
4
 * This file is part of the PhpBotFramework.
5
 *
6
 * PhpBotFramework is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as
8
 * published by the Free Software Foundation, version 3.
9
 *
10
 * PhpBotFramework is distributed in the hope that it will be useful, but
11
 * WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public License
16
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
namespace PhpBotFramework\Localization;
20
21
use PhpBotFramework\Core\CoreBot;
22
use PhpBotFramework\Entities\InlineKeyboard;
23
24
/** \class Button Button Inline keyboard with localizated buttons. */
25
class Button extends InlineKeyboard
26
{
27
    /**
28
     * \addtogroup InlineKeyboard InlineKeyboard
29
     * \brief Handle an inline keyboard to send along with messages.
30
     * @{
31
     */
32
33
    /** \brief Stores a reference to the bot that's using the inline keyboard. */
34
    protected $bot;
35
36
    /**
37
     * \brief Create an inline keyboard object with localizated buttons.
38
     * @param CoreBot $bot References to the bot that's using the inline keyboard.
39
     * @param array $buttons Buttons passed as inizialization.
40
     */
41 1
    public function __construct(CoreBot &$bot, array $buttons = array())
42
    {
43 1
        $this->bot = $bot;
44
45
        // Call parent constructor passing array
46 1
        parent::__construct($buttons);
47 1
    }
48
49
50
    /**
51
     * \brief Get a simple Back button with back as <code>callback_data</code>.
52
     * @param $json_serialized return a json serialized string, or an array.
53
     * @return string|array A button with written "back".
54
     */
55
    public function getBackButton(bool $json_serialized = true)
56
    {
57
        // Create the button
58
        $inline_keyboard = [ 'inline_keyboard' =>
59
            [
60
                [
61
                    [
62
                        'text' => $this->bot->local[$this->bot->language]['Back_Button'],
0 ignored issues
show
The property local does not seem to exist in PhpBotFramework\Core\CoreBot.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
The property language does not seem to exist in PhpBotFramework\Core\CoreBot.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
63
                        'callback_data' => 'back'
64
                    ]
65
                ]
66
            ]
67
        ];
68
69
        // Serialize everything as JSON if necessary
70
        if ($json_serialized) {
71
            return json_encode($inline_keyboard);
72
        } else {
73
            return $inline_keyboard;
74
        }
75
    }
76
77
    /**
78
     * \brief Get a Back and a Skip buttons inthe same row.
79
     * \details Back button has callback_data "back" and Skip button has callback_data "skip".
80
     * @param bool $json_serialized return a json serialized string, or an array.
81
     * @return string|array A button with written "back" and one with written "Skip".
82
     */
83
    public function getBackSkipKeyboard(bool $json_serialized = true)
84
    {
85
        // Create the keyboard
86
        $inline_keyboard = [ 'inline_keyboard' =>
87
            [
88
                [
89
                    [
90
                        'text' => $this->bot->local[$this->bot->language]['Back_Button'],
0 ignored issues
show
The property local does not seem to exist in PhpBotFramework\Core\CoreBot.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
The property language does not seem to exist in PhpBotFramework\Core\CoreBot.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
91
                        'callback_data' => 'back'
92
                    ],
93
                    [
94
                        'text' => $this->bot->local[$this->bot->language]['Skip_Button'],
95
                        'callback_data' => 'skip'
96
                    ]
97
                ]
98
            ]
99
        ];
100
101
        if ($json_serialized) {
102
            return json_encode($inline_keyboard);
103
        } else {
104
            return $inline_keyboard;
105
        }
106
    }
107
108
    /**
109
     * \brief Get various buttons for set various languages.
110
     * \details Create a button for each language contained in <code>$localization['languages']</code> variable of $bot object.
111
     * There will be a button per row.
112
     *
113
     * The button's label will include the target language and the current one.
114
     * The callback data for each button will be "cl/key" where key is the key in <code>$localization['languages']</code>.
115
     * @param $prefix Prefix followed by '/' and the language index (en, it..).
116
     * @param $json_serialized Get a JSON-serialized string or an array.
117
     * @return string|array The buttons in the selected type.
118
     */
119
    public function getChooseLanguageKeyboard(string $prefix = 'cl', bool $json_serialized = true)
120
    {
121
        $inline_keyboard = ['inline_keyboard' => array()];
122
123
        foreach ($this->bot->local as $languages => $language_msg) {
124
            // If the language is the same as the one set for the current user in $bot
125
            if (strpos($languages, $this->bot->language) !== false) {
126
                // Just create a button with one language in it
127
                array_push($inline_keyboard['inline_keyboard'], [
128
                    [
129
                        'text' => $language_msg['Language'],
130
                        'callback_data' => 'same/language'
131
                    ]
132
                ]);
133
            } else {
134
                array_push($inline_keyboard['inline_keyboard'], [
135
                        [
136
                            'text' => $language_msg['Language'] . '/' . $this->bot->local[$this->bot->language][$languages],
0 ignored issues
show
The property local does not seem to exist in PhpBotFramework\Core\CoreBot.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
The property language does not seem to exist in PhpBotFramework\Core\CoreBot.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
137
                            'callback_data' => $prefix . '/' . $languages
138
                        ]
139
                ]);
140
            }
141
        }
142
143
        // Unset the variables from the foreach
144
        unset($languages);
145
        unset($language_msg);
146
147
        array_push($inline_keyboard['inline_keyboard'], [
148
                [
149
                    'text' => $this->bot->local[$this->bot->language]['Back_Button'],
150
                    'callback_data' => 'back'
151
                ]
152
        ]);
153
154
        if ($json_serialized) {
155
            return json_encode($inline_keyboard);
156
        } else {
157
            return $inline_keyboard;
158
        }
159
    }
160
161
    /** @} */
162
}
163