Method: NewRelic::Agent::Configuration::SecurityPolicySource#build_overrides

Defined in:
lib/new_relic/agent/configuration/security_policy_source.rb

#build_overrides(security_policies) ⇒ Object

[View source]

215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/new_relic/agent/configuration/security_policy_source.rb', line 215

def build_overrides(security_policies)
  security_policies.inject({}) do |settings, (policy_name, policy_settings)|
    SECURITY_SETTINGS_MAP[policy_name].each do |policy|
      next unless policy[:supported]

      if policy_settings[ENABLED]
        if policy[:enabled_fn].call(policy[:option])
          if permitted_fn = policy[:permitted_fn]
            permitted_fn.call(settings)
          end
        else
          config_source = Agent.config.source(policy[:option]).class.name.split(COLON_COLON).last
          NewRelic::Agent.logger.info( \
            "Setting applied: {#{policy[:option]}: #{policy[:disabled_value]}}. " \
            "Source: #{config_source}"
          )
        end
      else
        settings[policy[:option]] = policy[:disabled_value]
        NewRelic::Agent.logger.info( \
          "Setting applied: {#{policy[:option]}: #{policy[:disabled_value]}}. " \
          'Source: SecurityPolicySource'
        )
      end
    end
    settings
  end
end