Skip to content

Commit dd77379

Browse files
committed
Bugfix: Fixed security check timeout
refactoring
1 parent 33ccdd8 commit dd77379

File tree

2 files changed

+6
-43
lines changed

2 files changed

+6
-43
lines changed

resources/views/components/config/diagnose.blade.php

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,6 @@
99
$ufalse = "<td style=\"text-align: center; cursor: help;\" title=\"Everything is working as expected!\"><i class='bi bi-check-lg'></i></td>";
1010
$unull = "<td style=\"text-align: center; cursor: help;\" title=\"Something went wrong. This might be normal if you're running behind a proxy or docker container.\">➖</td>";
1111
12-
13-
$server = $_SERVER['SERVER_NAME'];
14-
$uri = $_SERVER['REQUEST_URI'];
15-
16-
// Tests if a URL has a valid SSL certificate
17-
function has_ssl( $domain ) {
18-
$ssl_check = @fsockopen( 'ssl://' . $domain, 443, $errno, $errstr, 30 );
19-
$res = !! $ssl_check;
20-
if ( $ssl_check ) { fclose( $ssl_check ); }
21-
return $res;
22-
}
23-
24-
// Changes probed URL to HTTP if no valid SSL certificate is present, otherwise an error would be thrown
25-
if (has_ssl($server)) {
26-
$actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
27-
} else {
28-
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
29-
}
30-
3112
function getUrlSatusCode($url, $timeout = 3)
3213
{
3314
$ch = curl_init();
@@ -43,12 +24,12 @@ function getUrlSatusCode($url, $timeout = 3)
4324
}
4425
4526
//Files or directories to test if writable
46-
$wrt1 = is_writable('.env');
47-
$wrt2 = is_writable('database/database.sqlite');
27+
$wrt1 = is_writable(base_path('.env'));
28+
$wrt2 = is_writable(base_path('database/database.sqlite'));
4829
4930
//Files or directories to test if accessible externally
50-
$url1 = getUrlSatusCode($actual_link . '/../../.env');
51-
$url2 = getUrlSatusCode($actual_link . '/../../database/database.sqlite');
31+
$url1 = getUrlSatusCode(url('.env'));
32+
$url2 = getUrlSatusCode(url('database/database.sqlite'));
5233
5334
?>
5435

resources/views/layouts/notifications.blade.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,6 @@ function notificationCard($ntid, $icon, $heading, $subheading) {
4747
//security check, checks if config files got compromised
4848
if(auth()->user()->role == 'admin'){
4949
50-
$serversb = $_SERVER['SERVER_NAME'];
51-
$urisb = $_SERVER['REQUEST_URI'];
52-
53-
// Tests if a URL has a valid SSL certificate
54-
function has_sslsb( $domain ) {
55-
$ssl_check = @fsockopen( 'ssl://' . $domain, 443, $errno, $errstr, 30 );
56-
$res = !! $ssl_check;
57-
if ( $ssl_check ) { fclose( $ssl_check ); }
58-
return $res;
59-
}
60-
61-
// Changes probed URL to HTTP if no valid SSL certificate is present, otherwise an error would be thrown
62-
if (has_sslsb($serversb)) {
63-
$actual_linksb = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
64-
} else {
65-
$actual_linksb = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
66-
}
67-
6850
function getUrlSatusCodesb($urlsb, $timeoutsb = 3)
6951
{
7052
$chsb = curl_init();
@@ -80,8 +62,8 @@ function getUrlSatusCodesb($urlsb, $timeoutsb = 3)
8062
}
8163
8264
// Files or directories to test if accessible externally
83-
$url1sb = getUrlSatusCodesb($actual_linksb . '/../../.env');
84-
$url2sb = getUrlSatusCodesb($actual_linksb . '/../../database/database.sqlite');
65+
$url1sb = getUrlSatusCodesb(url('.env'));
66+
$url2sb = getUrlSatusCodesb(url('database/database.sqlite'));
8567
8668
// sets compromised to true if config files got compromised
8769
if($url1sb == '200' or $url2sb == '200') {

0 commit comments

Comments
 (0)