despamilator 0.2
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/History.txt +4 -0
- data/Manifest.txt +44 -0
- data/PostInstall.txt +1 -0
- data/README.rdoc +107 -0
- data/Rakefile +33 -0
- data/despamilator.gemspec +42 -0
- data/lib/despamilator/filter/html_tags.rb +116 -0
- data/lib/despamilator/filter/naughty_q.rb +17 -0
- data/lib/despamilator/filter/numbers_and_words.rb +33 -0
- data/lib/despamilator/filter/script_tag.rb +13 -0
- data/lib/despamilator/filter.rb +52 -0
- data/lib/despamilator/filter_base.rb +37 -0
- data/lib/despamilator.rb +19 -0
- data/pkg/despamilator-0.1/History.txt +4 -0
- data/pkg/despamilator-0.1/Manifest.txt +21 -0
- data/pkg/despamilator-0.1/PostInstall.txt +1 -0
- data/pkg/despamilator-0.1/README.rdoc +107 -0
- data/pkg/despamilator-0.1/Rakefile +33 -0
- data/pkg/despamilator-0.1/despamilator.gemspec +42 -0
- data/pkg/despamilator-0.1/lib/despamilator/filter/html_tags.rb +116 -0
- data/pkg/despamilator-0.1/lib/despamilator/filter/naughty_q.rb +17 -0
- data/pkg/despamilator-0.1/lib/despamilator/filter/numbers_and_words.rb +33 -0
- data/pkg/despamilator-0.1/lib/despamilator/filter/script_tag.rb +13 -0
- data/pkg/despamilator-0.1/lib/despamilator/filter.rb +52 -0
- data/pkg/despamilator-0.1/lib/despamilator/filter_base.rb +37 -0
- data/pkg/despamilator-0.1/lib/despamilator.rb +19 -0
- data/pkg/despamilator-0.1/spec/despamilator_spec.rb +15 -0
- data/pkg/despamilator-0.1/spec/filters/html_tags_spec.rb +144 -0
- data/pkg/despamilator-0.1/spec/filters/naughty_q_spec.rb +39 -0
- data/pkg/despamilator-0.1/spec/filters/numbers_and_words_spec.rb +59 -0
- data/pkg/despamilator-0.1/spec/filters/script_tag_spec.rb +32 -0
- data/pkg/despamilator-0.1/spec/spec.opts +1 -0
- data/pkg/despamilator-0.1/spec/spec_helper.rb +10 -0
- data/pkg/despamilator-0.1/tasks/rspec.rake +21 -0
- data/pkg/despamilator-0.1.gem +0 -0
- data/pkg/despamilator-0.1.tgz +0 -0
- data/spec/despamilator_spec.rb +15 -0
- data/spec/filters/html_tags_spec.rb +144 -0
- data/spec/filters/naughty_q_spec.rb +39 -0
- data/spec/filters/numbers_and_words_spec.rb +59 -0
- data/spec/filters/script_tag_spec.rb +32 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/rspec.rake +21 -0
- metadata +155 -0
Binary file
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe Despamilator do
|
4
|
+
before :each do
|
5
|
+
@dspam = Despamilator.new('this text is absolutely fine')
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return a zero score for fine text" do
|
9
|
+
@dspam.score.should == 0
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return no matching filter for fine text" do
|
13
|
+
@dspam.matched_by.should be_empty
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
context "HtmlTags" do
|
4
|
+
describe "filtering" do
|
5
|
+
[
|
6
|
+
'!--',
|
7
|
+
'!DOCTYPE',
|
8
|
+
'a',
|
9
|
+
'abbr',
|
10
|
+
'acronym',
|
11
|
+
'address',
|
12
|
+
'applet',
|
13
|
+
'area',
|
14
|
+
'b',
|
15
|
+
'base',
|
16
|
+
'basefont',
|
17
|
+
'bdo',
|
18
|
+
'big',
|
19
|
+
'blockquote',
|
20
|
+
'body',
|
21
|
+
'br',
|
22
|
+
'button',
|
23
|
+
'caption',
|
24
|
+
'center',
|
25
|
+
'cite',
|
26
|
+
'code',
|
27
|
+
'col',
|
28
|
+
'colgroup',
|
29
|
+
'dd',
|
30
|
+
'del',
|
31
|
+
'dfn',
|
32
|
+
'dir',
|
33
|
+
'div',
|
34
|
+
'dl',
|
35
|
+
'dt',
|
36
|
+
'em',
|
37
|
+
'fieldset',
|
38
|
+
'font',
|
39
|
+
'form',
|
40
|
+
'frame',
|
41
|
+
'frameset',
|
42
|
+
'h1',
|
43
|
+
'h2',
|
44
|
+
'h3',
|
45
|
+
'h4',
|
46
|
+
'h5',
|
47
|
+
'h6',
|
48
|
+
'head',
|
49
|
+
'hr',
|
50
|
+
'html',
|
51
|
+
'i',
|
52
|
+
'iframe',
|
53
|
+
'img',
|
54
|
+
'input',
|
55
|
+
'ins',
|
56
|
+
'isindex',
|
57
|
+
'kbd',
|
58
|
+
'label',
|
59
|
+
'legend',
|
60
|
+
'li',
|
61
|
+
'link',
|
62
|
+
'map',
|
63
|
+
'menu',
|
64
|
+
'meta',
|
65
|
+
'noframes',
|
66
|
+
'noscript',
|
67
|
+
'object',
|
68
|
+
'ol',
|
69
|
+
'optgroup',
|
70
|
+
'option',
|
71
|
+
'p',
|
72
|
+
'param',
|
73
|
+
'pre',
|
74
|
+
'q',
|
75
|
+
's',
|
76
|
+
'samp',
|
77
|
+
'select',
|
78
|
+
'small',
|
79
|
+
'span',
|
80
|
+
'strike',
|
81
|
+
'strong',
|
82
|
+
'style',
|
83
|
+
'sub',
|
84
|
+
'sup',
|
85
|
+
'table',
|
86
|
+
'tbody',
|
87
|
+
'td',
|
88
|
+
'textarea',
|
89
|
+
'tfoot',
|
90
|
+
'th',
|
91
|
+
'thead',
|
92
|
+
'title',
|
93
|
+
'tr',
|
94
|
+
'tt',
|
95
|
+
'u',
|
96
|
+
'ul',
|
97
|
+
'var',
|
98
|
+
'xmp'
|
99
|
+
].each do |script_tag|
|
100
|
+
[script_tag.upcase, script_tag.downcase].each do |script_tag|
|
101
|
+
[
|
102
|
+
"<#{script_tag}",
|
103
|
+
"#{script_tag}/>",
|
104
|
+
"<#{script_tag}/>",
|
105
|
+
"< #{script_tag} ",
|
106
|
+
"#{script_tag} />",
|
107
|
+
"<\n#{script_tag}\n/>",
|
108
|
+
"<\n#{script_tag} ",
|
109
|
+
"#{script_tag}\n/>",
|
110
|
+
"<\r#{script_tag}\r/>"
|
111
|
+
].each do |script_tag|
|
112
|
+
it "should detect '#{script_tag}'" do
|
113
|
+
dspam = Despamilator.new(script_tag)
|
114
|
+
dspam.score.should == 0.3
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe 'attributes' do
|
121
|
+
before :all do
|
122
|
+
@dspam = Despamilator.new('<xmp>').matched_by.first
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should have a name" do
|
126
|
+
@dspam.name.should == 'Detects HTML tags in text'
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should have a description" do
|
130
|
+
@dspam.description.should == 'Searches for various HTML tags'
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should have a filename" do
|
134
|
+
@dspam.filename.should == 'html_tags.rb'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe 'bug fixes' do
|
139
|
+
it "should detect an h1" do
|
140
|
+
Despamilator.new('<h1>TITLE!!</h1>').score.should == 0.3
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe "NaughtyQ" do
|
4
|
+
it "should return a score for 1 misplaced q" do
|
5
|
+
dspam = Despamilator.new('qtu')
|
6
|
+
dspam.score.should == 0.2
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'attributes' do
|
10
|
+
before :each do
|
11
|
+
@filter = Despamilator.new('qtqt').matched_by.first
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have a filename" do
|
15
|
+
@filter.filename.should == 'naughty_q.rb'
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have a name" do
|
19
|
+
@filter.name.should == 'Naughty Q'
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have a description" do
|
23
|
+
@filter.description.should == 'Detects possible misuse of the letter Q (English language)'
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have a number of matches" do
|
27
|
+
@filter.matches.should == 2
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have a score" do
|
31
|
+
@filter.score.should == 0.4
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should score more for 3 misplaced q's" do
|
36
|
+
dspam = Despamilator.new('qtuqsq')
|
37
|
+
dspam.score.to_s.should == 0.4.to_s
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe "NumbersAndWords" do
|
4
|
+
[1, 4, 10, 100000, '1,000,000', '1st', '2nd', '3rd', '4th', '5th', '6th', '10th', '122nd'].each do |number|
|
5
|
+
it "should return a blank for a #{number}" do
|
6
|
+
dspam = Despamilator.new(number)
|
7
|
+
dspam.score.should == 0
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
['wanga x5 mool', '4ghk', 'XTHL9'].each do |string|
|
12
|
+
it "should detect suspicious number word combos such as #{string}" do
|
13
|
+
dspam = Despamilator.new(string)
|
14
|
+
dspam.score.should == 0.1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
['4wanga x5 mool', '4g6hk', 'XT7HL9', '77th8nd'].each do |string|
|
19
|
+
it "should detect multiple suspicious number word combos such as #{string}" do
|
20
|
+
dspam = Despamilator.new(string)
|
21
|
+
dspam.score.should == 0.2
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
[1, 2, 3, 4, 5, 6].each do |tag_no|
|
26
|
+
header_tag = "h#{tag_no}"
|
27
|
+
|
28
|
+
it "should ignore html header tag #{header_tag}" do
|
29
|
+
dspam = Despamilator.new(header_tag)
|
30
|
+
dspam.score.should == 0
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'attributes' do
|
35
|
+
before :each do
|
36
|
+
@filter = Despamilator.new('X5T').matched_by.first
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have a filename" do
|
40
|
+
@filter.filename.should == 'numbers_and_words.rb'
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should have a name" do
|
44
|
+
@filter.name.should == 'Numbers next to words'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should have a description" do
|
48
|
+
@filter.description.should == 'Detects unusual number/word combinations'
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should have a number of matches" do
|
52
|
+
@filter.matches.should == 1
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should have a score" do
|
56
|
+
@filter.score.should == 0.1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
context "ScriptTag" do
|
4
|
+
describe "detecting various script tags" do
|
5
|
+
['<script type="whatever">', '<script></script>', '</script>', '<script>', "<script\n>"].each do |script_tag|
|
6
|
+
[script_tag.upcase, script_tag.downcase].each do |script_tag|
|
7
|
+
it "should detect '#{script_tag}' of a script tag" do
|
8
|
+
dspam = Despamilator.new(script_tag)
|
9
|
+
dspam.score.should == 1
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'attributes' do
|
16
|
+
before :all do
|
17
|
+
@dspam = Despamilator.new('<script>').matched_by.first
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have a name" do
|
21
|
+
@dspam.name.should == 'Detects script tags in text'
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have a description" do
|
25
|
+
@dspam.description.should == 'Searches for variations for the HTML script tag'
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should have a filename" do
|
29
|
+
@dspam.filename.should == 'script_tag.rb'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: despamilator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
version: "0.2"
|
9
|
+
platform: ruby
|
10
|
+
authors:
|
11
|
+
- Stephen Hardisty
|
12
|
+
autorequire:
|
13
|
+
bindir: bin
|
14
|
+
cert_chain: []
|
15
|
+
|
16
|
+
date: 2010-03-28 00:00:00 +11:00
|
17
|
+
default_executable:
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
20
|
+
name: rubyforge
|
21
|
+
prerelease: false
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
segments:
|
27
|
+
- 2
|
28
|
+
- 0
|
29
|
+
- 3
|
30
|
+
version: 2.0.3
|
31
|
+
type: :development
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: gemcutter
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 0
|
42
|
+
- 5
|
43
|
+
- 0
|
44
|
+
version: 0.5.0
|
45
|
+
type: :development
|
46
|
+
version_requirements: *id002
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: hoe
|
49
|
+
prerelease: false
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 2
|
56
|
+
- 5
|
57
|
+
- 0
|
58
|
+
version: 2.5.0
|
59
|
+
type: :development
|
60
|
+
version_requirements: *id003
|
61
|
+
description: |-
|
62
|
+
Despamilator is a plugin based spam detector designed for use on your web forms borne out of two annoyances:
|
63
|
+
Spam being submitted in my web forms AND CAPTCHAS being intrusive. Despamilator will apply
|
64
|
+
some commonly used heuristics from the world of anti-spam to help you decide whether your users are human or machine.
|
65
|
+
email:
|
66
|
+
- moowahaha@hotmail.com
|
67
|
+
executables: []
|
68
|
+
|
69
|
+
extensions: []
|
70
|
+
|
71
|
+
extra_rdoc_files:
|
72
|
+
- History.txt
|
73
|
+
- Manifest.txt
|
74
|
+
- PostInstall.txt
|
75
|
+
- pkg/despamilator-0.1/History.txt
|
76
|
+
- pkg/despamilator-0.1/Manifest.txt
|
77
|
+
- pkg/despamilator-0.1/PostInstall.txt
|
78
|
+
files:
|
79
|
+
- History.txt
|
80
|
+
- Manifest.txt
|
81
|
+
- PostInstall.txt
|
82
|
+
- README.rdoc
|
83
|
+
- Rakefile
|
84
|
+
- despamilator.gemspec
|
85
|
+
- lib/despamilator.rb
|
86
|
+
- lib/despamilator/filter.rb
|
87
|
+
- lib/despamilator/filter/html_tags.rb
|
88
|
+
- lib/despamilator/filter/naughty_q.rb
|
89
|
+
- lib/despamilator/filter/numbers_and_words.rb
|
90
|
+
- lib/despamilator/filter/script_tag.rb
|
91
|
+
- lib/despamilator/filter_base.rb
|
92
|
+
- pkg/despamilator-0.1.gem
|
93
|
+
- pkg/despamilator-0.1.tgz
|
94
|
+
- pkg/despamilator-0.1/History.txt
|
95
|
+
- pkg/despamilator-0.1/Manifest.txt
|
96
|
+
- pkg/despamilator-0.1/PostInstall.txt
|
97
|
+
- pkg/despamilator-0.1/README.rdoc
|
98
|
+
- pkg/despamilator-0.1/Rakefile
|
99
|
+
- pkg/despamilator-0.1/despamilator.gemspec
|
100
|
+
- pkg/despamilator-0.1/lib/despamilator.rb
|
101
|
+
- pkg/despamilator-0.1/lib/despamilator/filter.rb
|
102
|
+
- pkg/despamilator-0.1/lib/despamilator/filter/html_tags.rb
|
103
|
+
- pkg/despamilator-0.1/lib/despamilator/filter/naughty_q.rb
|
104
|
+
- pkg/despamilator-0.1/lib/despamilator/filter/numbers_and_words.rb
|
105
|
+
- pkg/despamilator-0.1/lib/despamilator/filter/script_tag.rb
|
106
|
+
- pkg/despamilator-0.1/lib/despamilator/filter_base.rb
|
107
|
+
- pkg/despamilator-0.1/spec/despamilator_spec.rb
|
108
|
+
- pkg/despamilator-0.1/spec/filters/html_tags_spec.rb
|
109
|
+
- pkg/despamilator-0.1/spec/filters/naughty_q_spec.rb
|
110
|
+
- pkg/despamilator-0.1/spec/filters/numbers_and_words_spec.rb
|
111
|
+
- pkg/despamilator-0.1/spec/filters/script_tag_spec.rb
|
112
|
+
- pkg/despamilator-0.1/spec/spec.opts
|
113
|
+
- pkg/despamilator-0.1/spec/spec_helper.rb
|
114
|
+
- pkg/despamilator-0.1/tasks/rspec.rake
|
115
|
+
- spec/despamilator_spec.rb
|
116
|
+
- spec/filters/html_tags_spec.rb
|
117
|
+
- spec/filters/naughty_q_spec.rb
|
118
|
+
- spec/filters/numbers_and_words_spec.rb
|
119
|
+
- spec/filters/script_tag_spec.rb
|
120
|
+
- spec/spec.opts
|
121
|
+
- spec/spec_helper.rb
|
122
|
+
- tasks/rspec.rake
|
123
|
+
has_rdoc: true
|
124
|
+
homepage: http://github.com/moowahaha/despamliator
|
125
|
+
licenses: []
|
126
|
+
|
127
|
+
post_install_message: PostInstall.txt
|
128
|
+
rdoc_options:
|
129
|
+
- --main
|
130
|
+
- README.rdoc
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
segments:
|
138
|
+
- 0
|
139
|
+
version: "0"
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
segments:
|
145
|
+
- 0
|
146
|
+
version: "0"
|
147
|
+
requirements: []
|
148
|
+
|
149
|
+
rubyforge_project: despamilator
|
150
|
+
rubygems_version: 1.3.6
|
151
|
+
signing_key:
|
152
|
+
specification_version: 3
|
153
|
+
summary: "Despamilator is a plugin based spam detector designed for use on your web forms borne out of two annoyances: Spam being submitted in my web forms AND CAPTCHAS being intrusive"
|
154
|
+
test_files: []
|
155
|
+
|