Skip to content

Commit a7790eb

Browse files
authored
Merge pull request #1207 from Fryguy/fix_filter_params
Fix issues after core changes for partial match passwords
2 parents 194ae2d + cecf020 commit a7790eb

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

lib/api.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ module Api
1111
UnsupportedMediaTypeError = Class.new(ApiError)
1212

1313
def self.encrypted_attribute?(attr)
14-
Environment.encrypted_attributes.include?(attr.to_s) || attr.to_s.include?('password')
14+
!Environment.encrypted_attributes_whitelist.include?(attr.to_s) &&
15+
Environment.encrypted_attributes.any? { |a| attr.to_s.include?(a.to_s) }
1516
end
1617

1718
def self.time_attribute?(attr)

lib/api/environment.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ def self.encrypted_attributes
1414
::Vmdb::Settings::PASSWORD_FIELDS.map(&:to_s)
1515
end
1616

17+
def self.encrypted_attributes_whitelist
18+
@encrypted_attributes_whitelist ||= Set.new(%w[
19+
auth_token
20+
verify_ssl
21+
])
22+
end
23+
1724
def self.time_attributes
1825
@time_attributes ||= ApiConfig.collections.each.with_object(Set.new(%w(expires_on))) do |(_, cspec), result|
1926
next if cspec[:klass].blank?

spec/requests/regions_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@
128128
context "/api/regions/:id?expand=settings" do
129129
it "expands the settings subcollection" do
130130
api_basic_authorize(action_identifier(:regions, :read, :resource_actions, :get), :ops_settings)
131-
allow(Vmdb::Settings).to receive(:for_resource).and_return('authentications' => { 'bind_pwd' => 'bad_val'})
131+
stub_settings_merge(:authentication => {:bind_pwd => 'passw0rd'})
132132
allow(User).to receive(:current_user).and_return(@user)
133133
allow(@user).to receive(:super_admin_user?).and_return(true)
134134

135135
get(api_region_url(nil, region), :params => {:expand => 'settings'})
136136

137-
expect(response.parsed_body).to include('settings' => {'authentications' => {}})
137+
expect(response.parsed_body).to_not have_key_path("settings", "authentication", "bind_pwd")
138138
expect(response).to have_http_status(:ok)
139139
end
140140

0 commit comments

Comments
 (0)