repsheet_visualizer 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- repsheet_visualizer (0.0.8)
4
+ repsheet_visualizer (0.1.3)
5
5
  geoip
6
6
  json
7
7
  redis
@@ -47,25 +47,42 @@ class RepsheetVisualizer < Sinatra::Base
47
47
  suspects = {}
48
48
  blacklisted = {}
49
49
 
50
- connection.keys("*:requests").map {|d| d.split(":").first}.reject {|ip| ip.empty?}.each do |actor|
51
- detected = connection.smembers("#{actor}:detected").join(", ")
52
- blacklist = connection.get("#{actor}:repsheet:blacklist")
53
-
54
- if !detected.empty? && blacklist != "true"
50
+ if connection.exists("offenders")
51
+ connection.zrevrangebyscore("offenders", "+inf", "0").each do |actor|
55
52
  suspects[actor] = Hash.new 0
56
- suspects[actor][:detected] = detected
57
- connection.smembers("#{actor}:detected").each do |rule|
58
- suspects[actor][:total] += connection.get("#{actor}:#{rule}:count").to_i
59
- end
53
+ suspects[actor][:detected] = connection.smembers("#{actor}:detected").join(", ")
54
+ suspects[actor][:total] = connection.zscore("offenders", actor)
60
55
  end
61
56
 
62
- if blacklist == "true"
57
+ connection.keys("*:*:blacklist").map {|d| d.split(":").first}.reject {|ip| ip.empty?}.each do |actor|
58
+ connection.get("#{actor}:repsheet:blacklist") == "true"
63
59
  blacklisted[actor] = Hash.new 0
64
- blacklisted[actor][:detected] = detected
60
+ blacklisted[actor][:detected] = connection.smembers("#{actor}:detected").join(", ")
65
61
  connection.smembers("#{actor}:detected").each do |rule|
66
62
  blacklisted[actor][:total] += connection.get("#{actor}:#{rule}:count").to_i
67
63
  end
68
64
  end
65
+ else
66
+ connection.keys("*:requests").map {|d| d.split(":").first}.reject {|ip| ip.empty?}.each do |actor|
67
+ detected = connection.smembers("#{actor}:detected").join(", ")
68
+ blacklist = connection.get("#{actor}:repsheet:blacklist")
69
+
70
+ if !detected.empty? && blacklist != "true"
71
+ suspects[actor] = Hash.new 0
72
+ suspects[actor][:detected] = detected
73
+ connection.smembers("#{actor}:detected").each do |rule|
74
+ suspects[actor][:total] += connection.get("#{actor}:#{rule}:count").to_i
75
+ end
76
+ end
77
+
78
+ if blacklist == "true"
79
+ blacklisted[actor] = Hash.new 0
80
+ blacklisted[actor][:detected] = detected
81
+ connection.smembers("#{actor}:detected").each do |rule|
82
+ blacklisted[actor][:total] += connection.get("#{actor}:#{rule}:count").to_i
83
+ end
84
+ end
85
+ end
69
86
  end
70
87
 
71
88
  [suspects.sort_by{|k,v| -v[:total]}.take(10), blacklisted]
@@ -1,3 +1,3 @@
1
1
  module RepsheetVisualizer
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repsheet_visualizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-14 00:00:00.000000000 Z
12
+ date: 2013-06-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: geoip