mihari 7.3.0 → 7.3.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 +4 -4
- data/lib/mihari/actor.rb +0 -7
- data/lib/mihari/analyzers/base.rb +7 -0
- data/lib/mihari/emitters/base.rb +7 -0
- data/lib/mihari/rule.rb +12 -21
- data/lib/mihari/schemas/analyzer.rb +1 -1
- data/lib/mihari/schemas/concerns/orrable.rb +1 -1
- data/lib/mihari/schemas/emitter.rb +6 -6
- data/lib/mihari/schemas/enricher.rb +1 -1
- data/lib/mihari/schemas/options.rb +15 -10
- data/lib/mihari/schemas/rule.rb +3 -3
- data/lib/mihari/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed9b24457d01edc4d1643e6c31c654ad7c13bf71fc849b10bb02276abf45852c
|
4
|
+
data.tar.gz: 1be36d2083e0b0209ad16475a8f20eb4d2ee9bfcb37eae43fa76091207526def
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4482938e33386e24054cb215f78f065e3190ba32269872aea6a9f543745a2c71777bb609120dcaa3872dba9b6ebd307651f80239342d6ac9427db205f03c80e0
|
7
|
+
data.tar.gz: 5723cbca9f18c519fc4cf91775d751f417a85161add0c0c6d499fd03075c7985c1cb73ef68e24b4913b1d8d3a9652a0e4e1025a32b83c987d3e9e22886923e38
|
data/lib/mihari/actor.rb
CHANGED
@@ -40,6 +40,13 @@ module Mihari
|
|
40
40
|
options[:ignore_error] || Mihari.config.ignore_error
|
41
41
|
end
|
42
42
|
|
43
|
+
#
|
44
|
+
# @return [Boolean]
|
45
|
+
#
|
46
|
+
def parallel?
|
47
|
+
options[:parallel] || Mihari.config.parallel
|
48
|
+
end
|
49
|
+
|
43
50
|
# @return [Array<String>, Array<Mihari::Models::Artifact>]
|
44
51
|
def artifacts
|
45
52
|
raise NotImplementedError, "You must implement #{self.class}##{__method__}"
|
data/lib/mihari/emitters/base.rb
CHANGED
data/lib/mihari/rule.rb
CHANGED
@@ -33,9 +33,9 @@ module Mihari
|
|
33
33
|
# @return [Boolean]
|
34
34
|
#
|
35
35
|
def errors?
|
36
|
-
return false if
|
36
|
+
return false if errors.nil?
|
37
37
|
|
38
|
-
|
38
|
+
!errors.empty?
|
39
39
|
end
|
40
40
|
|
41
41
|
def [](key)
|
@@ -163,9 +163,7 @@ module Mihari
|
|
163
163
|
# @return [Array<Mihari::Models::Artifact>]
|
164
164
|
#
|
165
165
|
def unique_artifacts
|
166
|
-
normalized_artifacts.select
|
167
|
-
artifact.unique?(base_time: base_time, artifact_ttl: artifact_ttl)
|
168
|
-
end
|
166
|
+
normalized_artifacts.select { |artifact| artifact.unique?(base_time: base_time, artifact_ttl: artifact_ttl) }
|
169
167
|
end
|
170
168
|
|
171
169
|
#
|
@@ -174,11 +172,11 @@ module Mihari
|
|
174
172
|
# @return [Array<Mihari::Models::Artifact>]
|
175
173
|
#
|
176
174
|
def enriched_artifacts
|
177
|
-
@enriched_artifacts ||=
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
175
|
+
@enriched_artifacts ||= Parallel.map(unique_artifacts) do |artifact|
|
176
|
+
artifact.tap do |tapped|
|
177
|
+
# NOTE: To apply changes correctly, enrichers should be applied to an artifact serially
|
178
|
+
enrichers.each { |enricher| enricher.result(tapped) }
|
179
|
+
end
|
182
180
|
end
|
183
181
|
end
|
184
182
|
|
@@ -337,9 +335,10 @@ module Mihari
|
|
337
335
|
|
338
336
|
# @return [Array<Dry::Monads::Result::Success<Array<Mihari::Models::Artifact>>, Dry::Monads::Result::Failure>]
|
339
337
|
def analyzer_results
|
340
|
-
|
341
|
-
|
342
|
-
|
338
|
+
[].tap do |out|
|
339
|
+
out << Parallel.map(parallel_analyzers, &:result)
|
340
|
+
out << serial_analyzers.map(&:result)
|
341
|
+
end.flatten
|
343
342
|
end
|
344
343
|
|
345
344
|
#
|
@@ -404,14 +403,6 @@ module Mihari
|
|
404
403
|
end
|
405
404
|
end
|
406
405
|
|
407
|
-
def parallel_enrichers
|
408
|
-
enrichers.select(&:parallel?)
|
409
|
-
end
|
410
|
-
|
411
|
-
def serial_enrichers
|
412
|
-
enrichers.reject(&:parallel?)
|
413
|
-
end
|
414
|
-
|
415
406
|
#
|
416
407
|
# Validate the data format
|
417
408
|
#
|
@@ -10,28 +10,28 @@ module Mihari
|
|
10
10
|
|
11
11
|
Database = Dry::Schema.Params do
|
12
12
|
required(:emitter).value(Types::String.enum(*Mihari::Emitters::Database.keys))
|
13
|
-
optional(:options).hash(
|
13
|
+
optional(:options).hash(EmitterOptions)
|
14
14
|
end
|
15
15
|
|
16
16
|
MISP = Dry::Schema.Params do
|
17
17
|
required(:emitter).value(Types::String.enum(*Mihari::Emitters::MISP.keys))
|
18
18
|
optional(:url).filled(:string)
|
19
19
|
optional(:api_key).filled(:string)
|
20
|
-
optional(:options).hash(
|
20
|
+
optional(:options).hash(EmitterOptions)
|
21
21
|
end
|
22
22
|
|
23
23
|
TheHive = Dry::Schema.Params do
|
24
24
|
required(:emitter).value(Types::String.enum(*Mihari::Emitters::TheHive.keys))
|
25
25
|
optional(:url).filled(:string)
|
26
26
|
optional(:api_key).filled(:string)
|
27
|
-
optional(:options).hash(
|
27
|
+
optional(:options).hash(EmitterOptions)
|
28
28
|
end
|
29
29
|
|
30
30
|
Slack = Dry::Schema.Params do
|
31
31
|
required(:emitter).value(Types::String.enum(*Mihari::Emitters::Slack.keys))
|
32
32
|
optional(:webhook_url).filled(:string)
|
33
33
|
optional(:channel).filled(:string)
|
34
|
-
optional(:options).hash(
|
34
|
+
optional(:options).hash(EmitterOptions)
|
35
35
|
end
|
36
36
|
|
37
37
|
Webhook = Dry::Schema.Params do
|
@@ -40,10 +40,10 @@ module Mihari
|
|
40
40
|
optional(:method).value(Types::HTTPRequestMethods).default("POST")
|
41
41
|
optional(:headers).filled(:hash)
|
42
42
|
optional(:template).filled(:string)
|
43
|
-
optional(:options).hash(
|
43
|
+
optional(:options).hash(EmitterOptions)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
Emitter = Schemas::Emitters.
|
47
|
+
Emitter = Schemas::Emitters.compose_by_or
|
48
48
|
end
|
49
49
|
end
|
@@ -3,24 +3,29 @@
|
|
3
3
|
module Mihari
|
4
4
|
module Schemas
|
5
5
|
Options = Dry::Schema.Params do
|
6
|
-
optional(:retry_times).value(:integer)
|
7
|
-
optional(:retry_interval).value(:integer)
|
8
|
-
optional(:retry_exponential_backoff).value(:bool)
|
6
|
+
optional(:retry_times).value(:integer)
|
7
|
+
optional(:retry_interval).value(:integer)
|
8
|
+
optional(:retry_exponential_backoff).value(:bool)
|
9
9
|
optional(:timeout).value(:integer)
|
10
|
-
optional(:parallel).value(:bool).default(Mihari.config.parallel)
|
11
10
|
end
|
12
11
|
|
13
|
-
|
14
|
-
optional(:
|
12
|
+
ParallelOptions = Dry::Schema.Params do
|
13
|
+
optional(:parallel).value(:bool)
|
15
14
|
end
|
16
15
|
|
17
|
-
|
16
|
+
IgnoreErrorOptions = Dry::Schema.Params do
|
17
|
+
optional(:ignore_error).value(:bool)
|
18
|
+
end
|
18
19
|
|
19
20
|
PaginationOptions = Dry::Schema.Params do
|
20
|
-
optional(:pagination_interval).value(:integer)
|
21
|
-
optional(:pagination_limit).value(:integer)
|
21
|
+
optional(:pagination_interval).value(:integer)
|
22
|
+
optional(:pagination_limit).value(:integer)
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
+
AnalyzerOptions = Options & IgnoreErrorOptions & ParallelOptions
|
26
|
+
|
27
|
+
AnalyzerPaginationOptions = AnalyzerOptions & PaginationOptions
|
28
|
+
|
29
|
+
EmitterOptions = Options & ParallelOptions
|
25
30
|
end
|
26
31
|
end
|
data/lib/mihari/schemas/rule.rb
CHANGED
@@ -21,9 +21,9 @@ module Mihari
|
|
21
21
|
optional(:created_on).value(:date)
|
22
22
|
optional(:updated_on).value(:date)
|
23
23
|
|
24
|
-
required(:queries).
|
25
|
-
optional(:emitters).
|
26
|
-
optional(:enrichers).
|
24
|
+
required(:queries).array { Analyzer }
|
25
|
+
optional(:emitters).array { Emitter }.default(DEFAULT_EMITTERS)
|
26
|
+
optional(:enrichers).array { Enricher }.default(DEFAULT_ENRICHERS)
|
27
27
|
|
28
28
|
optional(:data_types).filled(array[Types::DataTypes]).default(Mihari::Types::DataTypes.values)
|
29
29
|
|
data/lib/mihari/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mihari
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.3.
|
4
|
+
version: 7.3.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-01-
|
11
|
+
date: 2024-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: better_errors
|