mihari 8.0.0 → 8.0.1

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: 75cc81f17196e45d76732a65800c54416d73c2b86751ee3745f7d02d9e938b59
4
- data.tar.gz: 0300cb460d5cecae999c095967dbb6c2827fe59b0404becdb287f9df07a6ef8d
3
+ metadata.gz: 29091282748973618fb309a3584d0e24ea27f7e18f284feeb57dbb0f10138f33
4
+ data.tar.gz: c8079484f9241000479f543785c7d97f892b9a182401047ecf752090fe5bf37b
5
5
  SHA512:
6
- metadata.gz: aa653f50889b81341aa06a2d4bbab8c5bfb83bfb2adc60bbbba88933b24fe61503e52de6f5f8b082f5af7f697b249d206e545257def2603a6d0ab76fed090047
7
- data.tar.gz: 1737d85fb2322b49cc5b0a47ea3ad8a3cb723cfa8e7c793f57dd8747472e4509c8282c81148e454ef81f70fa55d6bc037d596ffe538f40fab98b8a1661feda25
6
+ metadata.gz: 4892f605f6dc1169ca22859eb6ddac36b42828575790c2cd7f6ecdf73a158bbdd80704f3c1a0fcba2fd1af3972270131c7df7e657ee30e9cdc7675bbb0aaca3c
7
+ data.tar.gz: 9fdd385288a708f900518c348a8a7ba2b0fd2ac7c0fb81e51c0b71a6e6b313fa8df87e8829539db52ecfc267481229bf2daee21c6bac3ab9ad313a7ee5c2451b
data/lib/mihari/actor.rb CHANGED
@@ -63,7 +63,7 @@ module Mihari
63
63
  raise NotImplementedError, "You must implement #{self.class}##{__method__}"
64
64
  end
65
65
 
66
- def result(...)
66
+ def get_result(...)
67
67
  Try[StandardError] do
68
68
  retry_on_error(times: retry_times, interval: retry_interval, exponential_backoff: retry_exponential_backoff) do
69
69
  call(...)
@@ -77,7 +77,7 @@ module Mihari
77
77
  normalized_artifacts
78
78
  end
79
79
 
80
- def result(...)
80
+ def get_result(...)
81
81
  result = Try[StandardError] do
82
82
  retry_on_error(
83
83
  times: retry_times,
@@ -91,7 +91,7 @@ module Mihari
91
91
  # @param [Integer] id
92
92
  #
93
93
  def get(id)
94
- value = Services::AlertGetter.result(id).value!
94
+ value = Services::AlertGetter.get_result(id).value!
95
95
  data = Entities::Alert.represent(value)
96
96
  puts JSON.pretty_generate(data.as_json)
97
97
  end
@@ -71,7 +71,7 @@ module Mihari
71
71
  # @param [Integer] id
72
72
  #
73
73
  def get(id)
74
- value = Services::ArtifactGetter.result(id).value!
74
+ value = Services::ArtifactGetter.get_result(id).value!
75
75
  data = Entities::Artifact.represent(value)
76
76
  puts JSON.pretty_generate(data.as_json)
77
77
  end
@@ -116,7 +116,7 @@ module Mihari
116
116
  desc "get ID", "Get a rule"
117
117
  around :with_db_connection
118
118
  def get(id)
119
- value = Services::RuleGetter.result(id).value!
119
+ value = Services::RuleGetter.get_result(id).value!
120
120
  data = Entities::Rule.represent(value)
121
121
  puts JSON.pretty_generate(data.as_json)
122
122
  end
@@ -44,7 +44,7 @@ module Mihari
44
44
  #
45
45
  # @return [Dry::Monads::Result::Success<Object>, Dry::Monads::Result::Failure]
46
46
  #
47
- def result(artifacts)
47
+ def get_result(artifacts)
48
48
  result = Try[StandardError] do
49
49
  retry_on_error(
50
50
  times: retry_times,
@@ -29,7 +29,7 @@ module Mihari
29
29
  #
30
30
  # @return [Dry::Monads::Result::Success<Object>, Dry::Monads::Result::Failure]
31
31
  #
32
- def result(artifact)
32
+ def get_result(artifact)
33
33
  return unless callable?(artifact)
34
34
 
35
35
  result = Try[StandardError] do
@@ -191,7 +191,7 @@ module Mihari
191
191
  # NOTE: doing parallel with ActiveRecord objects is troublesome (e.g. connection issue, etc.)
192
192
  # so converting the object to an OpenStruct object
193
193
  s = struct
194
- results = Parallel.map(enrichers) { |enricher| enricher.result s }
194
+ results = Parallel.map(enrichers) { |enricher| enricher.get_result s }
195
195
  enriched = results.compact.map { |result| result.value_or(nil) }.compact
196
196
 
197
197
  self.dns_records = enriched.map(&:dns_records).flatten.compact
@@ -18,7 +18,7 @@ module Mihari
18
18
  # @return [Array<Mihari::Port>]
19
19
  #
20
20
  def build_by_ip(ip, enricher: Enrichers::Shodan.new)
21
- enricher.result(ip).fmap do |res|
21
+ enricher.get_result(ip).fmap do |res|
22
22
  (res&.ports || []).map { |port| new(port:) }
23
23
  end.value_or []
24
24
  end
data/lib/mihari/rule.rb CHANGED
@@ -191,8 +191,8 @@ module Mihari
191
191
  return [] if enriched_artifacts.empty?
192
192
 
193
193
  [].tap do |out|
194
- out << serial_emitters.map { |emitter| emitter.result(enriched_artifacts).value_or(nil) }
195
- out << Parallel.map(parallel_emitters) { |emitter| emitter.result(enriched_artifacts).value_or(nil) }
194
+ out << serial_emitters.map { |emitter| emitter.get_result(enriched_artifacts).value_or(nil) }
195
+ out << Parallel.map(parallel_emitters) { |emitter| emitter.get_result(enriched_artifacts).value_or(nil) }
196
196
  end.flatten.compact
197
197
  end
198
198
 
@@ -349,8 +349,8 @@ module Mihari
349
349
  # @return [Array<Dry::Monads::Result::Success<Array<Mihari::Models::Artifact>>, Dry::Monads::Result::Failure>]
350
350
  def analyzer_results
351
351
  [].tap do |out|
352
- out << Parallel.map(parallel_analyzers, &:result)
353
- out << serial_analyzers.map(&:result)
352
+ out << Parallel.map(parallel_analyzers, &:get_result)
353
+ out << serial_analyzers.map(&:get_result)
354
354
  end.flatten
355
355
  end
356
356
 
@@ -11,7 +11,7 @@ module Mihari
11
11
  raise NotImplementedError, "You must implement #{self.class}##{__method__}"
12
12
  end
13
13
 
14
- def result(...)
14
+ def get_result(...)
15
15
  Try[StandardError] { call(...) }.to_result
16
16
  end
17
17
 
@@ -20,8 +20,8 @@ module Mihari
20
20
  new.call(...)
21
21
  end
22
22
 
23
- def result(...)
24
- new.result(...)
23
+ def get_result(...)
24
+ new.get_result(...)
25
25
  end
26
26
  end
27
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mihari
4
- VERSION = "8.0.0"
4
+ VERSION = "8.0.1"
5
5
  end
@@ -41,7 +41,7 @@ module Mihari
41
41
  end
42
42
  get "/:id" do
43
43
  id = params[:id].to_i
44
- result = Services::AlertGetter.result(id)
44
+ result = Services::AlertGetter.get_result(id)
45
45
  return present(result.value!, with: Entities::Alert) if result.success?
46
46
 
47
47
  case result.failure
@@ -61,7 +61,7 @@ module Mihari
61
61
  end
62
62
  delete "/:id" do
63
63
  id = params["id"].to_i
64
- result = Services::AlertDestroyer.result(id)
64
+ result = Services::AlertDestroyer.get_result(id)
65
65
  return if result.success?
66
66
 
67
67
  case result.failure
@@ -86,7 +86,7 @@ module Mihari
86
86
  post "/" do
87
87
  status 201
88
88
 
89
- result = Services::AlertCreator.result(params)
89
+ result = Services::AlertCreator.get_result(params)
90
90
  return present(result.value!, with: Entities::Alert) if result.success?
91
91
 
92
92
  case result.failure
@@ -41,7 +41,7 @@ module Mihari
41
41
  end
42
42
  get "/:id" do
43
43
  id = params[:id].to_i
44
- result = Services::ArtifactGetter.result(id)
44
+ result = Services::ArtifactGetter.get_result(id)
45
45
  return present(result.value!, with: Entities::Artifact) if result.success?
46
46
 
47
47
  case result.failure
@@ -98,7 +98,7 @@ module Mihari
98
98
  status 204
99
99
 
100
100
  id = params["id"].to_i
101
- result = Services::ArtifactDestroyer.result(id)
101
+ result = Services::ArtifactDestroyer.get_result(id)
102
102
  return if result.success?
103
103
 
104
104
  case result.failure
@@ -21,7 +21,7 @@ module Mihari
21
21
  end
22
22
  get "/:ip", requirements: {ip: %r{[^/]+}} do
23
23
  ip = params[:ip].to_s
24
- result = Services::IPGetter.result(ip)
24
+ result = Services::IPGetter.get_result(ip)
25
25
  if result.success?
26
26
  value = result.value!
27
27
  return present(
@@ -59,7 +59,7 @@ module Mihari
59
59
  end
60
60
  get "/:id" do
61
61
  id = params[:id].to_s
62
- result = Services::RuleGetter.result(params[:id].to_s)
62
+ result = Services::RuleGetter.get_result(params[:id].to_s)
63
63
  return present(result.value!, with: Entities::Rule) if result.success?
64
64
 
65
65
  case result.failure
@@ -120,7 +120,7 @@ module Mihari
120
120
 
121
121
  yaml = params[:yaml].to_s
122
122
 
123
- result = RuleCreateUpdater.result(yaml, overwrite: false)
123
+ result = RuleCreateUpdater.get_result(yaml, overwrite: false)
124
124
  return present(result.value!.model, with: Entities::Rule) if result.success?
125
125
 
126
126
  failure = result.failure
@@ -151,7 +151,7 @@ module Mihari
151
151
 
152
152
  yaml = params[:yaml].to_s
153
153
 
154
- result = RuleCreateUpdater.result(yaml, overwrite: true)
154
+ result = RuleCreateUpdater.get_result(yaml, overwrite: true)
155
155
  return present(result.value!.model, with: Entities::Rule) if result.success?
156
156
 
157
157
  failure = result.failure
@@ -178,7 +178,7 @@ module Mihari
178
178
  status 204
179
179
 
180
180
  id = params[:id].to_s
181
- result = Services::RuleDestroyer.result(id)
181
+ result = Services::RuleDestroyer.get_result(id)
182
182
  return if result.success?
183
183
 
184
184
  case result.failure
@@ -43,7 +43,7 @@ module Mihari
43
43
  status 204
44
44
 
45
45
  id = params[:id].to_i
46
- result = Services::TagDestroyer.result(id)
46
+ result = Services::TagDestroyer.get_result(id)
47
47
  return if result.success?
48
48
 
49
49
  case result.failure