intrusion 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/intrusion.rb +52 -52
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d6151639617a3b7284f48de675227ab59c8150b42b8134f697ebc8328b997984
|
4
|
+
data.tar.gz: 7ca22d37ccf3c3bf0acbea7d18515a4933c173b458d950c9e5cb975a19765529
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9fe80409942f12b85c4f2234550568b7d6a83b8b69ac4f8a60ec48dab59c98f8f58b7beb68cd40ef6b7dd3be804e0efb1aa659debde26a0e2dea5dc417f046f
|
7
|
+
data.tar.gz: 874aecd912cf2217d4c776393eae257c9e9debf75b24bbec577b51e6dfe8aec3186ce569c338717ff06cd5aad252c95669e60e1b3868b1fbd37162a320347a7c
|
data/lib/intrusion.rb
CHANGED
@@ -1,52 +1,52 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# check if ip is blocked
|
4
|
-
def ids_is_blocked?(
|
5
|
-
ids_load.each
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
dt = []
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
1
|
+
# Intrusion main module
|
2
|
+
module Intrusion
|
3
|
+
# check if ip is blocked
|
4
|
+
def ids_is_blocked?(address)
|
5
|
+
ids_load.each do |d|
|
6
|
+
return true if d[:ip] == address && d[:counter] > 9
|
7
|
+
end
|
8
|
+
false
|
9
|
+
end
|
10
|
+
|
11
|
+
# return block counter of address
|
12
|
+
def ids_counter(address)
|
13
|
+
ids_load.each { |d| return d[:counter] if d[:ip] == address }
|
14
|
+
0
|
15
|
+
end
|
16
|
+
|
17
|
+
# report suspicious activity
|
18
|
+
def ids_report!(address, block = false)
|
19
|
+
dt = ids_load
|
20
|
+
found = nil
|
21
|
+
dt.each { |d| found = d if d[:ip] == address }
|
22
|
+
if found
|
23
|
+
block ? found[:counter] = 10 : found[:counter] += 1
|
24
|
+
else
|
25
|
+
dt << { ip: address, counter: block ? 10 : 1 }
|
26
|
+
end
|
27
|
+
|
28
|
+
# update record
|
29
|
+
update_attributes(ids: dt.to_yaml)
|
30
|
+
end
|
31
|
+
|
32
|
+
# reset counter and stay
|
33
|
+
def ids_unblock!(address)
|
34
|
+
dt = ids_load
|
35
|
+
found = false
|
36
|
+
dt.each { |d| found = d if d[:ip] == address }
|
37
|
+
|
38
|
+
if found
|
39
|
+
dt.delete(found)
|
40
|
+
# update
|
41
|
+
return update_attributes(ids: dt.to_yaml)
|
42
|
+
end
|
43
|
+
false
|
44
|
+
end
|
45
|
+
|
46
|
+
# convert yaml string helper
|
47
|
+
def ids_load
|
48
|
+
dt = ids.blank? ? [] : YAML.load(ids, Intrusion) rescue []
|
49
|
+
dt = [] unless dt.class == Array
|
50
|
+
dt
|
51
|
+
end
|
52
|
+
end
|
metadata
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intrusion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Simon
|
7
|
+
- Simon Duncombe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
|
15
|
-
email:
|
13
|
+
description: Intrusion is a gem helping you to block objects for IP addresses within
|
14
|
+
your Ruby on Rails Application.
|
15
|
+
email: sd@netsense.ch
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- lib/intrusion.rb
|
21
|
-
homepage: http://
|
21
|
+
homepage: http://github.com/symontech/intrusion
|
22
22
|
licenses: []
|
23
23
|
metadata: {}
|
24
24
|
post_install_message:
|
@@ -37,8 +37,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
37
|
version: '0'
|
38
38
|
requirements: []
|
39
39
|
rubyforge_project:
|
40
|
-
rubygems_version: 2.
|
40
|
+
rubygems_version: 2.7.3
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
|
-
summary: intrusion detection and prevention for rails
|
43
|
+
summary: intrusion detection and prevention for rails applications
|
44
44
|
test_files: []
|