mihari 7.1.2 → 7.1.3
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/Rakefile +9 -8
- data/build_frontend.sh +1 -1
- data/lib/mihari/actor.rb +12 -4
- data/lib/mihari/commands/web.rb +3 -3
- data/lib/mihari/errors.rb +14 -1
- data/lib/mihari/structs/config.rb +3 -20
- data/lib/mihari/version.rb +1 -1
- data/lib/mihari/web/public/assets/{index-Guw2aMpk.js → index-TOeU8PE2.js} +53 -33
- data/lib/mihari/web/public/index.html +1 -1
- data/lib/mihari/web/public/redoc-static.html +384 -384
- metadata +7 -50
- data/test.json.jbuilder +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7463506c12a2476cfea5dda939e88e01150fb6539c232e102c15fca4c57ab99
|
4
|
+
data.tar.gz: fdb700f461140badc1d90b3199999a97e483e57ae9c9bfed2d0157a94f35529d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18d9dd1f63056cd2731caa823904fd9df80ca21e63a540eab89d06e7951fa10cde498344049f3ba7de8740da2e8cfb9da9fe660f77c3a1abca5e308e36a6973c
|
7
|
+
data.tar.gz: 5a8ce97455cb0e68538af1ca2c8af5b89ea96f817d4f11cf6c00851035a20288f9bc2d2de16b58b52f3e72e988c77a2e4d8744a3fbebfd27c2cb6895d4c4dccb
|
data/Rakefile
CHANGED
@@ -50,14 +50,15 @@ namespace :build do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
task :build do
|
54
|
+
# Build Swagger dos
|
55
|
+
Rake::Task["build:swagger"].invoke
|
56
|
+
# Build ReDocs docs & frontend assets
|
57
|
+
sh "cd frontend && npm install && npm run docs && npm run build-only"
|
58
|
+
# Copy built assets into ./lib/web/public/
|
59
|
+
sh "rm -rf ./lib/mihari/web/public/"
|
60
|
+
sh "mkdir -p ./lib/mihari/web/public/"
|
61
|
+
sh "cp -r frontend/dist/* ./lib/mihari/web/public"
|
61
62
|
end
|
62
63
|
|
63
64
|
# require it later enables doing pre-build step (= build the frontend app)
|
data/build_frontend.sh
CHANGED
data/lib/mihari/actor.rb
CHANGED
@@ -53,10 +53,10 @@ module Mihari
|
|
53
53
|
def validate_configuration!
|
54
54
|
return if configured?
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
raise ConfigurationError,
|
56
|
+
message = "#{self.class.type.capitalize}:#{self.class.key} is not configured correctly"
|
57
|
+
detail = self.class.configuration_keys.map { |key| "#{key.upcase} is missing" }
|
58
|
+
|
59
|
+
raise ConfigurationError.new(message, detail)
|
60
60
|
end
|
61
61
|
|
62
62
|
def call(*args, **kwargs)
|
@@ -92,6 +92,14 @@ module Mihari
|
|
92
92
|
def keys
|
93
93
|
([key] + [key_aliases]).flatten.compact.map(&:downcase)
|
94
94
|
end
|
95
|
+
|
96
|
+
def type
|
97
|
+
return "analyzer" if ancestors.include?(Mihari::Analyzers::Base)
|
98
|
+
return "emitter" if ancestors.include?(Mihari::Emitters::Base)
|
99
|
+
return "enricher" if ancestors.include?(Mihari::Enrichers::Base)
|
100
|
+
|
101
|
+
nil
|
102
|
+
end
|
95
103
|
end
|
96
104
|
end
|
97
105
|
end
|
data/lib/mihari/commands/web.rb
CHANGED
@@ -10,10 +10,10 @@ module Mihari
|
|
10
10
|
def included(thor)
|
11
11
|
thor.class_eval do
|
12
12
|
desc "web", "Start the web app"
|
13
|
-
method_option :port, type: :numeric, default: 9292, desc: "
|
14
|
-
method_option :host, type: :string, default: "localhost", desc: "
|
13
|
+
method_option :port, type: :numeric, default: 9292, desc: "Port to listen on"
|
14
|
+
method_option :host, type: :string, default: "localhost", desc: "Hostname to listen on"
|
15
15
|
method_option :threads, type: :string, default: "0:5", desc: "min:max threads to use"
|
16
|
-
method_option :verbose, type: :boolean, default:
|
16
|
+
method_option :verbose, type: :boolean, default: false, desc: "Don't report each request"
|
17
17
|
method_option :worker_timeout, type: :numeric, default: 60, desc: "Worker timeout value (in seconds)"
|
18
18
|
method_option :open, type: :boolean, default: true, desc: "Whether to open the app in browser or not"
|
19
19
|
method_option :env, type: :string, default: "production", desc: "Environment"
|
data/lib/mihari/errors.rb
CHANGED
@@ -7,7 +7,20 @@ module Mihari
|
|
7
7
|
|
8
8
|
class ValueError < Error; end
|
9
9
|
|
10
|
-
class ConfigurationError < Error
|
10
|
+
class ConfigurationError < Error
|
11
|
+
# @return [Array<String>, nil]
|
12
|
+
attr_reader :detail
|
13
|
+
|
14
|
+
#
|
15
|
+
# @param [String] msg
|
16
|
+
# @param [Array<String>, nil] detail
|
17
|
+
#
|
18
|
+
def initialize(msg, detail)
|
19
|
+
super(msg)
|
20
|
+
|
21
|
+
@detail = detail
|
22
|
+
end
|
23
|
+
end
|
11
24
|
|
12
25
|
class ResponseError < Error; end
|
13
26
|
|
@@ -20,21 +20,6 @@ module Mihari
|
|
20
20
|
attribute :items, Types.Array(Types::Hash).optional
|
21
21
|
|
22
22
|
class << self
|
23
|
-
#
|
24
|
-
# Get a type of a class
|
25
|
-
#
|
26
|
-
# @param [Class<Mihari::Analyzers::Base>, Class<Mihari::Emitters::Base>, Class<Mihari::Enrichers::Base>] klass
|
27
|
-
#
|
28
|
-
# @return [String, nil]
|
29
|
-
#
|
30
|
-
def get_type(klass)
|
31
|
-
return "analyzer" if klass.ancestors.include?(Mihari::Analyzers::Base)
|
32
|
-
return "emitter" if klass.ancestors.include?(Mihari::Emitters::Base)
|
33
|
-
return "enricher" if klass.ancestors.include?(Mihari::Enrichers::Base)
|
34
|
-
|
35
|
-
nil
|
36
|
-
end
|
37
|
-
|
38
23
|
#
|
39
24
|
# Get a dummy instance
|
40
25
|
#
|
@@ -43,8 +28,7 @@ module Mihari
|
|
43
28
|
# @return [Mihari::Analyzers::Base, Mihari::Emitter::Base, Mihari::Enricher::Base] dummy
|
44
29
|
#
|
45
30
|
def get_dummy(klass)
|
46
|
-
|
47
|
-
case type
|
31
|
+
case klass.type
|
48
32
|
when "analyzer"
|
49
33
|
klass.new("dummy")
|
50
34
|
when "emitter"
|
@@ -62,8 +46,7 @@ module Mihari
|
|
62
46
|
def from_class(klass)
|
63
47
|
return nil if klass == Mihari::Rule
|
64
48
|
|
65
|
-
|
66
|
-
return nil if type.nil?
|
49
|
+
return nil if klass.type.nil?
|
67
50
|
|
68
51
|
begin
|
69
52
|
instance = get_dummy(klass)
|
@@ -71,7 +54,7 @@ module Mihari
|
|
71
54
|
name: klass.key,
|
72
55
|
items: klass.configuration_items,
|
73
56
|
configured: instance.configured?,
|
74
|
-
type: type
|
57
|
+
type: klass.type
|
75
58
|
)
|
76
59
|
rescue ArgumentError
|
77
60
|
nil
|
data/lib/mihari/version.rb
CHANGED