mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
This commit updates the dashboard to use `URI.parse` instead of `Kernel#open` because open can potentially open files on the server and has other possible security issues. Also updated the logger to use `File.open` as it is more explicit and doesn't have the extra potential for abuse like `Kernel#open` https://rubocop.readthedocs.io/en/latest/cops_security/#securityopen
24 lines
449 B
Ruby
24 lines
449 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rubygems' unless defined?(Gem)
|
|
|
|
module Vmpooler
|
|
class Logger
|
|
def initialize(
|
|
f = '/var/log/vmpooler.log'
|
|
)
|
|
@file = f
|
|
end
|
|
|
|
def log(_level, string)
|
|
time = Time.new
|
|
stamp = time.strftime('%Y-%m-%d %H:%M:%S')
|
|
|
|
puts "[#{stamp}] #{string}" if ENV['VMPOOLER_DEBUG']
|
|
|
|
File.open(@file, 'a') do |f|
|
|
f.puts "[#{stamp}] #{string}"
|
|
end
|
|
end
|
|
end
|
|
end
|