intrusion 0.1.3 → 0.1.4

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.
data/lib/intrusion.rb CHANGED
@@ -1,59 +1,48 @@
1
1
  module Intrusion
2
2
 
3
- # check if ip is blocked
4
- def ids_is_blocked?(ip)
5
- ids_load.each { |d| return true if d[:ip] == ip and d[:counter] > 9 }
6
- return false
7
- end
3
+ # check if ip is blocked
4
+ def ids_is_blocked?(ip)
5
+ ids_load.each { |d| return true if d[:ip] == ip and d[:counter] > 9 }
6
+ return false
7
+ end
8
8
 
9
- # report suspicious activity
10
- def ids_report!(ip, block=false)
11
- dt = ids_load
12
-
13
- found = nil
14
- dt.each { |d| found = d if d[:ip] == ip }
15
-
16
- if found
17
- if block
18
- found[:counter] = 10
19
- else
20
- found[:counter] += 1
21
- end
22
- else
23
- new = { :ip => ip, :counter => 1 }
24
- dt << new
25
- end
9
+ # report suspicious activity
10
+ def ids_report!(ip, block=false)
11
+ dt = ids_load
12
+ found = false
13
+ dt.each { |d| found = d if d[:ip] == ip }
14
+ if found
15
+ block ? found[:counter] = 10 : found[:counter] += 1
16
+ else
17
+ dt << { :ip => ip, :counter => 1 }
18
+ end
26
19
 
27
- # update
28
- self.ids = dt.to_yaml
29
- return self.save
30
- end
31
-
32
- # reset counter and stay
33
- def ids_unblock!(ip)
34
- dt = ids_load
35
- found = false
36
- dt.each { |d|
37
- if d[:ip] == ip
38
- d[:counter] = 0
39
- found = true
40
- end
41
- }
20
+ # update
21
+ self.ids = dt.to_yaml
22
+ return self.save
23
+ end
42
24
 
43
- if found
44
- # update
45
- self.ids = dt.to_yaml
46
- return self.save
47
- end
48
- return false
25
+ # reset counter and stay
26
+ def ids_unblock!(ip)
27
+ dt = ids_load
28
+ found = false
29
+ dt.each { |d| found = d if d[:ip] == ip }
30
+
31
+ if found
32
+ dt.delete found
33
+
34
+ # update
35
+ self.ids = dt.to_yaml
36
+ return self.save
49
37
  end
38
+ return false
39
+ end
50
40
 
51
- # convert yaml string helper
52
- def ids_load
53
- dt = []
54
- dt = YAML::load(ids) if ids
55
- return dt
56
- end
41
+ # convert yaml string helper
42
+ def ids_load
43
+ dt = []
44
+ dt = YAML::load(ids) if ids
45
+ return dt
46
+ end
57
47
 
58
-
59
- end
48
+ end
metadata CHANGED
@@ -1,95 +1,45 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: intrusion
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 3
9
- version: 0.1.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Simon Wepfer
13
9
  autorequire:
14
10
  bindir: bin
15
- cert_chain:
16
- - |
17
- -----BEGIN CERTIFICATE-----
18
- MIIDKjCCAhKgAwIBAgIBADANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQDDAJzdzEY
19
- MBYGCgmSJomT8ixkARkWCG5ldHNlbnNlMRIwEAYKCZImiZPyLGQBGRYCY2gwHhcN
20
- MTAxMjMwMDEzMjIzWhcNMTExMjMwMDEzMjIzWjA7MQswCQYDVQQDDAJzdzEYMBYG
21
- CgmSJomT8ixkARkWCG5ldHNlbnNlMRIwEAYKCZImiZPyLGQBGRYCY2gwggEiMA0G
22
- CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDQcaHghb4NyoI5/ktDVocH6/T6vIhB
23
- rpxGCid4Ufk0nNJp2EQxzzJD2wpv+hmfndtH1yfA89RqIIBdHXhu/pY3Rs+7Rbuh
24
- KAhMF3Bt0MvYa2cCMOV0WQaS1TF+xu1Ko5JGNIP2YHpcusXdjUflYn/enb1xiyJ0
25
- tGe7au6H+gl55k+sy55KpSqije1sCRGsq001HEOgHMk99FWPglma1LSlHzHunCvr
26
- E0yjmEYQnA0Bz1fK23IPXpg1/JDCicz1JlOx1LQ6EXp/DsJhYvrltqMs0d8pThLz
27
- TK8zp88ciB3Je7ZV9gzCSRZn6eg7YAq3L6OGyCjXVDPeGutZ5A0+uNe5AgMBAAGj
28
- OTA3MAkGA1UdEwQCMAAwHQYDVR0OBBYEFNPOntwPYyIrXaEbpJDbJT3Td9ABMAsG
29
- A1UdDwQEAwIEsDANBgkqhkiG9w0BAQUFAAOCAQEAyKFvBXfbt8Rn/NjT5tObn9gF
30
- XE6YMpQvKFqgtjJsuWyldjpjnbg86YsEnOEW2AtRKjQJvTtuyBvf+jiGpj4TFv2u
31
- Z8lCtkHH7lOlotiqnrBpDn+4OGwHmRupmNbvs5JyWyCohFVEbTBcWuvVW+P7OM9E
32
- eaEOpD9PVJds+gguxxsdaAHafRvcOdVqQ9qpeTrofTwCttMEe6XvBF+HSTZ3IrXK
33
- ljm7jluHlbP28ywmLBUdz8bNLkoLrD77bYW5c8TqqhtgoaBXtG73y8V6WogvVV45
34
- jCYr7DaTo4rUhQrgDmq/JUQYZmAaf73WG6iwQ2Nr68hWCjVTj/wvKLKurgjqkQ==
35
- -----END CERTIFICATE-----
36
-
37
- date: 2010-12-30 00:00:00 +01:00
38
- default_executable:
11
+ cert_chain: []
12
+ date: 2012-07-17 00:00:00.000000000 Z
39
13
  dependencies: []
40
-
41
14
  description: intrusion detection and prevention for rails apps
42
15
  email: sw@netsense.ch
43
16
  executables: []
44
-
45
17
  extensions: []
46
-
47
- extra_rdoc_files:
48
- - README.rdoc
18
+ extra_rdoc_files: []
19
+ files:
49
20
  - lib/intrusion.rb
50
- files:
51
- - Manifest
52
- - README.rdoc
53
- - Rakefile
54
- - lib/intrusion.rb
55
- - intrusion.gemspec
56
- has_rdoc: true
57
- homepage: http://spectify.com
21
+ homepage: http://netsense.ch
58
22
  licenses: []
59
-
60
23
  post_install_message:
61
- rdoc_options:
62
- - --line-numbers
63
- - --inline-source
64
- - --title
65
- - Intrusion
66
- - --main
67
- - README.rdoc
68
- require_paths:
24
+ rdoc_options: []
25
+ require_paths:
69
26
  - lib
70
- required_ruby_version: !ruby/object:Gem::Requirement
27
+ required_ruby_version: !ruby/object:Gem::Requirement
71
28
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- segments:
76
- - 0
77
- version: "0"
78
- required_rubygems_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
34
  none: false
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- segments:
84
- - 1
85
- - 2
86
- version: "1.2"
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
87
39
  requirements: []
88
-
89
- rubyforge_project: intrusion
90
- rubygems_version: 1.3.7
40
+ rubyforge_project:
41
+ rubygems_version: 1.8.15
91
42
  signing_key:
92
43
  specification_version: 3
93
44
  summary: intrusion detection and prevention for rails apps
94
45
  test_files: []
95
-
data/Manifest DELETED
@@ -1,4 +0,0 @@
1
- Manifest
2
- README.rdoc
3
- Rakefile
4
- lib/intrusion.rb
data/README.rdoc DELETED
@@ -1,55 +0,0 @@
1
- = Intrusion
2
-
3
- Intrusion is a gem helping you to detect and prevent intrusion attempts within your ruby on rails application.
4
-
5
- == Installation
6
- Install the gem:
7
- gem install intrusion
8
-
9
- Rails 3: include intrusion in your Gemfile
10
- gem 'intrusion'
11
-
12
- Rails 2: include the gem in config/environment.rb
13
- config.gem "intrusion"
14
-
15
- create a 'ids' attribute for the ActiveRecord model you want to protect and migrate, e.g:
16
-
17
- # rails generate migration add_ids_to_accounts ids:string
18
- # rake db:migrate
19
-
20
- include Intrusion in your model:
21
-
22
- class Account < ActiveRecord::Base
23
- include Intrusion
24
- end
25
-
26
- == Examples:
27
-
28
- === Check if IP adress is blocked
29
- return "your ip is blocked" if Account.find(1).ids_is_blocked?(request.remote_addr)
30
-
31
-
32
- === Report suspicious activity
33
- The internal counter will be increased. If you do this 10 times, blocking will be enabled
34
-
35
- Account.find(1).ids_report!(request.remote_addr)
36
-
37
- === Instantly block ip
38
- Account.find(1).ids_report!(request.remote_addr, true)
39
-
40
- === Reset
41
- This resets the counter to 0:
42
- Account.find(1).ids_unblock!(request.remote_addr)
43
-
44
-
45
- === Blocking objects with keywords
46
- You are not limited to IP adresses. You may block the object itself using any keyword:
47
- Account.find(1).ids_report!('self')
48
-
49
-
50
- == Hint
51
- Try http://spectify.com to scan your servers and applications for vulnerabilities - for free!
52
-
53
- == Copyright
54
-
55
- (c) 2010 -2011 netsense LLC - managed security audits - http://netsense.ch
data/Rakefile DELETED
@@ -1,14 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'echoe'
4
-
5
- Echoe.new('intrusion', '0.1.3') do |p|
6
- p.description = "intrusion detection and prevention for rails apps"
7
- p.url = "http://spectify.com"
8
- p.author = "Simon Wepfer"
9
- p.email = "sw@netsense.ch"
10
- p.ignore_pattern = ["tmp/*", "script/*"]
11
- p.development_dependencies = []
12
- end
13
-
14
- Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
data/intrusion.gemspec DELETED
@@ -1,32 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{intrusion}
5
- s.version = "0.1.3"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Simon Wepfer"]
9
- s.cert_chain = ["/home/sw/gem-public_cert.pem"]
10
- s.date = %q{2010-12-30}
11
- s.description = %q{intrusion detection and prevention for rails apps}
12
- s.email = %q{sw@netsense.ch}
13
- s.extra_rdoc_files = ["README.rdoc", "lib/intrusion.rb"]
14
- s.files = ["Manifest", "README.rdoc", "Rakefile", "lib/intrusion.rb", "intrusion.gemspec"]
15
- s.homepage = %q{http://spectify.com}
16
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Intrusion", "--main", "README.rdoc"]
17
- s.require_paths = ["lib"]
18
- s.rubyforge_project = %q{intrusion}
19
- s.rubygems_version = %q{1.3.7}
20
- s.signing_key = %q{/home/sw/gem-private_key.pem}
21
- s.summary = %q{intrusion detection and prevention for rails apps}
22
-
23
- if s.respond_to? :specification_version then
24
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
- s.specification_version = 3
26
-
27
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
28
- else
29
- end
30
- else
31
- end
32
- end
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
Binary file