-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Global params for host obfuscation and migrate off settings #921
base: develop
Are you sure you want to change the base?
Conversation
3e407b8
to
efbca09
Compare
efbca09
to
2fd7b5d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we will need to add a UI message on the inventory page about the ability to obfuscate using the parameter. Otherwise it will feel to the user that the setting just disappeared without replacement.
CommonParameter.find_or_create_by!(name: 'obfuscate_inventory_hostnames', value: false) | ||
CommonParameter.find_or_create_by!(name: 'obfuscate_inventory_ips', value: false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CommonParameter.find_or_create_by!(name: 'obfuscate_inventory_hostnames', value: false) | |
CommonParameter.find_or_create_by!(name: 'obfuscate_inventory_ips', value: false) | |
hostname_setting = CommonParameter.find_or_create_by!(name: 'obfuscate_inventory_hostnames', value: false) | |
ip_setting = CommonParameter.find_or_create_by!(name: 'obfuscate_inventory_ips', value: false) |
You can skip the find_by
later in the code
@@ -61,7 +61,7 @@ def obfuscate_hostname?(host) | |||
insights_client_setting = ActiveModel::Type::Boolean.new.cast(insights_client_setting) | |||
return insights_client_setting unless insights_client_setting.nil? | |||
|
|||
Setting[:obfuscate_inventory_hostnames] | |||
CommonParameter.find_by(name: 'obfuscate_inventory_hostnames')&.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should look for a value on the host, not just the common parameter, similar to
foreman_rh_cloud/app/controllers/insights_cloud/api/machine_telemetries_controller.rb
Line 87 in 48f9d74
param_value = host.host_param(InsightsCloud.enable_client_param) |
@@ -79,7 +79,7 @@ def obfuscate_ips?(host) | |||
insights_client_setting = ActiveModel::Type::Boolean.new.cast(insights_client_setting) | |||
return insights_client_setting unless insights_client_setting.nil? | |||
|
|||
Setting[:obfuscate_inventory_ips] | |||
CommonParameter.find_by(name: 'obfuscate_inventory_ips')&.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's a parameter, you have to look up the value on the host object itself:
foreman_rh_cloud/app/controllers/insights_cloud/api/machine_telemetries_controller.rb
Line 87 in 48f9d74
param_value = host.host_param(InsightsCloud.enable_client_param) |
@@ -114,7 +114,7 @@ def hostname_match | |||
foreman_hostname = ForemanRhCloud.foreman_host&.name | |||
if bash_hostname == foreman_hostname | |||
fqdn(ForemanRhCloud.foreman_host) | |||
elsif Setting[:obfuscate_inventory_hostnames] | |||
elsif CommonParameter.find_by(name: 'obfuscate_inventory_hostnames')&.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's a parameter, you have to look up the value on the host object itself:
foreman_rh_cloud/app/controllers/insights_cloud/api/machine_telemetries_controller.rb
Line 87 in 48f9d74
param_value = host.host_param(InsightsCloud.enable_client_param) |
@@ -23,8 +23,8 @@ class MetadataGeneratorTest < ActiveSupport::TestCase | |||
end | |||
|
|||
test 'generates an empty report with hidden hostname and ip' do | |||
Setting[:obfuscate_inventory_hostnames] = true | |||
Setting[:obfuscate_inventory_ips] = true | |||
CommonParameter.find_or_create_by!(name: 'obfuscate_inventory_ips', value: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the parameter exists, I think this method will not reset its value.
What are the changes introduced in this pull request?
obfuscate_inventory_hostnames
andobfuscate_inventory_ips
and set them tofalse
which is the default value forinsights-client
obfuscate_inventory_hostnames
andobfuscate_inventory_ips
and deletes the settings from the plugin and DB