sensu-plugins / sensu-plugin

A framework for writing Sensu plugins & handlers with Ruby.
http://sensuapp.org
MIT License
126 stars 117 forks source link

[utils] only read from ENV['SENSU_LOADED_TEMPFILE'] if the file exists #158

Closed cwjohnston closed 7 years ago

cwjohnston commented 7 years ago

Description

This change adds a condition to the config_files method, ensuring that the file described by ENV['SENSU_LOADED_TEMPFILE'] exists on disk before attempting to read from that file.

This change is proposed as an alternative to #115, as that PR includes additional logic which I believe will never work as intended.

Motivation and Context

Because the value of ENV['SENSU_LOADED_TEMPFILE'] may point to a file under /tmp or another temporary directory, we should avoid errors by validating that a file exists at that path before trying to read from it.

Closes #115

How Has This Been Tested?

Existing tests pass.

Types of changes

None.