1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2025-11-30 21:32:30 +00:00

refactor: switch to use SecureRandom for random strings

هذا الالتزام موجود في:
Adam Cooke
2024-03-04 17:33:25 +00:00
الأصل cae4b63599
التزام ce30c070bd
6 ملفات معدلة مع 6 إضافات و8 حذوفات

عرض الملف

@@ -327,7 +327,7 @@ module Postal
time = Time.now.to_f - start_time
logger.debug " \e[4;34mMessageDB Query (#{time.round(2)}s) \e[0m \e[33m#{query}\e[0m"
if time > 0.05 && query =~ /\A(SELECT|UPDATE|DELETE) /
id = Nifty::Utils::RandomString.generate(length: 6).upcase
id = SecureRandom.alphanumeric(8)
explain_result = ResultForExplainPrinter.new(connection.query("EXPLAIN #{query}"))
logger.info " [#{id}] EXPLAIN #{query}"
ActiveRecord::ConnectionAdapters::MySQL::ExplainPrettyPrinter.new.pp(explain_result, time).split("\n").each do |line|

عرض الملف

@@ -488,7 +488,7 @@ module Postal
#
def create_link(url)
hash = Digest::SHA1.hexdigest(url.to_s)
token = Nifty::Utils::RandomString.generate(length: 8)
token = SecureRandom.alphanumeric(16)
database.insert(:links, { message_id: id, hash: hash, url: url, timestamp: Time.now.to_f, token: token })
token
end
@@ -585,7 +585,7 @@ module Postal
def _create(queue: true)
self.timestamp = Time.now.to_f if timestamp.blank?
self.status = "Pending" if status.blank?
self.token = Nifty::Utils::RandomString.generate(length: 12) if token.blank?
self.token = SecureRandom.alphanumeric(16) if token.blank?
last_id = @database.insert("messages", @attributes.except(:id))
@attributes["id"] = last_id
@database.statistics.increment_all(timestamp, scope)