teragrep / lsh_01

logstash-http-input to syslog bridge
https://teragrep.com
Apache License 2.0
0 stars 3 forks source link

Fix more coverity defects #73

Open 51-code opened 3 months ago

51-code commented 3 months ago

Related to #69.

Refactored the code to fix defects reported by Coverity. The list of defects below doesn't tell much if there is no access to Coverity, but the list is there just to give context on what needed fixing. The PR is still merely about refactoring the code to be more secure and clean.

Coverity defects that should be solved by this: 467201 CT: Constructor throws 456623 Dm: Dubious method used 456622 Dm: Dubious method used 456284 Dm: Dubious method used 452921 SS: Unread field should be static (not actually changing to static, but changing it to a local variable) 452920 WMI: Inefficient Map Iterator 452918 Dm: Dubious method used

As you can see, 4 of them are "Dubious method used". These were about using default charsets for example in a FileReader call. I wasn't quite sure with charset to use, but the default for me locally was UTF-8, so I went with that. This is probably going to need input from the architect whether that is correct.

Two defects are not solved, because I think solving them would introduce code that is not in the spirit of Elegant Objects or otherwise weird:

NOTE: The PR includes ConfigTests for the reason that I had to refactor the Exception throwing out of the constructor. I wanted to make sure I didn't break it in the process.