fushin 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a3216a5de562191b2da4ac160930ebe75bb67015ff575a973ebbfdfe7b40bbc
4
- data.tar.gz: a86b9615c22f44519bafb165fd4503b16c4cab05be70789bb3fdf3a8ade5a113
3
+ metadata.gz: eaed16618a5b214257cde6a34a750b61786c40adcddca7ebb8bb80b3e91014ce
4
+ data.tar.gz: c7593de893e79d23c042e03026902e04152552d0db79cbf63daba199d8567940
5
5
  SHA512:
6
- metadata.gz: 5e05122ab0d685cb9f6e3bb3c793c822f23752620f11027912fd298d5302d8a019d9117124f8d8cd4b53e20afb1c3c0a0153f26d17f3131a631bf1ac16a67359
7
- data.tar.gz: 731890e6307ff91e1a7a5d6d6c4b22085f6e28e1bad95de9591ec6fcb68a164a4b32d960a1fa9dc1d931788a47bbdc067038adc7b28d5f48add940ebca1e6de2
6
+ metadata.gz: 45db8c8062c76b474eef6d7d0c80554fc402ef320df9fbd4645d64f982ad178a6d853b79fafdda01d63b0399228cbf65dadef8948de53b2fdcefb8bff304209a
7
+ data.tar.gz: e17eca676c394e5900baa609641de46e6c8033b3b3ccf2c8d9257678982717082a5b51eb66672586bdf933c8c4e55a513bc4c49be46524d473373716a3ba4a5b
@@ -25,12 +25,12 @@ module Fushin
25
25
  "https://urlscan.io/domain/#{domain}"
26
26
  end
27
27
 
28
- def url_for_vt
29
- uri.path.empty? ? "#{url}/" : url
28
+ def normalized_url
29
+ @normalized_url ||= uri.path.empty? ? "#{url}/" : url
30
30
  end
31
31
 
32
32
  def vt_link
33
- "https://www.virustotal.com/#/url/#{Digest::SHA256.hexdigest(url_for_vt)}"
33
+ "https://www.virustotal.com/#/url/#{Digest::SHA256.hexdigest(normalized_url)}"
34
34
  end
35
35
 
36
36
  def to_attachements
@@ -14,7 +14,6 @@ module Fushin
14
14
  attachements = [].tap do |out|
15
15
  out << item.post.btcs.map(&:to_attachements)
16
16
  out << item.post.urls.map(&:to_attachements)
17
- out << item.post.links.map(&:to_attachements)
18
17
  out << item.post.attachements.map(&:to_attachements)
19
18
  end.flatten
20
19
  attachements << { text: "IoC is not found." } if attachements.empty?
@@ -28,33 +28,26 @@ module Fushin
28
28
  end.first
29
29
  end
30
30
 
31
- def main_text
32
- @main_text ||= [].tap do |out|
33
- detection = CharlockHolmes::EncodingDetector.detect(main.text)
34
- out << CharlockHolmes::Converter.convert(main.text, detection[:encoding], "UTF-8")
35
- end.first
36
- end
37
-
38
31
  def btcs
39
- @btcs ||= main_text.scan(/\b[13][a-km-zA-HJ-NP-Z0-9]{26,33}\b/).uniq.map do |address|
32
+ @btcs ||= main.text.scan(/\b[13][a-km-zA-HJ-NP-Z0-9]{26,33}\b/).uniq.map do |address|
40
33
  Models::BTC.new(address)
41
34
  end
42
35
  end
43
36
 
44
37
  def urls
45
- @urls ||= main_text.scan(UrlRegex.get(scheme_required: true, mode: :parsing)).uniq.map do |url|
38
+ @urls ||= (urls_in_text + links).uniq.map do |url|
46
39
  next if whitelisted_domain?(url)
47
40
 
48
41
  Models::Website.new(url)
49
- end.compact
42
+ end.compact.uniq(&:normalized_url)
50
43
  end
51
44
 
52
- def links
53
- @links ||= main.css("a").map { |a| a.get("href") }.compact.uniq.map do |url|
54
- next if whitelisted_domain?(url)
45
+ def urls_in_text
46
+ @urls_in_text ||= main.text.scan(UrlRegex.get(scheme_required: true, mode: :parsing))
47
+ end
55
48
 
56
- Models::Website.new(url)
57
- end.compact
49
+ def links
50
+ @links ||= main.css("a").map { |a| a.get("href") }.compact
58
51
  end
59
52
 
60
53
  def attachements
@@ -90,7 +83,8 @@ module Fushin
90
83
  res = HTTP.get(url)
91
84
  return nil unless res.code == 200
92
85
 
93
- res.body.to_s
86
+ detection = CharlockHolmes::EncodingDetector.detect(res.body.to_s)
87
+ CharlockHolmes::Converter.convert(res.body.to_s, detection[:encoding], "UTF-8")
94
88
  end
95
89
  end
96
90
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fushin
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fushin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-03 00:00:00.000000000 Z
11
+ date: 2019-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler