Please review pull request #207: (#14467) Warn when removing relative paths opened by (hkenney)

Description:

Due to changes made to Facter in commit
634f2f6, 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.

  • Opened: Mon May 14 20:46:03 UTC 2012
  • Based on: puppetlabs:master (634f2f6a57b461926afcb2e07dcfe4ed659f5b0c)
  • Requested merge: hkenney:ticket/master/14467_warn_when_removing_relative_paths (73693516cc397d71301cf0abe14864b3c9f9e696)

Diff follows:

diff --git a/lib/facter/util/loader.rb b/lib/facter/util/loader.rb
index 13266d8..6b50f73 100644
--- a/lib/facter/util/loader.rb
+++ b/lib/facter/util/loader.rb
@@ -61,7 +61,11 @@ def search_path
     # This allows others to register additional paths we should search.
     result += Facter.search_path
 
-    result.select { |dir| valid_search_path? dir }
+    result.select do |dir|
+      good = valid_search_path? dir
+      Facter.warnonce("Relative directory #{dir} removed from search path.") unless good
+      good
+    end
   end
   
   def valid_search_path?(path)
diff --git a/spec/unit/util/loader_spec.rb b/spec/unit/util/loader_spec.rb
index 9bc6154..7803bea 100755
--- a/spec/unit/util/loader_spec.rb
+++ b/spec/unit/util/loader_spec.rb
@@ -19,6 +19,7 @@ def load_file(file)
 describe Facter::Util::Loader do
   before :each do
     Facter::Util::Loader.any_instance.unstub(:load_all)
+    Facter.stubs(:warnonce)
   end
 
   it "should have a method for loading individual facts by name" do
@@ -110,7 +111,17 @@ def load_file(file)
         paths.should be_include(dir)
       end
     end
-    
+
+    it "should warn the user when an invalid search path has been excluded" do 
+      dirs = $LOAD_PATH.collect { |d| File.join(d, "facter") }
+      @loader.stubs(:valid_search_path?).returns(false)
+      dirs.each do |dir|
+        Facter.expects(:warnonce).with("Relative directory #{dir} removed from search path.").once
+      end 
+      paths = @loader.search_path
+    end 
+
+
     it "should exclude invalid search paths" do
       dirs = $LOAD_PATH.collect { |d| File.join(d, "facter") }
       @loader.stubs(:valid_search_path?).returns(false)

    

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to