Issues (112)

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.

classes/external.php (1 issue)

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
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
17
/**
18
 * BigBlueButtonBN external API
19
 *
20
 * @package   mod_bigbluebuttonbn
21
 * @category  external
22
 * @copyright 2018 onwards, Blindside Networks Inc
23
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
26
defined('MOODLE_INTERNAL') || die;
27
28
require_once("$CFG->libdir/externallib.php");
29
30
/**
31
 * BigBlueButtonBN external functions
32
 *
33
 * @package   mod_bigbluebuttonbn
34
 * @category  external
35
 * @copyright 2018 onwards, Blindside Networks Inc
36
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37
 */
38
class mod_bigbluebuttonbn_external extends external_api {
39
40
    /**
41
     * Returns description of method parameters
42
     *
43
     * @return external_function_parameters
44
     * @since Moodle 3.0
45
     */
46
    public static function view_bigbluebuttonbn_parameters() {
47
        return new external_function_parameters(
48
            array(
49
                'bigbluebuttonbnid' => new external_value(PARAM_INT, 'bigbluebuttonbn instance id')
50
            )
51
        );
52
    }
53
54
    /**
55
     * Trigger the course module viewed event and update the module completion status.
56
     *
57
     * @param int $bigbluebuttonbnid the bigbluebuttonbn instance id
58
     * @return array of warnings and status result
59
     * @since Moodle 3.0
60
     * @throws moodle_exception
61
     */
62
    public static function view_bigbluebuttonbn($bigbluebuttonbnid) {
63
        global $DB, $CFG;
64
        require_once($CFG->dirroot . "/mod/bigbluebuttonbn/lib.php");
65
66
        $params = self::validate_parameters(self::view_bigbluebuttonbn_parameters(),
67
                                            array(
68
                                                'bigbluebuttonbnid' => $bigbluebuttonbnid
69
                                            ));
70
        $warnings = array();
71
72
        // Request and permission validation.
73
        $bigbluebuttonbn = $DB->get_record('bigbluebuttonbn', array('id' => $params['bigbluebuttonbnid']), '*', MUST_EXIST);
74
        list($course, $cm) = get_course_and_cm_from_instance($bigbluebuttonbn, 'bigbluebuttonbn');
75
76
        $context = context_module::instance($cm->id);
77
        self::validate_context($context);
78
79
        require_capability('mod/bigbluebuttonbn:view', $context);
80
81
        // Call the bigbluebuttonbn/lib API.
82
        bigbluebuttonbn_view($bigbluebuttonbn, $course, $cm, $context);
83
84
        $result = array();
85
        $result['status'] = true;
86
        $result['warnings'] = $warnings;
87
        return $result;
88
    }
89
90
    /**
91
     * Returns description of method result value
92
     *
93
     * @return external_description
94
     * @since Moodle 3.0
95
     */
96
    public static function view_bigbluebuttonbn_returns() {
97
        return new external_single_structure(
98
            array(
99
                'status' => new external_value(PARAM_BOOL, 'status: true if success'),
100
                'warnings' => new external_warnings()
101
            )
102
        );
103
    }
104
105
    /**
106
     * Describes the parameters for get_bigbluebuttonbns_by_courses.
107
     *
108
     * @return external_function_parameters
109
     * @since Moodle 3.3
110
     */
111
    public static function get_bigbluebuttonbns_by_courses_parameters() {
112
        return new external_function_parameters (
113
            array(
114
                'courseids' => new external_multiple_structure(
115
                    new external_value(PARAM_INT, 'Course id'), 'Array of course ids', VALUE_DEFAULT, array()
116
                ),
117
            )
118
        );
119
    }
120
121
    /**
122
     * Returns a list of bigbluebuttonbns in a provided list of courses.
123
     * If no list is provided all bigbluebuttonbns that the user can view will be returned.
124
     *
125
     * @param array $courseids course ids
126
     * @return array of warnings and bigbluebuttonbns
127
     * @since Moodle 3.3
128
     */
129
    public static function get_bigbluebuttonbns_by_courses($courseids = array()) {
130
131
        $warnings = array();
132
        $returnedbigbluebuttonbns = array();
133
134
        $params = array(
135
            'courseids' => $courseids,
136
        );
137
        $params = self::validate_parameters(self::get_bigbluebuttonbns_by_courses_parameters(), $params);
138
139
        $mycourses = array();
140
        if (empty($params['courseids'])) {
141
            $mycourses = enrol_get_my_courses();
142
            $params['courseids'] = array_keys($mycourses);
143
        }
144
145
        // Ensure there are courseids to loop through.
146
        if (!empty($params['courseids'])) {
147
148
            list($courses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses);
149
150
            // Get the bigbluebuttonbns in this course, this function checks users visibility permissions.
151
            // We can avoid then additional validate_context calls.
152
            $bigbluebuttonbns = get_all_instances_in_courses("bigbluebuttonbn", $courses);
153
            foreach ($bigbluebuttonbns as $bigbluebuttonbn) {
154
                $context = context_module::instance($bigbluebuttonbn->coursemodule);
155
                // Entry to return.
156
                $bigbluebuttonbn->name = external_format_string($bigbluebuttonbn->name, $context->id);
157
158
                list($bigbluebuttonbn->intro, $bigbluebuttonbn->introformat) = external_format_text($bigbluebuttonbn->intro,
159
                    $bigbluebuttonbn->introformat, $context->id, 'mod_bigbluebuttonbn', 'intro', null);
160
                $bigbluebuttonbn->introfiles = external_util::get_area_files($context->id,
161
                    'mod_bigbluebuttonbn', 'intro', false, false);
162
163
                $returnedbigbluebuttonbns[] = $bigbluebuttonbn;
164
            }
165
        }
166
167
        $result = array(
168
            'bigbluebuttonbns' => $returnedbigbluebuttonbns,
169
            'warnings' => $warnings
170
        );
171
        return $result;
172
    }
173
174
    /**
175
     * Describes the get_bigbluebuttonbns_by_courses return value.
176
     *
177
     * @return external_single_structure
178
     * @since Moodle 3.3
179
     */
180
    public static function get_bigbluebuttonbns_by_courses_returns() {
181
        return new external_single_structure(
182
            array(
183
                'bigbluebuttonbns' => new external_multiple_structure(
184
                    new external_single_structure(
185
                        array(
186
                            'id' => new external_value(PARAM_INT, 'Module id'),
187
                            'coursemodule' => new external_value(PARAM_INT, 'Course module id'),
188
                            'course' => new external_value(PARAM_INT, 'Course id'),
189
                            'name' => new external_value(PARAM_RAW, 'Name'),
190
                            'intro' => new external_value(PARAM_RAW, 'Description'),
191
                            'meetingid' => new external_value(PARAM_RAW, 'Meeting id'),
192
                            'introformat' => new external_format_value('intro', 'Summary format'),
193
                            'introfiles' => new external_files('Files in the introduction text'),
194
                            'timemodified' => new external_value(PARAM_INT, 'Last time the instance was modified'),
195
                            'section' => new external_value(PARAM_INT, 'Course section id'),
196
                            'visible' => new external_value(PARAM_INT, 'Module visibility'),
197
                            'groupmode' => new external_value(PARAM_INT, 'Group mode'),
198
                            'groupingid' => new external_value(PARAM_INT, 'Grouping id'),
199
                        )
200
                    )
201
                ),
202
                'warnings' => new external_warnings(),
203
            )
204
        );
205
    }
206
207
    /**
208
     * Returns description of method parameters
209
     *
210
     * @return external_function_parameters
211
     * @since Moodle 3.0
212
     */
213
    public static function can_join_parameters() {
214
        return new external_function_parameters(
215
            array(
216
                'cmid' => new external_value(PARAM_INT, 'course module id', VALUE_REQUIRED)
217
            )
218
        );
219
    }
220
221
    /**
222
     * This will check if current user can join the session from this module
223
     * @param int $cmid
224
     * @throws coding_exception
225
     * @throws dml_exception
226
     */
227
    public static function can_join($cmid) {
228
        global $SESSION, $CFG;
229
        require_once($CFG->dirroot . "/mod/bigbluebuttonbn/locallib.php");
230
231
        $params = self::validate_parameters(self::can_join_parameters(),
0 ignored issues
show
$params is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
232
            array(
233
                'cmid' => $cmid
234
            ));
235
        $canjoin = \mod_bigbluebuttonbn\locallib\bigbluebutton::can_join_meeting($cmid);
236
        $canjoin['cmid'] = $cmid;
237
        return $canjoin;
238
    }
239
240
    /**
241
     * Return value for can join function
242
     *
243
     * @return external_single_structure
244
     * @since Moodle 3.3
245
     */
246
    public static function can_join_returns() {
247
        return new external_single_structure(
248
            array(
249
                'can_join' => new external_value(PARAM_BOOL, 'Can join session'),
250
                'message' => new external_value(PARAM_RAW, 'Message if we cannot join', VALUE_OPTIONAL),
251
                'cmid' => new external_value(PARAM_INT, 'course module id', VALUE_REQUIRED)
252
            )
253
        );
254
    }
255
}
256