]> git.openstreetmap.org Git - chef.git/commitdiff
Add Time to whitelist of classes to load for YAML.safe_load
authorMatt Amos <zerebubuth@gmail.com>
Sun, 5 Feb 2017 19:11:56 +0000 (19:11 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 5 Feb 2017 19:18:59 +0000 (19:18 +0000)
The update to ruby 2.3.1 pulls in a different version of the YAML / Psych code which doesn't allow the Time class to be loaded in `safe_load`, unlike the previous version. This change whitelists Time, and appears to solve the problem. Since `state.yaml` files are not loaded from the internet, and rarely hand-edited, then this seems like an okay thing to whitelist.

cookbooks/planet/files/default/replication-bin/replicate-changesets

index 8c943902a8e91ad7d2869e9e8eb8182b429f7949..a5312e1e6d52344e755f304790a1f1fd604f0375 100644 (file)
@@ -142,7 +142,7 @@ end
 class Replicator
   def initialize(config)
     @config = YAML.safe_load(File.read(config))
-    @state = YAML.safe_load(File.read(@config["state_file"]))
+    @state = YAML.safe_load(File.read(@config["state_file"]), [Time])
     @conn = PGconn.connect(@config["db"])
     # get current time from the database rather than the current system
     @now = @conn.exec("select now() as now").map { |row| Time.parse(row["now"]) }[0]