mihari 8.2.0 → 8.3.0
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 +4 -4
- data/lib/mihari/analyzers/censys.rb +64 -27
- data/lib/mihari/clients/censys.rb +91 -58
- data/lib/mihari/config.rb +3 -0
- data/lib/mihari/schemas/analyzer.rb +8 -1
- data/lib/mihari/sidekiq/application.rb +2 -1
- data/lib/mihari/structs/censys.rb +278 -184
- data/lib/mihari/version.rb +1 -1
- data/lib/mihari/web/endpoints/alerts.rb +3 -3
- data/lib/mihari/web/endpoints/artifacts.rb +3 -3
- data/lib/mihari/web/endpoints/ip_addresses.rb +1 -1
- data/lib/mihari/web/endpoints/rules.rb +5 -5
- data/lib/mihari/web/endpoints/tags.rb +1 -1
- data/lib/mihari/web/public/assets/index-DPwW50wG.js +1571 -0
- data/lib/mihari/web/public/assets/index-DZXEbm8D.css +1 -0
- data/lib/mihari/web/public/index.html +2 -2
- data/lib/mihari/web/public/redoc-static.html +19 -19
- data/mihari.gemspec +27 -27
- data/requirements.txt +1 -1
- metadata +56 -57
- data/lib/mihari/web/public/assets/index-C3PsXBg7.js +0 -1617
- data/lib/mihari/web/public/assets/index-DzpJMEJU.css +0 -1
- data/renovate.json +0 -3
|
@@ -3,243 +3,337 @@
|
|
|
3
3
|
module Mihari
|
|
4
4
|
module Structs
|
|
5
5
|
module Censys
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
#
|
|
14
|
-
# @return [Mihari::AutonomousSystem]
|
|
15
|
-
#
|
|
16
|
-
def as
|
|
17
|
-
Mihari::Models::AutonomousSystem.new(number: normalize_asn(asn))
|
|
18
|
-
end
|
|
6
|
+
module V2
|
|
7
|
+
class AutonomousSystem < Dry::Struct
|
|
8
|
+
include Concerns::AutonomousSystemNormalizable
|
|
9
|
+
|
|
10
|
+
# @!attribute [r] asn
|
|
11
|
+
# @return [Integer]
|
|
12
|
+
attribute :asn, Types::Int
|
|
19
13
|
|
|
20
|
-
class << self
|
|
21
14
|
#
|
|
22
|
-
# @
|
|
15
|
+
# @return [Mihari::AutonomousSystem]
|
|
23
16
|
#
|
|
24
|
-
def
|
|
25
|
-
|
|
17
|
+
def as
|
|
18
|
+
Mihari::Models::AutonomousSystem.new(number: normalize_asn(asn))
|
|
19
|
+
end
|
|
26
20
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
class << self
|
|
22
|
+
#
|
|
23
|
+
# @param [Hash] d
|
|
24
|
+
#
|
|
25
|
+
def from_dynamic!(d)
|
|
26
|
+
return nil if d.nil?
|
|
27
|
+
|
|
28
|
+
d = Types::Hash[d]
|
|
29
|
+
new(
|
|
30
|
+
asn: d.fetch("asn")
|
|
31
|
+
)
|
|
32
|
+
end
|
|
31
33
|
end
|
|
32
34
|
end
|
|
33
|
-
end
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
#
|
|
45
|
-
# @return [Mihari::Geolocation] <description>
|
|
46
|
-
#
|
|
47
|
-
def geolocation
|
|
48
|
-
# sometimes Censys overlooks country
|
|
49
|
-
# then set geolocation as nil
|
|
50
|
-
return nil if country.nil?
|
|
51
|
-
|
|
52
|
-
Mihari::Models::Geolocation.new(
|
|
53
|
-
country:,
|
|
54
|
-
country_code:
|
|
55
|
-
)
|
|
56
|
-
end
|
|
36
|
+
class Location < Dry::Struct
|
|
37
|
+
# @!attribute [r] country
|
|
38
|
+
# @return [String, nil]
|
|
39
|
+
attribute :country, Types::String.optional
|
|
40
|
+
|
|
41
|
+
# @!attribute [r] country_code
|
|
42
|
+
# @return [String, nil]
|
|
43
|
+
attribute :country_code, Types::String.optional
|
|
57
44
|
|
|
58
|
-
class << self
|
|
59
45
|
#
|
|
60
|
-
# @
|
|
46
|
+
# @return [Mihari::Geolocation] <description>
|
|
61
47
|
#
|
|
62
|
-
def
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
48
|
+
def geolocation
|
|
49
|
+
# sometimes Censys overlooks country
|
|
50
|
+
# then set geolocation as nil
|
|
51
|
+
return nil if country.nil?
|
|
52
|
+
|
|
53
|
+
Mihari::Models::Geolocation.new(
|
|
54
|
+
country:,
|
|
55
|
+
country_code:
|
|
67
56
|
)
|
|
68
57
|
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
class Service < Dry::Struct
|
|
73
|
-
# @!attribute [r] port
|
|
74
|
-
# @return [Integer, nil]
|
|
75
|
-
attribute :port, Types::Int
|
|
76
58
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
59
|
+
class << self
|
|
60
|
+
#
|
|
61
|
+
# @param [Hash] d
|
|
62
|
+
#
|
|
63
|
+
def from_dynamic!(d)
|
|
64
|
+
d = Types::Hash[d]
|
|
65
|
+
new(
|
|
66
|
+
country: d["country"],
|
|
67
|
+
country_code: d["country_code"]
|
|
68
|
+
)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
82
71
|
end
|
|
83
72
|
|
|
84
|
-
class
|
|
73
|
+
class Service < Dry::Struct
|
|
74
|
+
# @!attribute [r] port
|
|
75
|
+
# @return [Integer, nil]
|
|
76
|
+
attribute :port, Types::Int
|
|
77
|
+
|
|
85
78
|
#
|
|
86
|
-
# @
|
|
79
|
+
# @return [Mihari::Port]
|
|
87
80
|
#
|
|
88
|
-
def
|
|
89
|
-
|
|
90
|
-
new(
|
|
91
|
-
port: d.fetch("port")
|
|
92
|
-
)
|
|
81
|
+
def _port
|
|
82
|
+
Models::Port.new(number: port)
|
|
93
83
|
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
84
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
85
|
+
class << self
|
|
86
|
+
#
|
|
87
|
+
# @param [Hash] d
|
|
88
|
+
#
|
|
89
|
+
def from_dynamic!(d)
|
|
90
|
+
d = Types::Hash[d]
|
|
91
|
+
new(
|
|
92
|
+
port: d.fetch("port")
|
|
93
|
+
)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
101
97
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
class Hit < Dry::Struct
|
|
99
|
+
# @!attribute [r] ip
|
|
100
|
+
# @return [String]
|
|
101
|
+
attribute :ip, Types::String
|
|
105
102
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
# @!attribute [r] location
|
|
104
|
+
# @return [Location]
|
|
105
|
+
attribute :location, Location
|
|
109
106
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
# @!attribute [r] autonomous_system
|
|
108
|
+
# @return [AutonomousSystem, nil]
|
|
109
|
+
attribute :autonomous_system, AutonomousSystem.optional
|
|
113
110
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
# @!attribute [r] metadata
|
|
112
|
+
# @return [Hash]
|
|
113
|
+
attribute :metadata, Types::Hash
|
|
117
114
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
def ports
|
|
122
|
-
services.map(&:_port)
|
|
123
|
-
end
|
|
115
|
+
# @!attribute [r] services
|
|
116
|
+
# @return [Array<Service>]
|
|
117
|
+
attribute :services, Types.Array(Service)
|
|
124
118
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
metadata:,
|
|
132
|
-
autonomous_system: autonomous_system&.as,
|
|
133
|
-
geolocation: location.geolocation,
|
|
134
|
-
ports:
|
|
135
|
-
)
|
|
136
|
-
end
|
|
119
|
+
#
|
|
120
|
+
# @return [Array<Mihari::Port>]
|
|
121
|
+
#
|
|
122
|
+
def ports
|
|
123
|
+
services.map(&:_port)
|
|
124
|
+
end
|
|
137
125
|
|
|
138
|
-
class << self
|
|
139
126
|
#
|
|
140
|
-
# @
|
|
127
|
+
# @return [Mihari::Models::Artifact]
|
|
141
128
|
#
|
|
142
|
-
def
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
services: d.fetch("services", []).map { |x| Service.from_dynamic!(x) }
|
|
129
|
+
def artifact
|
|
130
|
+
Models::Artifact.new(
|
|
131
|
+
data: ip,
|
|
132
|
+
metadata:,
|
|
133
|
+
autonomous_system: autonomous_system&.as,
|
|
134
|
+
geolocation: location.geolocation,
|
|
135
|
+
ports:
|
|
150
136
|
)
|
|
151
137
|
end
|
|
138
|
+
|
|
139
|
+
class << self
|
|
140
|
+
#
|
|
141
|
+
# @param [Hash] d
|
|
142
|
+
#
|
|
143
|
+
def from_dynamic!(d)
|
|
144
|
+
d = Types::Hash[d]
|
|
145
|
+
new(
|
|
146
|
+
ip: d.fetch("ip"),
|
|
147
|
+
location: Location.from_dynamic!(d.fetch("location")),
|
|
148
|
+
autonomous_system: AutonomousSystem.from_dynamic!(d["autonomous_system"]),
|
|
149
|
+
metadata: d,
|
|
150
|
+
services: d.fetch("services", []).map { |x| Service.from_dynamic!(x) }
|
|
151
|
+
)
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
class Links < Dry::Struct
|
|
157
|
+
# @!attribute [r] next
|
|
158
|
+
# @return [String, nil]
|
|
159
|
+
attribute :next, Types::String.optional
|
|
160
|
+
|
|
161
|
+
# @!attribute [r] prev
|
|
162
|
+
# @return [String, nil]
|
|
163
|
+
attribute :prev, Types::String.optional
|
|
164
|
+
|
|
165
|
+
class << self
|
|
166
|
+
#
|
|
167
|
+
# @param [Hash] d
|
|
168
|
+
#
|
|
169
|
+
def from_dynamic!(d)
|
|
170
|
+
d = Types::Hash[d]
|
|
171
|
+
new(
|
|
172
|
+
next: d["next"],
|
|
173
|
+
prev: d["prev"]
|
|
174
|
+
)
|
|
175
|
+
end
|
|
176
|
+
end
|
|
152
177
|
end
|
|
153
|
-
end
|
|
154
178
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
179
|
+
class Result < Dry::Struct
|
|
180
|
+
# @!attribute [r] query
|
|
181
|
+
# @return [String]
|
|
182
|
+
attribute :query, Types::String
|
|
159
183
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
184
|
+
# @!attribute [r] total
|
|
185
|
+
# @return [Integer]
|
|
186
|
+
attribute :total, Types::Int
|
|
187
|
+
|
|
188
|
+
# @!attribute [r] hits
|
|
189
|
+
# @return [Array<Hit>]
|
|
190
|
+
attribute :hits, Types.Array(Hit)
|
|
191
|
+
|
|
192
|
+
# @!attribute [r] links
|
|
193
|
+
# @return [Links]
|
|
194
|
+
attribute :links, Links
|
|
163
195
|
|
|
164
|
-
class << self
|
|
165
196
|
#
|
|
166
|
-
# @
|
|
197
|
+
# @return [Array<Mihari::Models::Artifact>]
|
|
167
198
|
#
|
|
168
|
-
def
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
199
|
+
def artifacts
|
|
200
|
+
hits.map(&:artifact)
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
class << self
|
|
204
|
+
#
|
|
205
|
+
# @param [Hash] d
|
|
206
|
+
#
|
|
207
|
+
def from_dynamic!(d)
|
|
208
|
+
d = Types::Hash[d]
|
|
209
|
+
new(
|
|
210
|
+
query: d.fetch("query"),
|
|
211
|
+
total: d.fetch("total"),
|
|
212
|
+
hits: d.fetch("hits", []).map { |x| Hit.from_dynamic!(x) },
|
|
213
|
+
links: Links.from_dynamic!(d.fetch("links"))
|
|
214
|
+
)
|
|
215
|
+
end
|
|
174
216
|
end
|
|
175
217
|
end
|
|
176
|
-
end
|
|
177
218
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
219
|
+
class Response < Dry::Struct
|
|
220
|
+
# @!attribute [r] code
|
|
221
|
+
# @return [Integer]
|
|
222
|
+
attribute :code, Types::Int
|
|
182
223
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
224
|
+
# @!attribute [r] status
|
|
225
|
+
# @return [String]
|
|
226
|
+
attribute :status, Types::String
|
|
186
227
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
228
|
+
# @!attribute [r] result
|
|
229
|
+
# @return [Result]
|
|
230
|
+
attribute :result, Result
|
|
190
231
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
232
|
+
def artifacts
|
|
233
|
+
result.artifacts
|
|
234
|
+
end
|
|
194
235
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
236
|
+
class << self
|
|
237
|
+
#
|
|
238
|
+
# @param [Hash] d
|
|
239
|
+
#
|
|
240
|
+
def from_dynamic!(d)
|
|
241
|
+
d = Types::Hash[d]
|
|
242
|
+
new(
|
|
243
|
+
code: d.fetch("code"),
|
|
244
|
+
status: d.fetch("status"),
|
|
245
|
+
result: Result.from_dynamic!(d.fetch("result"))
|
|
246
|
+
)
|
|
247
|
+
end
|
|
248
|
+
end
|
|
200
249
|
end
|
|
250
|
+
end
|
|
201
251
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
252
|
+
module V3
|
|
253
|
+
class Hit < Dry::Struct
|
|
254
|
+
include Mihari::Concerns::AutonomousSystemNormalizable
|
|
255
|
+
|
|
256
|
+
attribute :ip, Types::String
|
|
257
|
+
attribute :autonomous_system, Types::Hash.optional
|
|
258
|
+
attribute :location, Types::Hash.optional
|
|
259
|
+
attribute :services, Types.Array(Types::Hash).optional
|
|
260
|
+
attribute :metadata, Types::Hash
|
|
261
|
+
|
|
262
|
+
def ports
|
|
263
|
+
(services || []).filter_map { |svc| svc["port"] }
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
def artifact
|
|
267
|
+
Mihari::Models::Artifact.new(
|
|
268
|
+
data: ip,
|
|
269
|
+
metadata: metadata,
|
|
270
|
+
autonomous_system: autonomous_system_model,
|
|
271
|
+
geolocation: geolocation_model,
|
|
272
|
+
ports: ports.map { |p| Mihari::Models::Port.new(number: p) }
|
|
213
273
|
)
|
|
214
274
|
end
|
|
215
|
-
end
|
|
216
|
-
end
|
|
217
275
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
# @return [Integer]
|
|
221
|
-
attribute :code, Types::Int
|
|
276
|
+
def autonomous_system_model
|
|
277
|
+
return nil if autonomous_system.nil?
|
|
222
278
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
attribute :status, Types::String
|
|
279
|
+
Mihari::Models::AutonomousSystem.new(number: normalize_asn(autonomous_system["asn"]))
|
|
280
|
+
end
|
|
226
281
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
attribute :result, Result
|
|
282
|
+
def geolocation_model
|
|
283
|
+
return nil if location.nil?
|
|
230
284
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
#
|
|
235
|
-
def from_dynamic!(d)
|
|
236
|
-
d = Types::Hash[d]
|
|
237
|
-
new(
|
|
238
|
-
code: d.fetch("code"),
|
|
239
|
-
status: d.fetch("status"),
|
|
240
|
-
result: Result.from_dynamic!(d.fetch("result"))
|
|
285
|
+
Mihari::Models::Geolocation.new(
|
|
286
|
+
country: location["country"],
|
|
287
|
+
country_code: location["country_code"]
|
|
241
288
|
)
|
|
242
289
|
end
|
|
290
|
+
|
|
291
|
+
class << self
|
|
292
|
+
def from_dynamic!(d)
|
|
293
|
+
res = d.dig("host_v1", "resource") || {}
|
|
294
|
+
new(
|
|
295
|
+
ip: res["ip"],
|
|
296
|
+
autonomous_system: res["autonomous_system"],
|
|
297
|
+
location: res["location"],
|
|
298
|
+
services: res["services"],
|
|
299
|
+
metadata: d
|
|
300
|
+
)
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
class Result < Dry::Struct
|
|
306
|
+
attribute :hits, Types.Array(Hit)
|
|
307
|
+
attribute :next_page_token, Types::String.optional
|
|
308
|
+
|
|
309
|
+
def artifacts
|
|
310
|
+
hits.map(&:artifact)
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
class << self
|
|
314
|
+
def from_dynamic!(d)
|
|
315
|
+
new(
|
|
316
|
+
hits: (d["hits"] || []).map { |x| Hit.from_dynamic!(x) },
|
|
317
|
+
next_page_token: d["next_page_token"]
|
|
318
|
+
)
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
class Response < Dry::Struct
|
|
324
|
+
attribute :result, Result
|
|
325
|
+
|
|
326
|
+
def artifacts
|
|
327
|
+
result.artifacts
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
class << self
|
|
331
|
+
def from_dynamic!(d)
|
|
332
|
+
new(
|
|
333
|
+
result: Result.from_dynamic!(d["result"])
|
|
334
|
+
)
|
|
335
|
+
end
|
|
336
|
+
end
|
|
243
337
|
end
|
|
244
338
|
end
|
|
245
339
|
end
|
data/lib/mihari/version.rb
CHANGED
|
@@ -42,7 +42,7 @@ module Mihari
|
|
|
42
42
|
get "/:id" do
|
|
43
43
|
id = params[:id].to_i
|
|
44
44
|
result = Services::AlertGetter.get_result(id)
|
|
45
|
-
|
|
45
|
+
next present(result.value!, with: Entities::Alert) if result.success?
|
|
46
46
|
|
|
47
47
|
case result.failure
|
|
48
48
|
when ActiveRecord::RecordNotFound
|
|
@@ -62,7 +62,7 @@ module Mihari
|
|
|
62
62
|
delete "/:id" do
|
|
63
63
|
id = params["id"].to_i
|
|
64
64
|
result = Services::AlertDestroyer.get_result(id)
|
|
65
|
-
|
|
65
|
+
next if result.success?
|
|
66
66
|
|
|
67
67
|
case result.failure
|
|
68
68
|
when ActiveRecord::RecordNotFound
|
|
@@ -87,7 +87,7 @@ module Mihari
|
|
|
87
87
|
status 201
|
|
88
88
|
|
|
89
89
|
result = Services::AlertCreator.get_result(params)
|
|
90
|
-
|
|
90
|
+
next present(result.value!, with: Entities::Alert) if result.success?
|
|
91
91
|
|
|
92
92
|
case result.failure
|
|
93
93
|
when ActiveRecord::RecordNotFound
|
|
@@ -42,7 +42,7 @@ module Mihari
|
|
|
42
42
|
get "/:id" do
|
|
43
43
|
id = params[:id].to_i
|
|
44
44
|
result = Services::ArtifactGetter.get_result(id)
|
|
45
|
-
|
|
45
|
+
next present(result.value!, with: Entities::Artifact) if result.success?
|
|
46
46
|
|
|
47
47
|
case result.failure
|
|
48
48
|
when ActiveRecord::RecordNotFound
|
|
@@ -75,7 +75,7 @@ module Mihari
|
|
|
75
75
|
end.to_result
|
|
76
76
|
|
|
77
77
|
message = queued ? "ID:#{id}'s enrichment is queued" : "ID:#{id}'s enrichment is successful"
|
|
78
|
-
|
|
78
|
+
next present({message:, queued:}, with: Entities::QueueMessage) if result.success?
|
|
79
79
|
|
|
80
80
|
case result.failure
|
|
81
81
|
when UnenrichableError
|
|
@@ -99,7 +99,7 @@ module Mihari
|
|
|
99
99
|
|
|
100
100
|
id = params["id"].to_i
|
|
101
101
|
result = Services::ArtifactDestroyer.get_result(id)
|
|
102
|
-
|
|
102
|
+
next if result.success?
|
|
103
103
|
|
|
104
104
|
case result.failure
|
|
105
105
|
when ActiveRecord::RecordNotFound
|
|
@@ -60,7 +60,7 @@ module Mihari
|
|
|
60
60
|
get "/:id" do
|
|
61
61
|
id = params[:id].to_s
|
|
62
62
|
result = Services::RuleGetter.get_result(params[:id].to_s)
|
|
63
|
-
|
|
63
|
+
next present(result.value!, with: Entities::Rule) if result.success?
|
|
64
64
|
|
|
65
65
|
case result.failure
|
|
66
66
|
when ActiveRecord::RecordNotFound
|
|
@@ -95,7 +95,7 @@ module Mihari
|
|
|
95
95
|
end.to_result
|
|
96
96
|
|
|
97
97
|
message = queued ? "ID:#{id}'s search is queued" : "ID:#{id}'s search is successful"
|
|
98
|
-
|
|
98
|
+
next present({message:, queued:}, with: Entities::QueueMessage) if result.success?
|
|
99
99
|
|
|
100
100
|
case result.failure
|
|
101
101
|
when ActiveRecord::RecordNotFound
|
|
@@ -121,7 +121,7 @@ module Mihari
|
|
|
121
121
|
yaml = params[:yaml].to_s
|
|
122
122
|
|
|
123
123
|
result = RuleCreateUpdater.get_result(yaml, overwrite: false)
|
|
124
|
-
|
|
124
|
+
next present(result.value!.model, with: Entities::Rule) if result.success?
|
|
125
125
|
|
|
126
126
|
failure = result.failure
|
|
127
127
|
case failure
|
|
@@ -152,7 +152,7 @@ module Mihari
|
|
|
152
152
|
yaml = params[:yaml].to_s
|
|
153
153
|
|
|
154
154
|
result = RuleCreateUpdater.get_result(yaml, overwrite: true)
|
|
155
|
-
|
|
155
|
+
next present(result.value!.model, with: Entities::Rule) if result.success?
|
|
156
156
|
|
|
157
157
|
failure = result.failure
|
|
158
158
|
case failure
|
|
@@ -179,7 +179,7 @@ module Mihari
|
|
|
179
179
|
|
|
180
180
|
id = params[:id].to_s
|
|
181
181
|
result = Services::RuleDestroyer.get_result(id)
|
|
182
|
-
|
|
182
|
+
next if result.success?
|
|
183
183
|
|
|
184
184
|
case result.failure
|
|
185
185
|
when ActiveRecord::RecordNotFound
|