File tree Expand file tree Collapse file tree 8 files changed +58
-5
lines changed Expand file tree Collapse file tree 8 files changed +58
-5
lines changed Original file line number Diff line number Diff line change @@ -7,5 +7,6 @@ def index
7
7
repo = `git remote show origin -n | perl -ne 'print $1 if m{Fetch URL: .*github\\ .com[:/](.*)\\ .git}'`
8
8
@github_origin = "https://github.com/#{ repo } /tree/"
9
9
@request_env = request . env
10
+ @alaveteli_configuration = AlaveteliConfiguration . to_sanitized_hash
10
11
end
11
12
end
Original file line number Diff line number Diff line change 45
45
46
46
< h2 > Configuration</ h2 >
47
47
48
+ < div class ="help-block ">
49
+ < p >
50
+ See the < a href ="https://alaveteli.org/docs/customising/config/ ">
51
+ documentation</ a > for more information about configuring Alaveteli.
52
+ </ p >
53
+
54
+ < p >
55
+ Sensitive values are replaced with < tt > [FILTERED]</ tt > . Use the
56
+ < tt > config/general.yml</ tt > configuration file to view these.
57
+ </ p >
58
+ </ div >
59
+
48
60
< table class ="table table-condensed table-debug ">
49
61
< tr >
50
62
< td > Rails env:</ td >
56
68
</ tr >
57
69
</ table >
58
70
71
+ < table class ="table table-condensed table-debug ">
72
+ <% @alaveteli_configuration . each do |k , v | %>
73
+ < tr >
74
+ < td > <%= k %> </ td >
75
+ < td > <%= v %> </ td >
76
+ </ tr >
77
+ <% end %>
78
+ </ table >
79
+
59
80
< h2 > Environment variables</ h2 >
60
81
61
82
< table class ="table table-condensed table-debug ">
Original file line number Diff line number Diff line change 18
18
< li > <%= link_to 'Summary' , admin_general_index_path %> </ li >
19
19
< li > <%= link_to 'Timeline' , admin_timeline_path %> </ li >
20
20
< li > <%= link_to 'Stats' , admin_stats_path %> </ li >
21
- < li > <%= link_to 'Debug' , admin_debug_path %> </ li >
21
+ < li > <%= link_to 'Debug' , admin_debug_index_path %> </ li >
22
22
</ ul >
23
23
</ li >
24
24
Original file line number Diff line number Diff line change 12
12
# Default values for these settings can be found in
13
13
# RAILS_ROOT/lib/configuration.rb
14
14
#
15
+ #
16
+ # WARNING: AlaveteliConfiguration is rendered to admin users in
17
+ # Admin::DebugController.
18
+ #
19
+ # Ensure any sensitive values are matched by
20
+ # AlaveteliConfiguration.sensitive_key_patterns
21
+ #
15
22
# ==============================================================================
16
23
17
24
# Site name appears in various places throughout the site
Original file line number Diff line number Diff line change @@ -528,10 +528,7 @@ def matches?(request)
528
528
529
529
#### Admin::Debug controller
530
530
namespace :admin do
531
- # FIXME: For some reason the resources call is generating the route as
532
- # admin_debug_index_path rather than the standard admin_debug_path.
533
- # resources :debug, only: [:index]
534
- get 'debug' , to : 'debug#index' , as : :debug
531
+ resources :debug , only : :index
535
532
end
536
533
####
537
534
Original file line number Diff line number Diff line change 2
2
3
3
## Highlighted Features
4
4
5
+ * Render Alaveteli configuration values on admin debug page (Gareth Rees)
5
6
* View user profile photos from admin list of users (Gareth Rees)
6
7
* Update user email to be sent from the blackhole address (Graeme Porteous)
7
8
* Remove ability to publicly view authority contact email addresses to prevent
Original file line number Diff line number Diff line change 13
13
# TODO: Make this return different values depending on the current rails environment
14
14
15
15
module AlaveteliConfiguration
16
+ # WARNING: AlaveteliConfiguration is rendered to admin users in
17
+ # Admin::DebugController.
18
+ #
19
+ # Ensure any sensitive values match this pattern, or add to the pattern if
20
+ # adding a new value that doesn't fit.
21
+ mattr_accessor :sensitive_key_patterns ,
22
+ default : /SECRET|PASSWORD|LICENSE_KEY/
23
+
16
24
unless const_defined? ( :DEFAULTS )
17
25
18
26
# rubocop:disable Layout/LineLength
@@ -150,4 +158,12 @@ def self.method_missing(name)
150
158
super
151
159
end
152
160
end
161
+
162
+ def self . to_sanitized_hash
163
+ DEFAULTS . keys . each_with_object ( { } ) do |key , memo |
164
+ value = send ( key )
165
+ value = '[FILTERED]' if value . present? && key =~ sensitive_key_patterns
166
+ memo [ key ] = value
167
+ end
168
+ end
153
169
end
Original file line number Diff line number Diff line change
1
+ require 'spec_helper'
2
+
3
+ RSpec . describe AlaveteliConfiguration do
4
+ include AlaveteliConfiguration
5
+
6
+ describe '#to_sanitized_hash' do
7
+ subject { described_class . to_sanitized_hash }
8
+ it { is_expected . to include ( :INCOMING_EMAIL_SECRET => '[FILTERED]' ) }
9
+ end
10
+ end
You can’t perform that action at this time.
0 commit comments