def mime_type
filetype = Open3.capture2("/usr/bin/file", "-Lbz", trace_name).first.chomp
- gzipped = filetype =~ /gzip compressed/
- bzipped = filetype =~ /bzip2 compressed/
- zipped = filetype =~ /Zip archive/
- tarred = filetype =~ /tar archive/
+ gzipped = filetype.include?("gzip compressed")
+ bzipped = filetype.include?("bzip2 compressed")
+ zipped = filetype.include?("Zip archive")
+ tarred = filetype.include?("tar archive")
mimetype = if gzipped
"application/x-gzip"
def extension_name
filetype = Open3.capture2("/usr/bin/file", "-Lbz", trace_name).first.chomp
- gzipped = filetype =~ /gzip compressed/
- bzipped = filetype =~ /bzip2 compressed/
- zipped = filetype =~ /Zip archive/
- tarred = filetype =~ /tar archive/
+ gzipped = filetype.include?("gzip compressed")
+ bzipped = filetype.include?("bzip2 compressed")
+ zipped = filetype.include?("Zip archive")
+ tarred = filetype.include?("tar archive")
extension = if tarred && gzipped
".tar.gz"
def xml_file
filetype = Open3.capture2("/usr/bin/file", "-Lbz", trace_name).first.chomp
- gzipped = filetype =~ /gzip compressed/
- bzipped = filetype =~ /bzip2 compressed/
- zipped = filetype =~ /Zip archive/
- tarred = filetype =~ /tar archive/
+ gzipped = filetype.include?("gzip compressed")
+ bzipped = filetype.include?("bzip2 compressed")
+ zipped = filetype.include?("Zip archive")
+ tarred = filetype.include?("tar archive")
if gzipped || bzipped || zipped || tarred
file = Tempfile.new("trace.#{id}")
def self.check(hash, salt, candidate)
if salt.nil?
candidate = Digest::MD5.hexdigest(candidate)
- elsif salt.match?(/!/)
+ elsif salt.include?("!")
algorithm, iterations, salt = salt.split("!")
size = Base64.strict_decode64(hash).length
candidate = self.hash(candidate, salt, iterations.to_i, size, algorithm)
def self.upgrade?(hash, salt)
if salt.nil?
return true
- elsif salt.match?(/!/)
+ elsif salt.include?("!")
algorithm, iterations, salt = salt.split("!")
return true if Base64.strict_decode64(salt).length != SALT_BYTE_SIZE
return true if Base64.strict_decode64(hash).length != HASH_BYTE_SIZE