mihari 7.1.2 → 7.1.3

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: 52d1c8320fdb5233c9738f3b4599868260fef892599cdfb42da6c3af17583b75
4
- data.tar.gz: 625cd92558eff5a4d5613e588cc5ee85b9b714a9af211788da1a294d8d54ac45
3
+ metadata.gz: d7463506c12a2476cfea5dda939e88e01150fb6539c232e102c15fca4c57ab99
4
+ data.tar.gz: fdb700f461140badc1d90b3199999a97e483e57ae9c9bfed2d0157a94f35529d
5
5
  SHA512:
6
- metadata.gz: 96811d3ebfffcb27a7577b814be280916dd46bd3477233374ffafd2bf784d9e5133f89b1d7650c722c25e2f678f82380f5ced2eff8f9b7e1f3c96583f54a1114
7
- data.tar.gz: 5c13581e670c7aff158e93335fe9c626294cad622f153e61a338f31bb5a1e459302f34a3a9ddf18e0bb322e1359c43a6b782387cdc800f9b047c04e5521f4c70
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
- def ci?
54
- ENV.fetch("CI", false)
55
- end
56
-
57
- unless ci?
58
- task :build do
59
- sh "./build_frontend.sh"
60
- end
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
@@ -3,7 +3,7 @@
3
3
  CURRENT_DIR=${PWD}
4
4
 
5
5
  cd frontend
6
- npm ci
6
+ npm install
7
7
  npm run build
8
8
 
9
9
  trash -r ${CURRENT_DIR}/lib/mihari/web/public/
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
- joined = self.class.configuration_keys.join(", ")
57
- be = (self.class.configuration_keys.length > 1) ? "are" : "is"
58
- message = "#{self.class.key} is not configured correctly. #{joined} #{be} missing."
59
- raise ConfigurationError, message
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
@@ -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: "Hostname to listen on"
14
- method_option :host, type: :string, default: "localhost", desc: "Port to listen on"
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: true, desc: "Report each request"
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; end
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
- type = get_type(klass)
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
- type = get_type(klass)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mihari
4
- VERSION = "7.1.2"
4
+ VERSION = "7.1.3"
5
5
  end