Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
9533bf2c66 | |||
c4bde860e2 | |||
415f7c9d24 | |||
707b115428 | |||
15ea3a4f67 | |||
a7e59ef5c8 |
@ -1,4 +1,5 @@
|
|||||||
Copyright (c) 2010 Charles Max Wood chuck@teachmetocode.com
|
Copyright (c) 2010 Charles Max Wood chuck@teachmetocode.com
|
||||||
|
Copyright (c) 2013 Guillaume DOTT guillaume+github@dott.fr
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
Permission is hereby granted, free of charge, to any person
|
||||||
obtaining a copy of this software and associated documentation
|
obtaining a copy of this software and associated documentation
|
||||||
|
5
Rakefile
Normal file
5
Rakefile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
require 'rspec/core/rake_task'
|
||||||
|
|
||||||
|
RSpec::Core::RakeTask.new(:spec)
|
||||||
|
|
||||||
|
task :default => :spec
|
@ -1,6 +1,7 @@
|
|||||||
require 'net/dns'
|
require 'net/dns'
|
||||||
require "project_honeypot/url"
|
require "project_honeypot/url"
|
||||||
require "project_honeypot/base"
|
require "project_honeypot/base"
|
||||||
|
require "project_honeypot/rack"
|
||||||
require "project_honeypot/rack/header"
|
require "project_honeypot/rack/header"
|
||||||
require "project_honeypot/rack/forbidden"
|
require "project_honeypot/rack/forbidden"
|
||||||
|
|
||||||
|
10
lib/project_honeypot/rack.rb
Normal file
10
lib/project_honeypot/rack.rb
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
module ProjectHoneypot
|
||||||
|
class Rack
|
||||||
|
def initialize(app, options={})
|
||||||
|
@app = app
|
||||||
|
|
||||||
|
raise ArgumentError, 'Must specify an API key' unless options[:api_key]
|
||||||
|
ProjectHoneypot.api_key = options[:api_key]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -1,12 +1,6 @@
|
|||||||
module ProjectHoneypot::Rack
|
module ProjectHoneypot
|
||||||
class Forbidden
|
class Rack
|
||||||
def initialize(app, options={})
|
class Forbidden < Rack
|
||||||
@app = app
|
|
||||||
|
|
||||||
raise ArgumentError, 'Must specify an API key' unless options[:api_key]
|
|
||||||
ProjectHoneypot.api_key = options[:api_key]
|
|
||||||
end
|
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
request = ::Rack::Request.new(env)
|
request = ::Rack::Request.new(env)
|
||||||
url = ProjectHoneypot.lookup(request.ip)
|
url = ProjectHoneypot.lookup(request.ip)
|
||||||
@ -18,4 +12,5 @@ module ProjectHoneypot::Rack
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
module ProjectHoneypot::Rack
|
module ProjectHoneypot
|
||||||
class Header
|
class Rack
|
||||||
def initialize(app, options={})
|
class Header < Rack
|
||||||
@app = app
|
|
||||||
|
|
||||||
raise ArgumentError, 'Must specify an API key' unless options[:api_key]
|
|
||||||
ProjectHoneypot.api_key = options[:api_key]
|
|
||||||
end
|
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
request = ::Rack::Request.new(env)
|
request = ::Rack::Request.new(env)
|
||||||
url = ProjectHoneypot.lookup(request.ip)
|
url = ProjectHoneypot.lookup(request.ip)
|
||||||
@ -16,4 +10,5 @@ module ProjectHoneypot::Rack
|
|||||||
@app.call(request.env)
|
@app.call(request.env)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
module ProjectHoneypot
|
module ProjectHoneypot
|
||||||
VERSION = "0.3.0"
|
VERSION = "0.3.1"
|
||||||
end
|
end
|
||||||
|
@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|||||||
s.email = ["chuck@teachmetocode.com", "guillaume+github@dott.fr"]
|
s.email = ["chuck@teachmetocode.com", "guillaume+github@dott.fr"]
|
||||||
s.summary = %q{Project-Honeypot provides a programatic interface to the Project Honeypot services.}
|
s.summary = %q{Project-Honeypot provides a programatic interface to the Project Honeypot services.}
|
||||||
s.description = %q{Project-Honeypot provides a programatic interface to the Project Honeypot services. It can be used to identify spammers, bogus commenters, and harvesters. You will need a FREE api key from http://projecthoneypot.org}
|
s.description = %q{Project-Honeypot provides a programatic interface to the Project Honeypot services. It can be used to identify spammers, bogus commenters, and harvesters. You will need a FREE api key from http://projecthoneypot.org}
|
||||||
s.homepage = ""
|
s.homepage = "https://github.com/gdott9/project_honeypot"
|
||||||
|
|
||||||
s.files = `git ls-files`.split($/)
|
s.files = `git ls-files`.split($/)
|
||||||
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
||||||
|
@ -9,9 +9,10 @@ describe ProjectHoneypot::Base do
|
|||||||
|
|
||||||
it "returns a Url object" do
|
it "returns a Url object" do
|
||||||
url = base.lookup("127.10.10.5")
|
url = base.lookup("127.10.10.5")
|
||||||
url.should be_a ProjectHoneypot::Url
|
|
||||||
url.last_activity.should == 1
|
expect(url).to be_a(ProjectHoneypot::Url)
|
||||||
url.score.should == 63
|
expect(url.last_activity).to eq(1)
|
||||||
|
expect(url.score).to eq(63)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "looks up non-ip addresses" do
|
it "looks up non-ip addresses" do
|
||||||
|
@ -5,37 +5,37 @@ describe ProjectHoneypot::Url do
|
|||||||
let(:url) { ProjectHoneypot::Url.new("127.0.0.1", "127.1.63.3") }
|
let(:url) { ProjectHoneypot::Url.new("127.0.0.1", "127.1.63.3") }
|
||||||
|
|
||||||
it "is safe" do
|
it "is safe" do
|
||||||
url.should_not be_safe
|
expect(url.safe?).to be false
|
||||||
|
|
||||||
url.safe?(score: 63).should be_false
|
expect(url.safe?(score: 63)).to be false
|
||||||
url.safe?(score: 64).should be_true
|
expect(url.safe?(score: 64)).to be true
|
||||||
|
|
||||||
url.safe?(last_activity: 1).should be_false
|
expect(url.safe?(last_activity: 1)).to be false
|
||||||
url.safe?(last_activity: 2).should be_true
|
expect(url.safe?(last_activity: 2)).to be true
|
||||||
|
|
||||||
url.safe?(last_activity: 2, score: 64).should be_true
|
expect(url.safe?(last_activity: 2, score: 64)).to be true
|
||||||
url.safe?(last_activity: 1, score: 64).should be_false
|
expect(url.safe?(last_activity: 1, score: 64)).to be false
|
||||||
url.safe?(last_activity: 2, score: 63).should be_false
|
expect(url.safe?(last_activity: 2, score: 63)).to be false
|
||||||
|
|
||||||
url.safe?(offenses: [:comment_spammer]).should be_true
|
expect(url.safe?(offenses: [:comment_spammer])).to be true
|
||||||
url.safe?(offenses: [:suspicious, :comment_spammer]).should be_false
|
expect(url.safe?(offenses: [:suspicious, :comment_spammer])).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it "has the correct latest activity" do
|
it "has the correct latest activity" do
|
||||||
url.last_activity.should == 1
|
expect(url.last_activity).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "has the correct score" do
|
it "has the correct score" do
|
||||||
url.score.should == 63
|
expect(url.score).to eq(63)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "has the correct offenses" do
|
it "has the correct offenses" do
|
||||||
url.offenses.should include(:suspicious)
|
expect(url.offenses).to include(:suspicious)
|
||||||
url.offenses.should include(:harvester)
|
expect(url.offenses).to include(:harvester)
|
||||||
url.offenses.should_not include(:comment_spammer)
|
expect(url.offenses).to_not include(:comment_spammer)
|
||||||
url.should be_suspicious
|
expect(url).to be_suspicious
|
||||||
url.should be_harvester
|
expect(url).to be_harvester
|
||||||
url.should_not be_comment_spammer
|
expect(url).to_not be_comment_spammer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user