miteru 2.1.0 → 2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7428f741cd791e37e5f201c978f4ee6b5f6fe239d350b69d3377a6af4604305d
4
- data.tar.gz: 0057c9ee7ebe6dd5ee039939b30ff897d3298605c3843c980f2b30081ad8bc2d
3
+ metadata.gz: 509957b241020f76fcd9c85a6acbb9e80c0f8b3224fe5c1b4af41dcd2faa6ca5
4
+ data.tar.gz: 4e507a9974264a9b98d1ded16c09496a06ed4ca83409f75fc49719c37f934f77
5
5
  SHA512:
6
- metadata.gz: b4f69cf18c8db256f035466f669835810e53329f7af7df5fd3d58689002c2e7175abb9456b31e21c0b23369e31a1559040c82f92c662202661c50cc8cc702334
7
- data.tar.gz: d7188fe6bc2372560031fb964254f5ea6df56672edd0f112a6ebe7b41d5ad7efa2a52e6c1deb666891573990f0cf75e8b4ea768f5240cd5d25127a544e06e26c
6
+ metadata.gz: 3dc8e2b4569555f5551a1b7fd2407162949cc7a459a5a7f83c5a787206b5cf39b34f16235466b6bcd74f34bac1878e1e4df6797daebe407eda2c03a9e7379e3a
7
+ data.tar.gz: 69d83a4c964ebbcd87b416675ed03bc18e270c0d604a19ef98b8988a0f344388eb49d0fb290edaa2f8637fa5f100608a3e9a76a1571503bda529611aea332bc0
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "colorize"
4
+
3
5
  module Miteru
4
6
  class Crawler < Service
5
7
  #
@@ -7,7 +9,10 @@ module Miteru
7
9
  #
8
10
  def call(website)
9
11
  Try[OpenSSL::SSL::SSLError, ::HTTP::Error, Addressable::URI::InvalidURIError] do
10
- Miteru.logger.info("Website:#{website.truncated_url} has #{website.kits.length} kit(s).")
12
+ info = "Website:#{website.info}."
13
+ info = info.colorize(:red) if website.kits?
14
+
15
+ Miteru.logger.info(info)
11
16
  return unless website.kits?
12
17
 
13
18
  notify website
@@ -5,6 +5,7 @@ require "slack-notifier"
5
5
  module Miteru
6
6
  module Notifiers
7
7
  class SlackAttachment
8
+ # @return [String]
8
9
  attr_reader :url
9
10
 
10
11
  def initialize(url)
@@ -14,7 +15,7 @@ module Miteru
14
15
  def to_a
15
16
  [
16
17
  {
17
- text: defanged_url,
18
+ text:,
18
19
  fallback: "VT & urlscan.io links",
19
20
  actions:
20
21
  }
@@ -47,10 +48,6 @@ module Miteru
47
48
  }
48
49
  end
49
50
 
50
- def defanged_url
51
- @defanged_url ||= url.to_s.gsub(".", "[.]")
52
- end
53
-
54
51
  def domain
55
52
  @domain ||= [].tap do |out|
56
53
  out << URI(url).hostname
@@ -59,6 +56,10 @@ module Miteru
59
56
  end.first
60
57
  end
61
58
 
59
+ def text
60
+ domain.to_s.gsub(".", "[.]")
61
+ end
62
+
62
63
  def _urlscan_link
63
64
  return nil unless domain
64
65
 
@@ -82,12 +83,11 @@ module Miteru
82
83
  return unless callable?
83
84
 
84
85
  attachment = SlackAttachment.new(website.url)
85
- kits = website.kits.select(&:downloaded?)
86
- notifier.post(text: website.message.capitalize, attachments: attachment.to_a) if kits.any?
86
+ notifier.post(text: website.info, attachments: attachment.to_a) if website.kits?
87
87
  end
88
88
 
89
89
  def callable?
90
- !slack_webhook_url.nil?
90
+ !webhook_url.nil?
91
91
  end
92
92
 
93
93
  private
@@ -9,7 +9,7 @@ module Miteru
9
9
  def call(website)
10
10
  return unless callable?
11
11
 
12
- website.kits.each { |kit| submit(kit.url) }
12
+ website.kits.each { |kit| submit(kit.url, source: website.source) }
13
13
  end
14
14
 
15
15
  def callable?
@@ -41,8 +41,12 @@ module Miteru
41
41
  Miteru.config.urlscan_submit_visibility
42
42
  end
43
43
 
44
- def submit(url)
45
- http.post("https://urlscan.io/api/v1/scan/", json: {tags:, visibility:, url:})
44
+ #
45
+ # @param [String] url
46
+ # @param [String] source
47
+ #
48
+ def submit(url, source:)
49
+ http.post("https://urlscan.io/api/v1/scan/", json: {tags: tags + ["source:#{source}"], visibility:, url:})
46
50
  end
47
51
  end
48
52
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Miteru
4
- VERSION = "2.1.0"
4
+ VERSION = "2.1.1"
5
5
  end
@@ -48,6 +48,14 @@ module Miteru
48
48
  url.truncate(64)
49
49
  end
50
50
 
51
+ def defanged_truncated_url
52
+ truncated_url.to_s.gsub(".", "[.]")
53
+ end
54
+
55
+ def info
56
+ "#{defanged_truncated_url} has #{kits.length} kit(s) (Source: #{source})"
57
+ end
58
+
51
59
  private
52
60
 
53
61
  def timeout
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miteru
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-06 00:00:00.000000000 Z
11
+ date: 2024-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler