mihari 4.7.4 → 4.9.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/.rubocop.yml +4 -0
- data/README.md +0 -1
- data/lib/mihari/analyzers/rule.rb +0 -1
- data/lib/mihari/commands/search.rb +8 -2
- data/lib/mihari/commands/validator.rb +2 -1
- data/lib/mihari/schemas/analyzer.rb +0 -7
- data/lib/mihari/schemas/rule.rb +4 -4
- data/lib/mihari/structs/rule.rb +12 -28
- data/lib/mihari/version.rb +1 -1
- data/lib/mihari/web/public/index.html +1 -1
- data/lib/mihari/web/public/redoc-static.html +282 -246
- data/lib/mihari/web/public/static/css/{chunk-vendors.5013d549.css → chunk-vendors.380724be.css} +2 -2
- data/lib/mihari/web/public/static/fonts/fa-brands-400.86c7e1fa.woff2 +0 -0
- data/lib/mihari/web/public/static/fonts/{fa-brands-400.7fa789ab.ttf → fa-brands-400.f5defc2e.ttf} +0 -0
- data/lib/mihari/web/public/static/fonts/{fa-regular-400.da02cb7e.ttf → fa-regular-400.3edb9004.ttf} +0 -0
- data/lib/mihari/web/public/static/fonts/fa-regular-400.e0550912.woff2 +0 -0
- data/lib/mihari/web/public/static/fonts/fa-solid-900.64d5644d.woff2 +0 -0
- data/lib/mihari/web/public/static/fonts/{fa-solid-900.3a463ec3.ttf → fa-solid-900.f418d876.ttf} +0 -0
- data/lib/mihari/web/public/static/fonts/{fa-v4compatibility.924588dc.ttf → fa-v4compatibility.7e7e1dad.ttf} +0 -0
- data/lib/mihari/web/public/static/js/app.6413bf4f.js +2 -0
- data/lib/mihari/web/public/static/js/app.6413bf4f.js.map +1 -0
- data/lib/mihari/web/public/static/js/chunk-vendors.723e02cf.js +31 -0
- data/lib/mihari/web/public/static/js/chunk-vendors.723e02cf.js.map +1 -0
- data/lib/mihari.rb +0 -1
- data/mihari.gemspec +13 -13
- metadata +41 -41
- data/lib/mihari/analyzers/spyse.rb +0 -93
- data/lib/mihari/web/public/static/fonts/fa-brands-400.859fc388.woff2 +0 -0
- data/lib/mihari/web/public/static/fonts/fa-regular-400.2ffd018f.woff2 +0 -0
- data/lib/mihari/web/public/static/fonts/fa-solid-900.40ddefd7.woff2 +0 -0
- data/lib/mihari/web/public/static/js/app.524d9ed2.js +0 -2
- data/lib/mihari/web/public/static/js/app.524d9ed2.js.map +0 -1
- data/lib/mihari/web/public/static/js/chunk-vendors.64580a1f.js +0 -31
- data/lib/mihari/web/public/static/js/chunk-vendors.64580a1f.js.map +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85756e55047ef3bde95c50c1ac3c474adbd29828bf1f95618f3aac85638a1752
|
4
|
+
data.tar.gz: babe64cf74a96f659057b06ac3b5864b6faa2c3ec9b7e3f0f9b57bce7dd635a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c15c65a8952c1fbcf695feba8add8a7fc962eaac9ca426a18dd510663573dc9fe6b27472ca0edcd1ff9fb86b68a49ce8c459e3a7d90eabe9dbbe1e4506181d8
|
7
|
+
data.tar.gz: aceb04f0f6e78af7f0df2293d78a4d4d20bcf1827e70d45e3f425e38b128c5f9194dbdac608b29b44852af77b626ccbdd03583e7170d5330a2b584c7cbdca55b
|
data/.rubocop.yml
ADDED
data/README.md
CHANGED
@@ -44,7 +44,6 @@ Mihari supports the following services by default.
|
|
44
44
|
- [Pulsedive](https://pulsedive.com/)
|
45
45
|
- [SecurityTrails](https://securitytrails.com/)
|
46
46
|
- [Shodan](https://shodan.io)
|
47
|
-
- [Spyse](https://spyse.com)
|
48
47
|
- [urlscan.io](https://urlscan.io)
|
49
48
|
- [VirusTotal](http://virustotal.com) & [VirusTotal Intelligence](https://www.virustotal.com/gui/intelligence-overview)
|
50
49
|
- [ZoomEye](https://zoomeye.org)
|
@@ -14,7 +14,11 @@ module Mihari
|
|
14
14
|
rule = Structs::Rule.from_path_or_id path_or_id
|
15
15
|
|
16
16
|
# validate
|
17
|
-
|
17
|
+
begin
|
18
|
+
rule.validate!
|
19
|
+
rescue RuleValidationError
|
20
|
+
return
|
21
|
+
end
|
18
22
|
|
19
23
|
# check update
|
20
24
|
id = rule.id
|
@@ -23,7 +27,9 @@ module Mihari
|
|
23
27
|
with_db_connection do
|
24
28
|
rule_ = Mihari::Rule.find(id)
|
25
29
|
next if rule.yaml == rule_.yaml
|
26
|
-
|
30
|
+
unless yes?("This operation will overwrite the rule in the database (Rule ID: #{id}). Are you sure you want to update the rule? (yes/no)")
|
31
|
+
return
|
32
|
+
end
|
27
33
|
rescue ActiveRecord::RecordNotFound
|
28
34
|
next
|
29
35
|
end
|
@@ -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
|
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
|
@@ -58,13 +58,6 @@ module Mihari
|
|
58
58
|
optional(:options).hash(AnalyzerOptions)
|
59
59
|
end
|
60
60
|
|
61
|
-
Spyse = Dry::Schema.Params do
|
62
|
-
required(:analyzer).value(Types::String.enum("spyse"))
|
63
|
-
required(:query).value(:string)
|
64
|
-
required(:type).value(Types::String.enum("ip", "domain"))
|
65
|
-
optional(:options).hash(AnalyzerOptions)
|
66
|
-
end
|
67
|
-
|
68
61
|
ZoomEye = Dry::Schema.Params do
|
69
62
|
required(:analyzer).value(Types::String.enum("zoomeye"))
|
70
63
|
required(:query).value(:string)
|
data/lib/mihari/schemas/rule.rb
CHANGED
@@ -22,7 +22,9 @@ module Mihari
|
|
22
22
|
optional(:created_on).value(:date)
|
23
23
|
optional(:updated_on).value(:date)
|
24
24
|
|
25
|
-
required(:queries).value(:array).each
|
25
|
+
required(:queries).value(:array).each do
|
26
|
+
AnalyzerWithoutAPIKey | AnalyzerWithAPIKey | Censys | CIRCL | PassiveTotal | ZoomEye | Urlscan | Crtsh | Feed
|
27
|
+
end
|
26
28
|
|
27
29
|
optional(:emitters).value(:array).each { Emitter | MISP | TheHive | Slack | HTTP }
|
28
30
|
|
@@ -57,9 +59,7 @@ module Mihari
|
|
57
59
|
|
58
60
|
rule(:disallowed_data_values) do
|
59
61
|
value.each do |v|
|
60
|
-
unless valid_disallowed_data_value?(v)
|
61
|
-
key.failure("#{v} is not a valid format.")
|
62
|
-
end
|
62
|
+
key.failure("#{v} is not a valid format.") unless valid_disallowed_data_value?(v)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
data/lib/mihari/structs/rule.rb
CHANGED
@@ -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
|
-
|
58
|
-
|
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
|
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
|
-
|
75
|
-
|
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
|
data/lib/mihari/version.rb
CHANGED
@@ -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.
|
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>
|