phishtank 0.1.0 → 0.1.1
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/ChangeLog.md +10 -0
- data/README.md +6 -4
- data/lib/phishtank.rb +12 -4
- data/lib/phishtank/{data.rb → feed_data.rb} +1 -2
- data/lib/phishtank/{request.rb → feed_request.rb} +1 -3
- data/lib/phishtank/url_request.rb +55 -0
- data/lib/phishtank/version.rb +1 -1
- data/spec/cassettes/invalid_search.yml +65 -0
- data/spec/cassettes/valid_search.yml +71 -0
- data/spec/phishtank/{data_spec.rb → feed_data_spec.rb} +1 -1
- data/spec/phishtank/{request_spec.rb → feed_request_spec.rb} +1 -1
- data/spec/phishtank/url_request_spec.rb +47 -0
- data/spec/phishtank_spec.rb +3 -1
- metadata +17 -9
data/ChangeLog.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# PhishTank
|
2
|
+
## v0.1.1 / 2012-03-13
|
3
|
+
* Rename Request and Data to FeedRequest and FeedData
|
4
|
+
* This breaks semver, so to the none of you that have installed this, my apologies.
|
5
|
+
* Add URL search API interface.
|
6
|
+
|
7
|
+
## v0.1.0 / 2012-03-13
|
8
|
+
* First release!
|
9
|
+
* Basic request handling, update checks, caching, and data parsing.
|
10
|
+
* Specs
|
data/README.md
CHANGED
@@ -21,9 +21,9 @@ or w/ Bundler, add the following to the Gemfile.
|
|
21
21
|
c.etag = "ETag" #optional
|
22
22
|
end
|
23
23
|
|
24
|
-
PhishTank.
|
24
|
+
PhishTank.update_feed!
|
25
25
|
|
26
|
-
data = PhishTank::
|
26
|
+
data = PhishTank::FeedData.new
|
27
27
|
|
28
28
|
data.entries.first
|
29
29
|
# => #<OpenStruct:0x1021026f8
|
@@ -41,8 +41,10 @@ or w/ Bundler, add the following to the Gemfile.
|
|
41
41
|
# }
|
42
42
|
#>
|
43
43
|
|
44
|
+
PhishTank.search("http://www.google.com/") #=> false
|
45
|
+
PhishTank.search("http://suspiciousurl.com/") #=> OpenStruct w/ PhishTank details
|
46
|
+
|
44
47
|
Read specs for more details.
|
45
48
|
|
46
49
|
## TODO
|
47
|
-
|
48
|
-
* Add errors for service-specific rate limiting errors
|
50
|
+
You can see and contribute to the list of TODO items in [issues](https://github.com/ezkl/phishtank/issues?sort=created&labels=todo&direction=desc&state=open).
|
data/lib/phishtank.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
+
require 'typhoeus'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
1
4
|
require "phishtank/version"
|
2
5
|
require "phishtank/configuration"
|
3
|
-
require "phishtank/
|
4
|
-
require "phishtank/
|
6
|
+
require "phishtank/feed_request"
|
7
|
+
require "phishtank/feed_data"
|
8
|
+
require "phishtank/url_request"
|
5
9
|
|
6
10
|
module PhishTank
|
7
11
|
BASE_URI = "http://data.phishtank.com"
|
@@ -16,11 +20,15 @@ module PhishTank
|
|
16
20
|
@configuration ||= Configuration.new
|
17
21
|
end
|
18
22
|
|
19
|
-
def self.
|
20
|
-
request =
|
23
|
+
def self.update_feed!
|
24
|
+
request = FeedRequest.new
|
21
25
|
request.get_update if request.update?
|
22
26
|
end
|
23
27
|
|
28
|
+
def self.search(url)
|
29
|
+
URLRequest.new(url).search
|
30
|
+
end
|
31
|
+
|
24
32
|
def self.api_key
|
25
33
|
@configuration.api_key
|
26
34
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module PhishTank
|
4
|
+
class URLRequest
|
5
|
+
attr_reader :url, :doc
|
6
|
+
|
7
|
+
def initialize(url)
|
8
|
+
@url = URI.encode(url)
|
9
|
+
end
|
10
|
+
|
11
|
+
def search
|
12
|
+
response = Typhoeus::Request.post(search_uri, :params => params)
|
13
|
+
parse_response(response.body)
|
14
|
+
|
15
|
+
if in_database?
|
16
|
+
result_data
|
17
|
+
else
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def in_database?
|
23
|
+
in_database = @doc.xpath("/response/results/url0/in_database").text
|
24
|
+
in_database =~ /true/ ? true : false
|
25
|
+
end
|
26
|
+
|
27
|
+
def result_data
|
28
|
+
search_result = @doc.xpath("/response/results/url0")
|
29
|
+
result = OpenStruct.new
|
30
|
+
result.url = search_result.at("url").text
|
31
|
+
result.in_database = true
|
32
|
+
result.phish_id = search_result.at("phish_id").text
|
33
|
+
result.detail_page = search_result.at("phish_detail_page").text
|
34
|
+
result.verified = search_result.at("verified").text
|
35
|
+
result.verified_at = search_result.at("verified_at").text
|
36
|
+
result.valid = search_result.at("valid").text
|
37
|
+
# result.submitted_at = search_result.at("submitted_at").text
|
38
|
+
result
|
39
|
+
end
|
40
|
+
|
41
|
+
def params
|
42
|
+
{ :format => "XML",
|
43
|
+
:app_key => PhishTank.configuration.api_key,
|
44
|
+
:url => @url }
|
45
|
+
end
|
46
|
+
|
47
|
+
def search_uri
|
48
|
+
"http://checkurl.phishtank.com/checkurl/"
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse_response(body)
|
52
|
+
@doc = Nokogiri::XML(body)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/phishtank/version.rb
CHANGED
@@ -0,0 +1,65 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://checkurl.phishtank.com/checkurl/
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: !binary |-
|
14
|
+
T0s=
|
15
|
+
headers:
|
16
|
+
!binary "RGF0ZQ==":
|
17
|
+
- !binary |-
|
18
|
+
V2VkLCAxNCBNYXIgMjAxMiAwMjozNTo0NSBHTVQ=
|
19
|
+
!binary "U2VydmVy":
|
20
|
+
- !binary |-
|
21
|
+
QXBhY2hlLzIuMi45IChEZWJpYW4pIFBIUC81LjIuNi0xK2xlbm55OSB3aXRo
|
22
|
+
IFN1aG9zaW4tUGF0Y2g=
|
23
|
+
!binary "WC1Qb3dlcmVkLUJ5":
|
24
|
+
- !binary |-
|
25
|
+
UEhQLzUuMi42LTErbGVubnk5
|
26
|
+
!binary "WC1SZXF1ZXN0LUxpbWl0LUludGVydmFs":
|
27
|
+
- !binary |-
|
28
|
+
MzAwIFNlY29uZHM=
|
29
|
+
!binary "WC1SZXF1ZXN0LUxpbWl0":
|
30
|
+
- !binary |-
|
31
|
+
MjUw
|
32
|
+
!binary "WC1SZXF1ZXN0LUNvdW50":
|
33
|
+
- !binary |-
|
34
|
+
MQ==
|
35
|
+
!binary "VmFyeQ==":
|
36
|
+
- !binary |-
|
37
|
+
QWNjZXB0LUVuY29kaW5n
|
38
|
+
!binary "Q29udGVudC1FbmNvZGluZw==":
|
39
|
+
- !binary |-
|
40
|
+
Z3ppcA==
|
41
|
+
!binary "Q29udGVudC1MZW5ndGg=":
|
42
|
+
- !binary |-
|
43
|
+
Mjcw
|
44
|
+
!binary "Q29ubmVjdGlvbg==":
|
45
|
+
- !binary |-
|
46
|
+
Y2xvc2U=
|
47
|
+
!binary "Q29udGVudC1UeXBl":
|
48
|
+
- !binary |-
|
49
|
+
dGV4dC94bWw=
|
50
|
+
body:
|
51
|
+
encoding: ASCII-8BIT
|
52
|
+
string: !binary |-
|
53
|
+
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KCTxyZXNw
|
54
|
+
b25zZT4KCQk8bWV0YT4KCQkJPHRpbWVzdGFtcD4yMDEyLTAzLTE0VDAyOjM1
|
55
|
+
OjQ1KzAwOjAwPC90aW1lc3RhbXA+CgkJCTxzZXJ2ZXJpZD5lNTZkZWZjYzwv
|
56
|
+
c2VydmVyaWQ+CgkJCTxyZXF1ZXN0aWQ+MTkyLjE2OC4wLjEwNy40ZjYwMDQw
|
57
|
+
MTM3ODBhNC4yMTIzNDUxMjwvcmVxdWVzdGlkPgoJCTwvbWV0YT4KCQk8cmVz
|
58
|
+
dWx0cz4KCQkJPHVybDA+CgkJCQk8dXJsPjwhW0NEQVRBW2h0dHA6Ly93d3cu
|
59
|
+
Z29vZ2xlLmNvbS8/cT1zZWFyY2ggcXVlcnldXT48L3VybD4KCQkJCTxpbl9k
|
60
|
+
YXRhYmFzZT5mYWxzZTwvaW5fZGF0YWJhc2U+CgkJCTwvdXJsMD4KCQk8L3Jl
|
61
|
+
c3VsdHM+Cgk8L3Jlc3BvbnNlPgo=
|
62
|
+
http_version: !binary |-
|
63
|
+
MS4x
|
64
|
+
recorded_at: Wed, 14 Mar 2012 02:34:06 GMT
|
65
|
+
recorded_with: VCR 2.0.0
|
@@ -0,0 +1,71 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://checkurl.phishtank.com/checkurl/
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: !binary |-
|
14
|
+
T0s=
|
15
|
+
headers:
|
16
|
+
!binary "RGF0ZQ==":
|
17
|
+
- !binary |-
|
18
|
+
V2VkLCAxNCBNYXIgMjAxMiAwMjo0NDoyMyBHTVQ=
|
19
|
+
!binary "U2VydmVy":
|
20
|
+
- !binary |-
|
21
|
+
QXBhY2hlLzIuMi45IChEZWJpYW4pIFBIUC81LjIuNi0xK2xlbm55OSB3aXRo
|
22
|
+
IFN1aG9zaW4tUGF0Y2g=
|
23
|
+
!binary "WC1Qb3dlcmVkLUJ5":
|
24
|
+
- !binary |-
|
25
|
+
UEhQLzUuMi42LTErbGVubnk5
|
26
|
+
!binary "WC1SZXF1ZXN0LUxpbWl0LUludGVydmFs":
|
27
|
+
- !binary |-
|
28
|
+
MzAwIFNlY29uZHM=
|
29
|
+
!binary "WC1SZXF1ZXN0LUxpbWl0":
|
30
|
+
- !binary |-
|
31
|
+
MjUw
|
32
|
+
!binary "WC1SZXF1ZXN0LUNvdW50":
|
33
|
+
- !binary |-
|
34
|
+
MQ==
|
35
|
+
!binary "VmFyeQ==":
|
36
|
+
- !binary |-
|
37
|
+
QWNjZXB0LUVuY29kaW5n
|
38
|
+
!binary "Q29udGVudC1FbmNvZGluZw==":
|
39
|
+
- !binary |-
|
40
|
+
Z3ppcA==
|
41
|
+
!binary "Q29udGVudC1MZW5ndGg=":
|
42
|
+
- !binary |-
|
43
|
+
Mzcx
|
44
|
+
!binary "Q29ubmVjdGlvbg==":
|
45
|
+
- !binary |-
|
46
|
+
Y2xvc2U=
|
47
|
+
!binary "Q29udGVudC1UeXBl":
|
48
|
+
- !binary |-
|
49
|
+
dGV4dC94bWw=
|
50
|
+
body:
|
51
|
+
encoding: ASCII-8BIT
|
52
|
+
string: !binary |-
|
53
|
+
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KCTxyZXNw
|
54
|
+
b25zZT4KCQk8bWV0YT4KCQkJPHRpbWVzdGFtcD4yMDEyLTAzLTE0VDAyOjQ0
|
55
|
+
OjIzKzAwOjAwPC90aW1lc3RhbXA+CgkJCTxzZXJ2ZXJpZD4yZDVjMmNiPC9z
|
56
|
+
ZXJ2ZXJpZD4KCQkJPHJlcXVlc3RpZD4xOTIuMTY4LjAuMTA3LjRmNjAwNjA3
|
57
|
+
ZDBkZjMxLjAxMjQ2MjM1PC9yZXF1ZXN0aWQ+CgkJPC9tZXRhPgoJCTxyZXN1
|
58
|
+
bHRzPgoJCQk8dXJsMD4KCQkJCTx1cmw+PCFbQ0RBVEFbaHR0cDovL3d3dy5n
|
59
|
+
cm92ZXNnYXMuY28udWsvVEFNRmlkZWxpZGFkZS9jbGllbnRldGFtLmh0bV1d
|
60
|
+
PjwvdXJsPgoJCQkJPGluX2RhdGFiYXNlPnRydWU8L2luX2RhdGFiYXNlPgoJ
|
61
|
+
CQkJPHBoaXNoX2lkPjEzODk3NTM8L3BoaXNoX2lkPgoJCQkJPHBoaXNoX2Rl
|
62
|
+
dGFpbF9wYWdlPjwhW0NEQVRBW2h0dHA6Ly93d3cucGhpc2h0YW5rLmNvbS9w
|
63
|
+
aGlzaF9kZXRhaWwucGhwP3BoaXNoX2lkPTEzODk3NTNdXT48L3BoaXNoX2Rl
|
64
|
+
dGFpbF9wYWdlPgoJCQkJPHZlcmlmaWVkPnRydWU8L3ZlcmlmaWVkPgoJCQkJ
|
65
|
+
PHZlcmlmaWVkX2F0PjIwMTItMDMtMTNUMjI6NTE6NDMrMDA6MDA8L3Zlcmlm
|
66
|
+
aWVkX2F0PgoJCQkJPHZhbGlkPnRydWU8L3ZhbGlkPgoJCQk8L3VybDA+CgkJ
|
67
|
+
PC9yZXN1bHRzPgoJPC9yZXNwb25zZT4K
|
68
|
+
http_version: !binary |-
|
69
|
+
MS4x
|
70
|
+
recorded_at: Wed, 14 Mar 2012 02:41:45 GMT
|
71
|
+
recorded_with: VCR 2.0.0
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe PhishTank::URLRequest do
|
4
|
+
subject do
|
5
|
+
PhishTank.configure { |c| c.api_key = API_KEY }
|
6
|
+
described_class.new("http://www.google.com/?q=search query")
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should URI-encode the search URL" do
|
10
|
+
subject.url.should eq "http://www.google.com/?q=search%20query"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have a search URI" do
|
14
|
+
subject.search_uri.should eq "http://checkurl.phishtank.com/checkurl/"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should respond to search" do
|
18
|
+
subject.should respond_to(:search)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#search" do
|
22
|
+
context "valid search", :vcr => { :cassette_name => "valid search" } do
|
23
|
+
subject { described_class.new("http://www.grovesgas.co.uk/TAMFidelidade/clientetam.htm").search }
|
24
|
+
it "should return a struct of data" do
|
25
|
+
subject.should be_kind_of(OpenStruct)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should have a bunch of attributes" do
|
29
|
+
subject.url.should eq "http://www.grovesgas.co.uk/TAMFidelidade/clientetam.htm"
|
30
|
+
subject.in_database.should eq true
|
31
|
+
subject.phish_id.should eq "1389753"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "invalid search", :vcr => { :cassette_name => "invalid search" } do
|
36
|
+
it "should return false" do
|
37
|
+
subject.search.should eq false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#params" do
|
43
|
+
its(:params) { should include(:format => "XML") }
|
44
|
+
its(:params) { should include(:app_key => API_KEY)}
|
45
|
+
its(:params) { should include(:url => "http://www.google.com/?q=search%20query") }
|
46
|
+
end
|
47
|
+
end
|
data/spec/phishtank_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phishtank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- .rspec
|
87
87
|
- .rvmrc
|
88
88
|
- .travis.yml
|
89
|
+
- ChangeLog.md
|
89
90
|
- Gemfile
|
90
91
|
- Guardfile
|
91
92
|
- LICENSE
|
@@ -93,16 +94,20 @@ files:
|
|
93
94
|
- Rakefile
|
94
95
|
- lib/phishtank.rb
|
95
96
|
- lib/phishtank/configuration.rb
|
96
|
-
- lib/phishtank/
|
97
|
-
- lib/phishtank/
|
97
|
+
- lib/phishtank/feed_data.rb
|
98
|
+
- lib/phishtank/feed_request.rb
|
99
|
+
- lib/phishtank/url_request.rb
|
98
100
|
- lib/phishtank/version.rb
|
99
101
|
- phishtank.gemspec
|
102
|
+
- spec/cassettes/invalid_search.yml
|
100
103
|
- spec/cassettes/no_update_needed.yml
|
101
104
|
- spec/cassettes/update_needed.yml
|
105
|
+
- spec/cassettes/valid_search.yml
|
102
106
|
- spec/fixtures/online-valid.xml
|
103
107
|
- spec/phishtank/configuration_spec.rb
|
104
|
-
- spec/phishtank/
|
105
|
-
- spec/phishtank/
|
108
|
+
- spec/phishtank/feed_data_spec.rb
|
109
|
+
- spec/phishtank/feed_request_spec.rb
|
110
|
+
- spec/phishtank/url_request_spec.rb
|
106
111
|
- spec/phishtank_spec.rb
|
107
112
|
- spec/spec_helper.rb
|
108
113
|
homepage: https://github.com/ezkl/phishtank
|
@@ -119,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
124
|
version: '0'
|
120
125
|
segments:
|
121
126
|
- 0
|
122
|
-
hash:
|
127
|
+
hash: -3595057374130271825
|
123
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
129
|
none: false
|
125
130
|
requirements:
|
@@ -128,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
133
|
version: '0'
|
129
134
|
segments:
|
130
135
|
- 0
|
131
|
-
hash:
|
136
|
+
hash: -3595057374130271825
|
132
137
|
requirements: []
|
133
138
|
rubyforge_project:
|
134
139
|
rubygems_version: 1.8.18
|
@@ -137,11 +142,14 @@ specification_version: 3
|
|
137
142
|
summary: Provides a simple interface to work with OpenDNS's PhishTank developer API
|
138
143
|
by handling caching and parsing of PhishTank data.
|
139
144
|
test_files:
|
145
|
+
- spec/cassettes/invalid_search.yml
|
140
146
|
- spec/cassettes/no_update_needed.yml
|
141
147
|
- spec/cassettes/update_needed.yml
|
148
|
+
- spec/cassettes/valid_search.yml
|
142
149
|
- spec/fixtures/online-valid.xml
|
143
150
|
- spec/phishtank/configuration_spec.rb
|
144
|
-
- spec/phishtank/
|
145
|
-
- spec/phishtank/
|
151
|
+
- spec/phishtank/feed_data_spec.rb
|
152
|
+
- spec/phishtank/feed_request_spec.rb
|
153
|
+
- spec/phishtank/url_request_spec.rb
|
146
154
|
- spec/phishtank_spec.rb
|
147
155
|
- spec/spec_helper.rb
|