Skip to content

Commit 570b5e8

Browse files
floriquadule
authored andcommitted
Avoid passsing possible user input directly into the shell. Instead quote the `image_path` value before calling the `convert` command. See here http://rubysec.com/advisories/CVE-2015-7541/ for more information.
1 parent d589ce0 commit 570b5e8

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/colorscore/histogram.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
require "shellwords"
2+
13
module Colorscore
24
class Histogram
35
def initialize(image_path, colors=16, depth=8)
4-
output = `convert #{image_path} -resize 400x400 -format %c -dither None -quantize YIQ -colors #{colors} -depth #{depth} histogram:info:-`
6+
output = `convert #{image_path.shellescape} -resize 400x400 -format %c -dither None -quantize YIQ -colors #{colors.to_i} -depth #{depth.to_i} histogram:info:-`
57
@lines = output.lines.sort.reverse.map(&:strip).reject(&:empty?)
68
end
79

0 commit comments

Comments
 (0)