Compare commits

...
6 Commits
Author SHA1 Message Date
cameron1729 85d0657563 Merge pull request #418 from catalyst/fix-502-forcelogin-tests
Fix outage step test by forcing login default to off
2026-07-16 01:41:52 +08:00
Cameron Ball 88667c51e4 Fix outage step test by forcing login default to off 2026-07-16 01:37:04 +08:00
Sarah Cotton 5dd73b0909 Merge pull request #411 from sarahjcotton/WR489688-security-fix-501
WR489688: Security fix #30
2026-07-13 14:02:23 +01:00
Sarah Cotton 1a94b8e635 WR489688: Security fix #30 2026-06-25 15:10:18 +01:00
Tomo Tsuyuki 40fccef237 Revert "Fix URL is blocked message when not behind a proxy/load balancer"
This reverts commit 51db933862.
2026-06-18 12:00:11 +10:00
Tomo Tsuyuki dbc8e75092 issue #405: fix unit test failure 2026-06-18 10:02:04 +10:00
4 changed files with 10 additions and 36 deletions
+5 -1
View File
@@ -56,7 +56,7 @@ class outagelib {
global $CFG;
require_once($CFG->libdir . '/filelib.php');
$curl = new curl(['ignoresecurity' => true]);
$curl = new curl();
$contents = $curl->get($file);
$info = $curl->get_info();
if (!empty($info['content_type'])) {
@@ -267,6 +267,10 @@ class outagelib {
// single-quotes (and double for the sake of it) are present otherwise it would break the code.
$allowedips = addslashes($allowedips);
// Escape the access key before substitution into the PHP literal to prevent
// code injection via a maliciously crafted access key value.
$accesskey = addslashes((string)$accesskey);
$cookiesecure = is_moodle_cookie_secure();
// Since Moodle 4.3 cookiehttponly is default to true and this CFG is not set.
+3
View File
@@ -95,6 +95,9 @@ abstract class base_testcase extends \advanced_testcase {
parent::setUp();
$this->resetAfterTest(true);
// These tests rely on force login being disabled, but Moodle 5.2 enables it by default (MDL-87523).
set_config('forcelogin', 0);
}
/**
@@ -431,39 +431,6 @@ final class maintenance_static_page_test extends \auth_outage\base_testcase {
maintenance_static_page_io::file_get_data(200);
}
/**
* Test file_get_data with curlsecurityblockedhosts.
* We will use an external URL to test passing ignoresecurity inside of file_get_data works,
* ideally in real code we should only be calling file_get_data with internal URLs.
*/
public function test_file_get_data_curlsecurityblockedhosts(): void {
global $CFG, $USER;
$testhtml = $this->getExternalTestFileUrl('/test.html');
$url = new \moodle_url($testhtml);
$host = $url->get_host();
set_config('curlsecurityblockedhosts', $host); // Blocks $host.
// Test a regular curl with the default security enabled does in fact get blocked.
$curl = new \curl();
$contents = $curl->get($testhtml);
$expected = $curl->get_security()->get_blocked_url_string();
self::assertSame($expected, $contents);
self::assertSame(0, $curl->get_errno());
if ($CFG->branch >= 403) {
self::assertDebuggingCalled(
"Blocked $testhtml: The URL is blocked. [user {$USER->id}]",
DEBUG_NONE
);
}
// Test file_get_data does return the page and isn't blocked by security.
$found = maintenance_static_page_io::file_get_data($url->out());
$expected = '47250a973d1b88d9445f94db4ef2c97a';
self::assertSame($expected, md5($found['contents']));
self::assertSame('text/html', $found['mime']);
}
/**
* Test remove css selector.
*/
+2 -2
View File
@@ -28,8 +28,8 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = "auth_outage";
$plugin->version = 2026011302; // The current plugin version (Date: YYYYMMDDXX).
$plugin->release = 2026011302; // Human-readable release information.
$plugin->version = 2026011306; // The current plugin version (Date: YYYYMMDDXX).
$plugin->release = 2026011305; // Human-readable release information.
$plugin->requires = 2025100600; // Moodle 5.1.
$plugin->maturity = MATURITY_STABLE; // Suitable for PRODUCTION environments!
$plugin->supported = [501, 501]; // A range of branch numbers of supported moodle versions.