site-inspector 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/site-inspector/dns.rb +1 -1
- data/lib/site-inspector/headers.rb +3 -3
- data/lib/site-inspector/sniffer.rb +2 -1
- data/lib/site-inspector.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 081857089e6dd0832b6fd0553615c02c74ba271b
|
4
|
+
data.tar.gz: aaa19892e68cf24c05898e44e2314413976819a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 613c90276d90b35a8d74502893f6d4bf2579c84f4f399c34c7ee33c3722f92af29e12796d7c733a8503903e63eb85e49f940379ca40d41c55ce1aa5660437181
|
7
|
+
data.tar.gz: 6ddf58171d7c76d8a0f5b029b94878a76e1b68b3becb6dc6c48b972389c9c94e48f5e7ff56ad52b3b00dab8b02aa6620c083920dbe97e2228de6d513ad52c8d1
|
data/lib/site-inspector/dns.rb
CHANGED
@@ -24,7 +24,7 @@ class SiteInspector
|
|
24
24
|
|
25
25
|
def detect_by_hostname(type)
|
26
26
|
|
27
|
-
haystack = load_data(type)
|
27
|
+
haystack = SiteInspector.load_data(type)
|
28
28
|
needle = haystack.find { |name, domain|
|
29
29
|
cnames.any? { |cname|
|
30
30
|
domain == cname.tld || domain == "#{cname.sld}.#{cname.tld}"
|
@@ -46,14 +46,14 @@ class SiteInspector
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def secure_cookies?
|
49
|
-
return
|
49
|
+
return false if !has_cookies?
|
50
50
|
cookie = headers["set-cookie"]
|
51
51
|
cookie = cookie.first if cookie.is_a?(Array)
|
52
52
|
!!(cookie =~ /(; secure.*; httponly|; httponly.*; secure)/i)
|
53
53
|
end
|
54
54
|
|
55
|
-
# Returns an array of hashes of downcased key/value header pairs (or
|
55
|
+
# Returns an array of hashes of downcased key/value header pairs (or an empty hash)
|
56
56
|
def headers
|
57
|
-
@headers ||= Hash[response.headers.map{ |k,v| [k.downcase,v] }]
|
57
|
+
@headers ||= response ? Hash[response.headers.map{ |k,v| [k.downcase,v] }] : {}
|
58
58
|
end
|
59
59
|
end
|
@@ -3,6 +3,8 @@ class SiteInspector
|
|
3
3
|
results = Sniffles.sniff(body, type).select { |name, meta| meta[:found] == true }
|
4
4
|
results.each { |name, result| result.delete :found} if results
|
5
5
|
results
|
6
|
+
rescue
|
7
|
+
nil
|
6
8
|
end
|
7
9
|
|
8
10
|
def cms
|
@@ -20,5 +22,4 @@ class SiteInspector
|
|
20
22
|
def advertising
|
21
23
|
sniff :advertising
|
22
24
|
end
|
23
|
-
|
24
25
|
end
|
data/lib/site-inspector.rb
CHANGED
@@ -21,6 +21,10 @@ Typhoeus::Config.cache = SiteInspectorCache.new
|
|
21
21
|
|
22
22
|
class SiteInspector
|
23
23
|
|
24
|
+
def self.load_data(name)
|
25
|
+
YAML.load_file File.expand_path "./data/#{name}.yml", File.dirname(__FILE__)
|
26
|
+
end
|
27
|
+
|
24
28
|
def initialize(domain)
|
25
29
|
domain = domain.downcase
|
26
30
|
domain = domain.sub /^https?\:/, ""
|
@@ -46,7 +50,7 @@ class SiteInspector
|
|
46
50
|
end
|
47
51
|
|
48
52
|
def request(ssl=false, www=false, followlocation=true)
|
49
|
-
Typhoeus
|
53
|
+
Typhoeus.get(uri(ssl, www), followlocation: followlocation, timeout: 10)
|
50
54
|
end
|
51
55
|
|
52
56
|
def response
|
@@ -75,10 +79,6 @@ class SiteInspector
|
|
75
79
|
doc.to_s.force_encoding("UTF-8").encode("UTF-8", :invalid => :replace, :replace => "")
|
76
80
|
end
|
77
81
|
|
78
|
-
def load_data(name)
|
79
|
-
YAML.load_file File.expand_path "./data/#{name}.yml", File.dirname(__FILE__)
|
80
|
-
end
|
81
|
-
|
82
82
|
def government?
|
83
83
|
Gman.valid? domain.to_s
|
84
84
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: site-inspector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|