Skip to content

Commit d125005

Browse files
committed
debug: obscure even more secrets
1 parent d4e82db commit d125005

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

modules/page-debug-info.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
echo("Powered by Pepperminty Wiki version $version+" . substr($commit, 0, 7) . ".\n");
4040
echo("This report may contain personal information.\n\n");
4141
echo("Environment: ");
42-
echo(var_export($env, true));
42+
echo(debug_mask_secrets(var_export($env, true)));
4343
echo("\nPaths: ");
44-
var_dump(var_export($paths, true));
44+
echo(var_export($paths, true));
4545
echo("\nServer information:\n");
4646
echo("uname -a: " . php_uname() . "\n");
4747
echo("Path: " . getenv("PATH") . "\n");
@@ -56,12 +56,7 @@
5656
echo("Storage directory permissions: " . substr(sprintf('%o', fileperms($env->storage_prefix)), -4) . "\n");
5757
echo("Loaded extensions: " . implode(", ", get_loaded_extensions()) . "\n");
5858
echo("Settings:\n-----\n");
59-
$settings_export = explode("\n", var_export($settings, true));
60-
foreach ($settings_export as &$row)
61-
{
62-
if(preg_match("/'(secret|sitesecret|email(?:Address)?|password)'/i", $row)) $row = "********* secret *********";
63-
}
64-
echo(implode("\n", $settings_export));
59+
echo(debug_mask_secrets(var_export($settings, true)));
6560
echo("\n-----\n");
6661
exit();
6762
});
@@ -73,4 +68,18 @@
7368
}
7469
]);
7570

71+
/**
72+
* Masks secrets in debug output.
73+
* @param string $text The text to mask.
74+
* @return string The masked text.
75+
*/
76+
function debug_mask_secrets($text) {
77+
$lines = explode("\n", $text);
78+
foreach ($lines as &$line) {
79+
if(preg_match("/'(secret|sitesecret|email(?:Address)?|password)'/i", $line)) $line = "********* secret *********";
80+
}
81+
82+
return implode("\n", $lines);
83+
}
84+
7685
?>

0 commit comments

Comments
 (0)