[Rt-commit] rt branch, 5.0/obfuscate-passphrase-in-crypt-configs, created. rt-5.0.0-98-g168438d12d
? sunnavy
sunnavy at bestpractical.com
Fri Nov 6 10:58:04 EST 2020
The branch, 5.0/obfuscate-passphrase-in-crypt-configs has been created
at 168438d12d607780c9f9f569a091556d7600d022 (commit)
- Log -----------------------------------------------------------------
commit 153a77b420a6a6e0b828c7c4f2c9a4c8030000d0
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Nov 6 16:00:40 2020 +0800
Make sure $user always exists to simplify Obfuscate callback a bit
We are going to add obfuscate callbacks for more configs, this tweak
will help reduce duplicate code.
Note that we already explicitly pass RT->SystemUser in tests, but since
there was no db previously, RT->SystemUser was still undef.
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 59ce078f1c..568b899802 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -1295,9 +1295,7 @@ our %META;
Obfuscate => sub {
# Ensure passwords are obfuscated on the System Configuration page
my ($config, $sources, $user) = @_;
-
- my $msg = 'Password not printed';
- $msg = $user->loc($msg) if $user and $user->Id;
+ my $msg = $user->loc('Password not printed');
for my $source (values %$sources) {
$source->{pass} = $msg;
@@ -2304,7 +2302,7 @@ sub GetObfuscated {
return $self->Get(@_) unless $obfuscate;
my $res = Clone::clone( $self->Get( @_ ) );
- $res = $obfuscate->( $self, $res, $user );
+ $res = $obfuscate->( $self, $res, $user && $user->Id ? $user : RT->SystemUser );
return $self->_ReturnValue( $res, $META{$name}->{'Type'} || 'SCALAR' );
}
diff --git a/t/api/config.t b/t/api/config.t
index f96d03b26c..7ccbf590c3 100644
--- a/t/api/config.t
+++ b/t/api/config.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
use RT;
-use RT::Test nodb => 1, tests => undef;
+use RT::Test tests => undef;
use Test::Warn;
ok(
commit 168438d12d607780c9f9f569a091556d7600d022
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Nov 5 06:09:28 2020 +0800
Obfuscate passphrase in %SMIME, %GnuPG and %GnuPGOptions on system config page
Note that the "passphrase" is lower cased in %GnuPGOptions.
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 568b899802..dcfe9ad9b0 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -930,6 +930,11 @@ our %META;
Type => 'HASH',
Immutable => 1,
Invisible => 1,
+ Obfuscate => sub {
+ my ( $config, $value, $user ) = @_;
+ $value->{Passphrase} = $user->loc('Password not printed');
+ return $value;
+ },
PostLoadCheck => sub {
my $self = shift;
my $opt = $self->Get('SMIME');
@@ -966,6 +971,11 @@ our %META;
Type => 'HASH',
Immutable => 1,
Invisible => 1,
+ Obfuscate => sub {
+ my ( $config, $value, $user ) = @_;
+ $value->{Passphrase} = $user->loc('Password not printed');
+ return $value;
+ },
PostLoadCheck => sub {
my $self = shift;
my $gpg = $self->Get('GnuPG');
@@ -998,6 +1008,11 @@ our %META;
Type => 'HASH',
Immutable => 1,
Invisible => 1,
+ Obfuscate => sub {
+ my ( $config, $value, $user ) = @_;
+ $value->{passphrase} = $user->loc('Password not printed');
+ return $value;
+ },
},
ReferrerWhitelist => { Type => 'ARRAY' },
EmailDashboardLanguageOrder => { Type => 'ARRAY' },
-----------------------------------------------------------------------
More information about the rt-commit
mailing list