mihari 4.7.2 → 4.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -0
  3. data/.rubocop.yml +4 -0
  4. data/lib/mihari/commands/validator.rb +2 -1
  5. data/lib/mihari/schemas/rule.rb +5 -0
  6. data/lib/mihari/structs/rule.rb +12 -28
  7. data/lib/mihari/version.rb +1 -1
  8. data/lib/mihari/web/public/index.html +1 -1
  9. data/lib/mihari/web/public/redoc-static.html +282 -246
  10. data/lib/mihari/web/public/static/css/{chunk-vendors.5013d549.css → chunk-vendors.380724be.css} +2 -2
  11. data/lib/mihari/web/public/static/fonts/fa-brands-400.86c7e1fa.woff2 +0 -0
  12. data/lib/mihari/web/public/static/fonts/{fa-brands-400.7fa789ab.ttf → fa-brands-400.f5defc2e.ttf} +0 -0
  13. data/lib/mihari/web/public/static/fonts/{fa-regular-400.da02cb7e.ttf → fa-regular-400.3edb9004.ttf} +0 -0
  14. data/lib/mihari/web/public/static/fonts/fa-regular-400.e0550912.woff2 +0 -0
  15. data/lib/mihari/web/public/static/fonts/fa-solid-900.64d5644d.woff2 +0 -0
  16. data/lib/mihari/web/public/static/fonts/{fa-solid-900.3a463ec3.ttf → fa-solid-900.f418d876.ttf} +0 -0
  17. data/lib/mihari/web/public/static/fonts/{fa-v4compatibility.924588dc.ttf → fa-v4compatibility.7e7e1dad.ttf} +0 -0
  18. data/lib/mihari/web/public/static/js/app.6413bf4f.js +2 -0
  19. data/lib/mihari/web/public/static/js/app.6413bf4f.js.map +1 -0
  20. data/lib/mihari/web/public/static/js/chunk-vendors.723e02cf.js +31 -0
  21. data/lib/mihari/web/public/static/js/chunk-vendors.723e02cf.js.map +1 -0
  22. data/mihari.gemspec +18 -18
  23. metadata +51 -50
  24. data/lib/mihari/web/public/static/fonts/fa-brands-400.859fc388.woff2 +0 -0
  25. data/lib/mihari/web/public/static/fonts/fa-regular-400.2ffd018f.woff2 +0 -0
  26. data/lib/mihari/web/public/static/fonts/fa-solid-900.40ddefd7.woff2 +0 -0
  27. data/lib/mihari/web/public/static/js/app.3ac3bd7a.js +0 -2
  28. data/lib/mihari/web/public/static/js/app.3ac3bd7a.js.map +0 -1
  29. data/lib/mihari/web/public/static/js/chunk-vendors.37b7208e.js +0 -31
  30. data/lib/mihari/web/public/static/js/chunk-vendors.37b7208e.js.map +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7eeecbacefc194f5d2e9356fe8f17884c358b45bb3b7ccbd83a47aa3567ae1f6
4
- data.tar.gz: d99abc5ef4368bf1a23a48cf0f15a64a33d3539313a624d489887e86a8cc564c
3
+ metadata.gz: 3e827da38142045be9b680636eb69b61d18e465b83f33d3a2a435c251041c7fc
4
+ data.tar.gz: 91d0c1fa7e50512c9a2bb8aceb914f69bec149c3fd7dc16f136a4b391a086e56
5
5
  SHA512:
6
- metadata.gz: e0347f1c03a949d7e3c85cb9a615247c41bea2a0ac8288f0e3c7a8f9bd5d93ad8f952c99f3b595bf19997fe10e32490898b58a858f63f402a6082344f68cdb87
7
- data.tar.gz: a507cfb86593c602ba46ef59f279a17ed1a34e433c8e34898a872048306733d26fb1a6546f1ae96605d524ccd80c3c3a0487ab4b4ad66219c0e3a63215ce8c6e
6
+ metadata.gz: c6c06c7d217091158d3fc354ccf3e0640494cfcd26b38cf5927d4d2a43f961ce8d2bf7d87bc965037554e745bf54b7dcf06e02b96d93962e6b0948bff11119d7
7
+ data.tar.gz: 5dd97d8c4a4d9ae9eac0e3823e8da97210de5dae87c448f48f6df565a12c99e7f0620d0477862762465aa77b0727912ccc935cd941e9a291a48a763fbf9ab8f3
@@ -56,6 +56,7 @@ jobs:
56
56
  uses: ruby/setup-ruby@v1
57
57
  with:
58
58
  ruby-version: ${{ matrix.ruby }}
59
+ bundler: latest
59
60
  bundler-cache: true
60
61
 
61
62
  - name: Test with PostgreSQL
data/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ Style/HashSyntax:
2
+ EnforcedShorthandSyntax: either
3
+ Style/StringLiterals:
4
+ EnforcedStyle: double_quotes
@@ -18,7 +18,8 @@ module Mihari
18
18
 
19
19
  begin
20
20
  rule.validate!
21
- Mihari.logger.info "Valid format. The input is parsed as the following:\n#{rule.data.to_yaml}"
21
+ Mihari.logger.info "Valid format. The input is parsed as the following:"
22
+ Mihari.logger.info rule.data.to_yaml
22
23
  rescue RuleValidationError
23
24
  nil
24
25
  end
@@ -13,6 +13,11 @@ module Mihari
13
13
  optional(:tags).value(array[:string]).default([])
14
14
  optional(:id).value(:string)
15
15
 
16
+ optional(:status).value(:string)
17
+
18
+ optional(:related).value(array[:string])
19
+ optional(:references).value(array[:string])
20
+
16
21
  optional(:author).value(:string)
17
22
  optional(:created_on).value(:date)
18
23
  optional(:updated_on).value(:date)
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "date"
4
4
  require "erb"
5
+ require "json"
5
6
  require "pathname"
6
7
  require "yaml"
7
8
 
@@ -20,12 +21,17 @@ module Mihari
20
21
  # @return [String]
21
22
  attr_writer :id
22
23
 
24
+ #
25
+ # Initialize
26
+ #
27
+ # @param [Hash] data
28
+ # @param [String] yaml
29
+ #
23
30
  def initialize(data, yaml)
24
31
  @data = data.deep_symbolize_keys
25
32
  @yaml = yaml
26
33
 
27
34
  @errors = nil
28
- @no_method_error = nil
29
35
 
30
36
  validate
31
37
  end
@@ -39,41 +45,19 @@ module Mihari
39
45
  !@errors.empty?
40
46
  end
41
47
 
42
- #
43
- # @return [Array<String>]
44
- #
45
- def error_messages
46
- return [] if @errors.nil?
47
-
48
- @errors.messages.filter_map do |message|
49
- path = message.path.map(&:to_s).join
50
- "#{path} #{message.text}"
51
- rescue NoMethodError
52
- nil
53
- end
54
- end
55
-
56
48
  def validate
57
- begin
58
- contract = Schemas::RuleContract.new
59
- result = contract.call(data)
60
- rescue NoMethodError => e
61
- @no_method_error = e
62
- return
63
- end
49
+ contract = Schemas::RuleContract.new
50
+ result = contract.call(data)
64
51
 
65
52
  @data = result.to_h
66
53
  @errors = result.errors
67
54
  end
68
55
 
69
56
  def validate!
70
- raise RuleValidationError, "Data should be a hash" unless data.is_a?(Hash)
71
- raise RuleValidationError, error_messages.join("\n") if errors?
72
- raise RuleValidationError, "Something wrong with queries, emitters or enrichers." unless @no_method_error.nil?
57
+ raise RuleValidationError if errors?
73
58
  rescue RuleValidationError => e
74
- message = "Failed to parse the input as a rule"
75
- message += ": #{e.message}" unless e.message.empty?
76
- Mihari.logger.error message
59
+ Mihari.logger.error "Failed to parse the input as a rule:"
60
+ Mihari.logger.error JSON.pretty_generate(errors.to_h)
77
61
 
78
62
  raise e
79
63
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mihari
4
- VERSION = "4.7.2"
4
+ VERSION = "4.8.0"
5
5
  end
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><link rel="icon" href="/static/favicon.ico"/><title>Mihari</title><script defer="defer" src="/static/js/chunk-vendors.37b7208e.js"></script><script defer="defer" src="/static/js/app.3ac3bd7a.js"></script><link href="/static/css/chunk-vendors.5013d549.css" rel="stylesheet"><link href="/static/css/app.2a5d3d21.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but Mihari doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><link rel="icon" href="/static/favicon.ico"/><title>Mihari</title><script defer="defer" src="/static/js/chunk-vendors.723e02cf.js"></script><script defer="defer" src="/static/js/app.6413bf4f.js"></script><link href="/static/css/chunk-vendors.380724be.css" rel="stylesheet"><link href="/static/css/app.2a5d3d21.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but Mihari doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>