Codebase list facter / e9326d7
(#14467) Warn when removing relative paths Due to changes made to Facter in commit 634f2f6a57b461926afcb2e07dcfe4ed659f5b0c, Facter no longer looks for facts in relative directories for security reasons. This change could result in users not getting all of their facts. This commit alerts users if a relative directory has been excluded from the search path. Due to feedback on this pull request on IRC, change message to be debug instead of warn. Hailee Kenney authored 12 years ago Jeff Weiss committed 12 years ago
3 changed file(s) with 25 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
6060 # This allows others to register additional paths we should search.
6161 result += Facter.search_path
6262
63 result.select { |dir| valid_search_path? dir }
63 result.select do |dir|
64 good = valid_search_path? dir
65 Facter.debugonce("Relative directory #{dir} removed from search path.") unless good
66 good
67 end
6468 end
6569
6670 def valid_search_path?(path)
4343 @@debug = 0
4444 @@timing = 0
4545 @@messages = {}
46 @@debug_messages = {}
4647
4748 # module methods
4849
6768 puts GREEN + string + RESET
6869 end
6970 end
71
72 # Debug once.
73 def self.debugonce(msg)
74 if msg and not msg.empty? and @@debug_messages[msg].nil?
75 @@debug_messages[msg] = true
76 debug(msg)
77 end
78 end
7079
7180 def self.debugging?
7281 @@debug != 0
109109 paths.should be_include(dir)
110110 end
111111 end
112
112
113 it "should warn the user when an invalid search path has been excluded" do
114 dirs = $LOAD_PATH.collect { |d| File.join(d, "facter") }
115 @loader.stubs(:valid_search_path?).returns(false)
116 dirs.each do |dir|
117 Facter.expects(:debugonce).with("Relative directory #{dir} removed from search path.").once
118 end
119 paths = @loader.search_path
120 end
121
122
113123 it "should exclude invalid search paths" do
114124 dirs = $LOAD_PATH.collect { |d| File.join(d, "facter") }
115125 @loader.stubs(:valid_search_path?).returns(false)