graylog-labs / gelf-rb

Ruby GELF library (Graylog Extended Log Format)
https://rubygems.org/gems/gelf
MIT License
153 stars 104 forks source link

Prevent mutation of notifier arguments #67

Closed nepalez closed 6 years ago

nepalez commented 6 years ago

Method GELF::Notifier.stringify_keys mutates its arguments which leads to mutating of arguments of the #notify invocations.

This behaviour is unsafe, and tbh not necessary, because the method returns processed hash, that could be a new object.

Previous behavior:

data = { foo: { bar: "BAZ" } }

n = GELF::Notifier.new("localhost", 12201)
n.notify!(:short_message => "foo", :full_message => "something here\n\nbacktrace?!", data)

data # => { "foo" => { "bar" => "BAZ" } } # keys are stringified in the source hash

The new one:

data = { foo: { bar: "BAZ" } }

n = GELF::Notifier.new("localhost", 12201)
n.notify!(:short_message => "foo", :full_message => "something here\n\nbacktrace?!", data)

data # => { foo: { bar: "BAZ" } } # the source hash not changed
CLAassistant commented 6 years ago

CLA assistant check
All committers have signed the CLA.