Skip to content

Commit 99143dc

Browse files
committed
Add "Keys to Hide" config option.
1 parent 975ba75 commit 99143dc

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

TracyDebugger.module.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static function getModuleInfo() {
2727
'summary' => __('Tracy debugger from Nette with many PW specific custom tools.', __FILE__),
2828
'author' => 'Adrian Jones',
2929
'href' => 'https://processwire.com/talk/forum/58-tracy-debugger/',
30-
'version' => '4.26.46',
30+
'version' => '4.26.47',
3131
'autoload' => 100000, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first
3232
'singular' => true,
3333
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',
@@ -216,6 +216,7 @@ static public function getDefaultData() {
216216
"forceScream" => null,
217217
"outputMode" => 'detect',
218218
"showLocation" => array('Tracy\Dumper::LOCATION_SOURCE', 'Tracy\Dumper::LOCATION_LINK', 'Tracy\Dumper::LOCATION_CLASS'),
219+
"keysToHide" => 'dbPass, dbName, dbUser, user, username, pass, password, pwd, pw, auth, token, secret',
219220
"logSeverity" => array(),
220221
"excludedPwLogFiles" => array('session', 'modules', 'file-compiler'),
221222
"excludedTracyLogFiles" => array(),
@@ -950,6 +951,9 @@ public function init() {
950951
Debugger::$showLocation = array_reduce($locations, function($a, $b) { return $a | $b; }, 0);
951952

952953

954+
Debugger::$keysToHide = array_map('trim', explode(',', $this->data['keysToHide']));
955+
956+
953957
// START ENABLING TRACY
954958
// now that required classes above have been loaded, we can now exit if user is not allowed
955959
if(!static::$allowedTracyUser) return;
@@ -3458,6 +3462,14 @@ public function getModuleConfigInputfields(array $data) {
34583462
$f->attr('checked', $data['debugInfo'] == '1' ? 'checked' : '');
34593463
$fieldset->add($f);
34603464

3465+
$f = $this->wire('modules')->get("InputfieldText");
3466+
$f->attr('name', 'keysToHide');
3467+
$f->label = __('Keys to hide', __FILE__);
3468+
$f->description = __('Keys to redact in dumps and bluescreens.', __FILE__);
3469+
$f->notes = __('Enter keys separated by commas.'."\nDefault: ".self::getDefaultData()['keysToHide'], __FILE__);
3470+
if($data['keysToHide']) $f->attr('value', $data['keysToHide']);
3471+
$fieldset->add($f);
3472+
34613473
$f = $this->wire('modules')->get("InputfieldInteger");
34623474
$f->attr('name', 'maxDepth');
34633475
$f->label = __('Maximum nesting depth', __FILE__);

includes/TD.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public static function barDump($var, $title = NULL, $options = []) {
7676
$options[Dumper::TRUNCATE] = isset($options['maxLength']) ? $options['maxLength'] : \TracyDebugger::getDataValue('maxLength');
7777
if(defined('\Tracy\Dumper::ITEMS')) $options[Dumper::ITEMS] = isset($options['maxItems']) ? $options['maxItems'] : \TracyDebugger::getDataValue('maxItems');
7878
$options[Dumper::LOCATION] = Debugger::$showLocation;
79+
$options[Dumper::KEYS_TO_HIDE] = Debugger::$keysToHide;
7980
if(version_compare(Debugger::VERSION, '2.6.0', '>=')) $options[Dumper::LAZY] = true;
8081
static::dumpToBar($var, $title, $options);
8182
}
@@ -100,6 +101,7 @@ public static function barDumpBig($var, $title = NULL, $options = []) {
100101
$options[Dumper::TRUNCATE] = 9999;
101102
if(defined('\Tracy\Dumper::ITEMS')) $options[Dumper::ITEMS] = 250;
102103
$options[Dumper::LOCATION] = Debugger::$showLocation;
104+
$options[Dumper::KEYS_TO_HIDE] = Debugger::$keysToHide;
103105
if(version_compare(Debugger::VERSION, '2.6.0', '>=')) $options[Dumper::LAZY] = true;
104106
static::dumpToBar($var, $title, $options);
105107
}
@@ -138,6 +140,7 @@ public static function dump($var, $title = NULL, $options = []) {
138140
$options[Dumper::ITEMS] = isset($options['maxItems']) ? $options['maxItems'] : \TracyDebugger::getDataValue('maxItems');
139141
}
140142
$options[Dumper::LOCATION] = \TracyDebugger::$fromConsole ? false : Debugger::$showLocation;
143+
$options[Dumper::KEYS_TO_HIDE] = Debugger::$keysToHide;
141144
if(version_compare(Debugger::VERSION, '2.6.0', '>=')) $options[Dumper::LAZY] = false;
142145
echo '
143146
<div class="tracy-inner" style="height:auto !important">
@@ -181,6 +184,7 @@ public static function dumpBig($var, $title = NULL, $options = []) {
181184
$options[Dumper::TRUNCATE] = 9999;
182185
if(defined('\Tracy\Dumper::ITEMS')) $options[Dumper::ITEMS] = 250;
183186
$options[Dumper::LOCATION] = \TracyDebugger::$fromConsole ? false : Debugger::$showLocation;
187+
$options[Dumper::KEYS_TO_HIDE] = Debugger::$keysToHide;
184188
if(version_compare(Debugger::VERSION, '2.6.0', '>=')) $options[Dumper::LAZY] = false;
185189
echo '
186190
<div class="tracy-inner" style="height:auto !important">
@@ -205,6 +209,7 @@ private static function dumpToBar($var, $title = NULL, $options = [], $echo = fa
205209
if((self::tracyUnavailable() && \TracyDebugger::getDataValue('recordGuestDumps')) || (isset(\TracyDebugger::$showPanels) && in_array('dumpsRecorder', \TracyDebugger::$showPanels))) {
206210
$dumpsFile = wire('config')->paths->cache . 'TracyDebugger/dumps.json';
207211
$dumpsRecorderItems = file_exists($dumpsFile) ? json_decode(file_get_contents($dumpsFile), true) : array();
212+
if(!$dumpsRecorderItems) $dumpsRecorderItems = array();
208213
array_push($dumpsRecorderItems, $dumpItem);
209214
wire('files')->filePutContents($dumpsFile, json_encode($dumpsRecorderItems));
210215
}

0 commit comments

Comments
 (0)