lib/mini_profiler/storage/redis_store.rb in rack-mini-profiler-2.3.3 vs lib/mini_profiler/storage/redis_store.rb in rack-mini-profiler-2.3.4

- old
+ new

@@ -23,11 +23,13 @@ def load(id) key = prefixed_id(id) raw = redis.get key begin - Marshal::load(raw) if raw + # rubocop:disable Security/MarshalLoad + Marshal.load(raw) if raw + # rubocop:enable Security/MarshalLoad rescue # bad format, junk old data redis.del key nil end @@ -175,11 +177,13 @@ ) break if ids.size == 0 batch = redis.mapped_hmget(hash_key, *ids).to_a batch.map! do |id, bytes| begin + # rubocop:disable Security/MarshalLoad Marshal.load(bytes) + # rubocop:enable Security/MarshalLoad rescue corrupt_snapshots << id nil end end @@ -187,26 +191,28 @@ blk.call(batch) if batch.size != 0 break if ids.size < batch_size iteration += 1 end if corrupt_snapshots.size > 0 - redis.pipelined do - redis.zrem(zset_key, corrupt_snapshots) - redis.hdel(hash_key, corrupt_snapshots) + redis.pipelined do |pipeline| + pipeline.zrem(zset_key, corrupt_snapshots) + pipeline.hdel(hash_key, corrupt_snapshots) end end end def load_snapshot(id) hash_key = snapshot_hash_key() bytes = redis.hget(hash_key, id) begin + # rubocop:disable Security/MarshalLoad Marshal.load(bytes) + # rubocop:enable Security/MarshalLoad rescue - redis.pipelined do - redis.zrem(snapshot_zset_key(), id) - redis.hdel(hash_key, id) + redis.pipelined do |pipeline| + pipeline.zrem(snapshot_zset_key(), id) + pipeline.hdel(hash_key, id) end nil end end @@ -251,14 +257,14 @@ end end # only used in tests def wipe_snapshots_data - redis.pipelined do - redis.del(snapshot_counter_key()) - redis.del(snapshot_zset_key()) - redis.del(snapshot_hash_key()) - end + redis.del( + snapshot_counter_key(), + snapshot_zset_key(), + snapshot_hash_key(), + ) end end end end