login_attack_report 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c84dbee098b60e3f36fe5817ea823f35ae78384
4
- data.tar.gz: 0768bdf44ec1f936f31e1dbc6dbf3587f4a40461
3
+ metadata.gz: 50fb79257560920c395c4dd4601307ec6830e65d
4
+ data.tar.gz: 45ed6e2f496da28277109484f7cbfa1cad78632c
5
5
  SHA512:
6
- metadata.gz: 627e90342d48447d920b8796afd8a13aa05dd849c56a43146b5a47768f7d3816459a60e740d4001c90cf646bb81643f44bf93f0cb29e2e1ea832008247bf106a
7
- data.tar.gz: 738e90ffd92db5072a383a4d4dfaeda7f89f3a536652c1336d185d175226dc78ad6acaed99eda127c2124ed9074fa24b8329ef7ec856af190d610a2bbf0f09a5
6
+ metadata.gz: 61efa806137b58d78779386550e02dcf3a316e915fa89a3b2e53ad32bba7f5ca74b9e140ea5fec13253aca6e401a7cd60b4a473619655ada13bffc387f326fd1
7
+ data.tar.gz: efb87ec42dd59bb604750422f14bad0953d3fbd8c17f7ba680680474702b568e5e952bf512cdf4ac60dd9e1423d3ff1dddfdf080759c6eaa5bb7da0e210cd185
data/README.md CHANGED
@@ -52,22 +52,27 @@ end
52
52
  前月のログイン成功回数のlimitを超えたユーザを抽出します。
53
53
  ※ 異常に多い場合、どこかでID/パスワードが漏れている、もしくはIDが共有されている可能性あり
54
54
  ```ruby
55
- # @return ActiveRecord::Relation::ActiveRecord_Relation_PaperTrail_Version
55
+ example:
56
+ # @return ActiveRecord::Relation::ActiveRecord_Relation_PaperTrail_Version. 'attack_count' you can confirm the number of attacks.
56
57
  LoginAttackReport::LARVersion.login_ok_limit_over(:User)
58
+
59
+ LoginAttackReport::LARVersion.login_ok_limit_over(:User).first.attack_count
57
60
  ```
58
61
 
59
62
 
60
63
  前月のログイン失敗回数のlimitを超えたユーザを抽出します。
61
64
  ※ 異常に多い場合、リスト型攻撃を受けている可能性あり
62
65
  ```ruby
63
- # @return ActiveRecord::Relation::ActiveRecord_Relation_PaperTrail_Version
66
+ example:
67
+ # @return ActiveRecord::Relation::ActiveRecord_Relation_PaperTrail_Version. 'attack_count' you can confirm the number of attacks.
64
68
  LoginAttackReport::LARVersion.login_ng_limit_over(:User)
65
69
  ```
66
70
 
67
71
 
68
- (未実装)前月のログイン元同一ipのlimitを超えたIPアドレスの一覧を抽出します。
72
+ 前月のログイン元同一ipのlimitを超えたIPアドレスの一覧を抽出します。
69
73
  ※ 同一ipでログイン失敗回数が多かったら、攻撃されている可能性あり
70
74
  ```ruby
75
+ example:
71
76
  # @return Hash IPs list {ip: count, ...}
72
77
  LoginAttackReport::LARVersion.ip_limit_over(:User)
73
78
  ```
@@ -7,26 +7,28 @@ module LoginAttackReport
7
7
  module ClassMethods
8
8
  def login_ok_limit_over(model)
9
9
  PaperTrail::Version
10
- .where(item_type: model)
10
+ .where(item_type: model) \
11
11
  .where(
12
- 'created_at >= ? and created_at <= ? and '\
13
- 'object_changes like \'%sign_in_count:%\'',
14
- Time.now.prev_month.beginning_of_month,
15
- Time.now.prev_month.end_of_month
16
- ).group(:item_id).having('count(item_id) > ?', LoginAttackReport.login_ok_limit)
12
+ 'created_at >= ? and created_at <= ? and ' \
13
+ + 'object_changes like \'%sign_in_count:%\'' \
14
+ , Time.now.prev_month.beginning_of_month \
15
+ , Time.now.prev_month.end_of_month
16
+ ).select('versions.*, count(item_id) as attack_count') \
17
+ .group(:item_id).having('count(item_id) > ?', LoginAttackReport.login_ok_limit)
17
18
  end
18
19
 
19
20
  def login_ng_limit_over(model)
20
21
  PaperTrail::Version
21
22
  .where(item_type: model)
22
23
  .where(
23
- 'created_at >= ? and created_at <= ? and '\
24
- 'object_changes not like \'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfailed_attempts:\n- _\n- 0%\' and '\
25
- 'object_changes not like \'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfailed_attempts:\n- __\n- 0%\' and '\
26
- 'object_changes like \'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfailed_attempts:%\'',
27
- Time.now.prev_month.beginning_of_month,
28
- Time.now.prev_month.end_of_month
29
- ).group(:item_id).having('count(item_id) > ?', LoginAttackReport.login_ng_limit)
24
+ 'created_at >= ? and created_at <= ? and ' \
25
+ + 'object_changes not like \'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfailed_attempts:\n- _\n- 0%\' and ' \
26
+ + 'object_changes not like \'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfailed_attempts:\n- __\n- 0%\' and ' \
27
+ + 'object_changes like \'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfailed_attempts:%\'' \
28
+ , Time.now.prev_month.beginning_of_month \
29
+ , Time.now.prev_month.end_of_month
30
+ ).select('versions.*, count(item_id) as attack_count') \
31
+ .group(:item_id).having('count(item_id) > ?', LoginAttackReport.login_ng_limit)
30
32
  end
31
33
 
32
34
  def ip_limit_over(model)
@@ -35,10 +37,10 @@ module LoginAttackReport
35
37
  .where(item_type: model)
36
38
  .where(
37
39
  'created_at >= ? and created_at <= ? and '\
38
- '(object_changes not like \'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfailed_attempts:\n- _\n- 0%\' and '\
39
- 'object_changes not like \'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfailed_attempts:\n- __\n- 0%\' and '\
40
- 'object_changes like \'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfailed_attempts:%\''\
41
- ')',
40
+ + '(object_changes not like \'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfailed_attempts:\n- _\n- 0%\' and '\
41
+ + 'object_changes not like \'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfailed_attempts:\n- __\n- 0%\' and '\
42
+ + 'object_changes like \'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfailed_attempts:%\''\
43
+ + ')',
42
44
  Time.now.prev_month.beginning_of_month,
43
45
  Time.now.prev_month.end_of_month
44
46
  )
@@ -1,3 +1,3 @@
1
1
  module LoginAttackReport
2
- VERSION = '0.2.2'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: login_attack_report
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - taru m
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-01 00:00:00.000000000 Z
11
+ date: 2015-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -195,3 +195,4 @@ summary: login attack report in Rails.
195
195
  test_files:
196
196
  - spec/login_attack_report_spec.rb
197
197
  - spec/spec_helper.rb
198
+ has_rdoc: