deliverer 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +128 -0
- data/Rakefile +2 -0
- data/deliverer.gemspec +17 -0
- data/lib/deliverer.rb +17 -0
- data/lib/deliverer/ansi/afm.rb +28 -0
- data/lib/deliverer/ansi/ansi-deliverer.rb +38 -0
- data/lib/deliverer/unicode/ufm.rb +28 -0
- data/lib/deliverer/unicode/unicode-deliverer.rb +52 -0
- data/lib/deliverer/version.rb +3 -0
- metadata +58 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Ronalt_X
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
# Deliverer
|
2
|
+
|
3
|
+
Any a web application needs the input filter.This gem help you protect your creature from
|
4
|
+
XSS atacks and uncensored user communication (case web-application is forum).Differently
|
5
|
+
it is your Deliverer from many,many problems..
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'deliverer'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install deliverer
|
20
|
+
|
21
|
+
## Methods
|
22
|
+
|
23
|
+
### Forbid
|
24
|
+
|
25
|
+
<pre>
|
26
|
+
Delete all selected words in filtering text. Just write them in function arguments.
|
27
|
+
(U may write so many argumentes as you need ) Every entrance every argumentes wil be deleted
|
28
|
+
</pre>
|
29
|
+
|
30
|
+
*Want learn more?* See Usage -> Example_2
|
31
|
+
|
32
|
+
### Censor
|
33
|
+
|
34
|
+
<pre>
|
35
|
+
Replaces all selected words in filtering text 1st argument is word replaces 2nd,3rd etc argumentes
|
36
|
+
in text (U may write so many argumentes as you need ) And every entrance every argumentes(except 1st)
|
37
|
+
wil be replaced on value 1st argument. for example 1st argument may be - " [censored] " or
|
38
|
+
"[Observe censorship] " or " (-_-) " or just "".
|
39
|
+
</pre>
|
40
|
+
|
41
|
+
*Want learn more?* See Usage -> Example_2
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
1.Example:
|
46
|
+
|
47
|
+
x - censor var
|
48
|
+
|
49
|
+
<pre>
|
50
|
+
x.filter
|
51
|
+
</pre>
|
52
|
+
|
53
|
+
*Congratulation! Henceforth you protect from XSS*
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
2.Example:
|
58
|
+
|
59
|
+
|
60
|
+
`if you want to filter user communication on your forum just `
|
61
|
+
`give block for last method and use functions forbid and censor in it.`
|
62
|
+
|
63
|
+
<pre>
|
64
|
+
x.filter do |check|
|
65
|
+
check.forbid " fuck "," pecker "
|
66
|
+
check.censor "[censored]"," dick "
|
67
|
+
end
|
68
|
+
</pre>
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
3.Example:
|
75
|
+
|
76
|
+
|
77
|
+
You may use one methods several times in block to code look normal.
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
>It is ugly,isn`t it?
|
83
|
+
|
84
|
+
<pre>
|
85
|
+
x.filter do |v|
|
86
|
+
v.censor "\[censored\]"," dick "," any not correct word "," any curse "," fucking admin ",
|
87
|
+
" 2nd not correct word "," 2 curse "," 3rd curse "
|
88
|
+
end
|
89
|
+
</pre>
|
90
|
+
|
91
|
+
|
92
|
+
>More better
|
93
|
+
|
94
|
+
<pre>
|
95
|
+
x.filter do
|
96
|
+
censor "\[censored\]"," dick "," any not correct word "
|
97
|
+
censor "\[censored\]"," any curse "," fucking admin "
|
98
|
+
censor "\[censored\]"," 2nd not correct word "," 2 curse "
|
99
|
+
censor "\[censored\]"," 3rd curse "
|
100
|
+
end`
|
101
|
+
</pre>
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
*P.S.* It would be beter if you`ll write forbid words beetwin spaces becourse it may be appear as part a normal word
|
107
|
+
I mean:
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
1.\- y r dick!
|
112
|
+
|
113
|
+
2.\- in dicken`s cafe at 7pm
|
114
|
+
|
115
|
+
\*\*after filtering(in example)\*\*
|
116
|
+
|
117
|
+
1.\- y r [censored]!
|
118
|
+
|
119
|
+
2.\- in [censored]en`s cafe at 7 pm
|
120
|
+
|
121
|
+
|
122
|
+
## Contributing
|
123
|
+
|
124
|
+
1. Fork it
|
125
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
126
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
127
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
128
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/deliverer.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/deliverer/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Ronalt_X"]
|
6
|
+
gem.email = ["ronaltx@gmail.com"]
|
7
|
+
gem.description = %q{A web application need a input filter.This gem protect your app from XSS atacks and flood.Differently It exempt you from many,many problems..) }
|
8
|
+
gem.summary = %q{Filter,XSS,Flood}
|
9
|
+
gem.homepage = "http://www.google.com"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "deliverer"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Deliverer::VERSION
|
17
|
+
end
|
data/lib/deliverer.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#coding: utf-8
|
2
|
+
|
3
|
+
require_relative 'deliverer/version'
|
4
|
+
require_relative 'deliverer/unicode/unicode-deliverer'
|
5
|
+
require_relative 'deliverer/ansi/ansi-deliverer'
|
6
|
+
|
7
|
+
|
8
|
+
module Deliverer
|
9
|
+
include Unic_Deliverer
|
10
|
+
include Ansi_Deliverer
|
11
|
+
end
|
12
|
+
|
13
|
+
class String
|
14
|
+
include Deliverer
|
15
|
+
end
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
module Ansi_Deliverer
|
3
|
+
|
4
|
+
public
|
5
|
+
|
6
|
+
def forbid(*to_dest)
|
7
|
+
to_dest.each do |dest|
|
8
|
+
@@desc.gsub!(dest,"")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def censor(censored,*found)
|
13
|
+
found.each do |dest|
|
14
|
+
@@desc.gsub!(dest,censored)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
class Object
|
22
|
+
include Ansi_Deliverer
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative 'afm'
|
2
|
+
|
3
|
+
|
4
|
+
module Ansi_Deliverer
|
5
|
+
|
6
|
+
private
|
7
|
+
@@desc = 0
|
8
|
+
|
9
|
+
def std_protection(unprt)
|
10
|
+
|
11
|
+
unprt.gsub!('&','&')
|
12
|
+
unprt.gsub!('<','<')
|
13
|
+
unprt.gsub!('>','>')
|
14
|
+
unprt.gsub!('"','"')
|
15
|
+
unprt.gsub!('javascript:','JS:')
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
public
|
20
|
+
|
21
|
+
def filter &block
|
22
|
+
@@desc = self
|
23
|
+
unless block_given?
|
24
|
+
std_protection(@@desc)
|
25
|
+
else
|
26
|
+
yield()
|
27
|
+
std_protection(@@desc)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#coding: utf-8
|
2
|
+
|
3
|
+
module Unic_Deliverer
|
4
|
+
|
5
|
+
public
|
6
|
+
|
7
|
+
def unic_forbid(*to_dest)
|
8
|
+
to_dest.each do |dest|
|
9
|
+
@@s.gsub!(dest,"")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def unic_censor(censored,*found)
|
14
|
+
found.each do |dest|
|
15
|
+
@@s.gsub!(dest,censored)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
class Object
|
22
|
+
include Unic_Deliverer
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#coding: utf-8
|
2
|
+
|
3
|
+
require_relative 'ufm'
|
4
|
+
|
5
|
+
|
6
|
+
module Unic_Deliverer
|
7
|
+
|
8
|
+
private
|
9
|
+
@@s = 0
|
10
|
+
def unic_std_protection(unprt)
|
11
|
+
|
12
|
+
unprt.gsub!('&','&')
|
13
|
+
unprt.gsub!('<','<')
|
14
|
+
unprt.gsub!('>','>')
|
15
|
+
unprt.gsub!('"','"')
|
16
|
+
unprt.gsub!('javascript:','JS:')
|
17
|
+
unprt.gsub!('©','©')
|
18
|
+
unprt.gsub!('®','®')
|
19
|
+
unprt.gsub!('—','—')
|
20
|
+
unprt.gsub!('–','–')
|
21
|
+
unprt.gsub!('“','“')
|
22
|
+
unprt.gsub!('«','«')
|
23
|
+
unprt.gsub!('‘','‘')
|
24
|
+
unprt.gsub!('…','…')
|
25
|
+
unprt.gsub!(' ',' ')
|
26
|
+
unprt.gsub!('”','”')
|
27
|
+
unprt.gsub!('»','»')
|
28
|
+
unprt.gsub!('’','’')
|
29
|
+
unprt.gsub!('€','€')
|
30
|
+
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
public
|
35
|
+
|
36
|
+
def unic_filter &block
|
37
|
+
@@s = self
|
38
|
+
unless block_given?
|
39
|
+
unic_std_protection(@@s)
|
40
|
+
else
|
41
|
+
yield()
|
42
|
+
unic_std_protection(@@s)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: deliverer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ronalt_X
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-08 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! 'A web application need a input filter.This gem protect your app from
|
15
|
+
XSS atacks and flood.Differently It exempt you from many,many problems..) '
|
16
|
+
email:
|
17
|
+
- ronaltx@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- LICENSE
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- deliverer.gemspec
|
28
|
+
- lib/deliverer.rb
|
29
|
+
- lib/deliverer/ansi/afm.rb
|
30
|
+
- lib/deliverer/ansi/ansi-deliverer.rb
|
31
|
+
- lib/deliverer/unicode/ufm.rb
|
32
|
+
- lib/deliverer/unicode/unicode-deliverer.rb
|
33
|
+
- lib/deliverer/version.rb
|
34
|
+
homepage: http://www.google.com
|
35
|
+
licenses: []
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.8.24
|
55
|
+
signing_key:
|
56
|
+
specification_version: 3
|
57
|
+
summary: Filter,XSS,Flood
|
58
|
+
test_files: []
|