Commit 8b6eca68 authored by Alex Kalderimis's avatar Alex Kalderimis Committed by Doug Stull

Remove unnecessary regexp elements

This removes the regexp filter for fields containing 'title' or
'description' in their name.

This relates to the removal of the title and description columns on
the integrations table

See: https://gitlab.com/gitlab-org/gitlab/-/issues/217587
parent 92368afa
......@@ -414,7 +414,10 @@ class Integration < ApplicationRecord
end
def api_field_names
fields.pluck(:name).grep_v(/password|token|key|title|description/)
fields
.reject { _1[:type] == 'password' }
.pluck(:name)
.grep_v(/password|token|key/)
end
def global_fields
......
......@@ -5,19 +5,8 @@ module API
class ProjectIntegration < Entities::ProjectIntegrationBasic
# Expose serialized properties
expose :properties do |integration, options|
# TODO: Simplify as part of https://gitlab.com/gitlab-org/gitlab/issues/29404
attributes =
if integration.data_fields_present?
integration.data_fields.as_json.keys
else
integration.properties.keys
end
attributes &= integration.api_field_names
attributes.each_with_object({}) do |attribute, hash|
hash[attribute] = integration.public_send(attribute) # rubocop:disable GitlabSecurity/PublicSend
integration.api_field_names.to_h do |name|
[name, integration.public_send(name)] # rubocop:disable GitlabSecurity/PublicSend
end
end
end
......
......@@ -732,14 +732,21 @@ RSpec.describe Integration do
{ name: 'password' },
{ name: 'password_field' },
{ name: 'some_safe_field' },
{ name: 'safe_field' }
{ name: 'safe_field' },
{ name: 'url' },
{ name: 'trojan_horse', type: 'password' },
{ name: 'trojan_gift', type: 'gift' }
].shuffle
end
end
end
it 'filters out sensitive fields' do
expect(fake_integration.new).to have_attributes(api_field_names: match_array(%w[some_safe_field safe_field]))
safe_fields = %w[some_safe_field safe_field url trojan_gift]
expect(fake_integration.new).to have_attributes(
api_field_names: match_array(safe_fields)
)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment