mihari 4.12.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Steepfile +0 -1
- data/lib/mihari/analyzers/base.rb +18 -37
- data/lib/mihari/analyzers/rule.rb +23 -36
- data/lib/mihari/cli/main.rb +6 -11
- data/lib/mihari/commands/initializer.rb +47 -0
- data/lib/mihari/commands/searcher.rb +57 -0
- data/lib/mihari/commands/validator.rb +2 -2
- data/lib/mihari/constants.rb +3 -3
- data/lib/mihari/database.rb +52 -87
- data/lib/mihari/emitters/database.rb +16 -7
- data/lib/mihari/emitters/misp.rb +13 -5
- data/lib/mihari/emitters/slack.rb +15 -8
- data/lib/mihari/emitters/the_hive.rb +42 -21
- data/lib/mihari/emitters/webhook.rb +99 -31
- data/lib/mihari/entities/alert.rb +7 -5
- data/lib/mihari/entities/artifact.rb +20 -8
- data/lib/mihari/entities/config.rb +2 -6
- data/lib/mihari/entities/rule.rb +8 -0
- data/lib/mihari/http.rb +13 -13
- data/lib/mihari/mixins/{disallowed_data_value.rb → falsepositive.rb} +8 -8
- data/lib/mihari/models/alert.rb +2 -15
- data/lib/mihari/models/artifact.rb +28 -17
- data/lib/mihari/models/rule.rb +7 -13
- data/lib/mihari/schemas/emitter.rb +6 -8
- data/lib/mihari/schemas/rule.rb +11 -13
- data/lib/mihari/structs/config.rb +41 -0
- data/lib/mihari/structs/filters.rb +2 -2
- data/lib/mihari/structs/rule.rb +94 -85
- data/lib/mihari/templates/rule.yml.erb +5 -23
- data/lib/mihari/types.rb +1 -1
- data/lib/mihari/version.rb +1 -1
- data/lib/mihari/web/api.rb +0 -2
- data/lib/mihari/web/endpoints/alerts.rb +11 -3
- data/lib/mihari/web/endpoints/configs.rb +1 -6
- data/lib/mihari/web/endpoints/rules.rb +27 -15
- data/lib/mihari/web/public/assets/{fa-brands-400-b1d1c1b0.ttf → fa-brands-400-2ef6fdde.ttf} +0 -0
- data/lib/mihari/web/public/assets/fa-brands-400-f4617423.woff2 +0 -0
- data/lib/mihari/web/public/assets/fa-regular-400-12dea17b.ttf +0 -0
- data/lib/mihari/web/public/assets/fa-regular-400-7ba24c41.woff2 +0 -0
- data/lib/mihari/web/public/assets/fa-solid-900-67a880b4.ttf +0 -0
- data/lib/mihari/web/public/assets/fa-solid-900-e2c5cf54.woff2 +0 -0
- data/lib/mihari/web/public/assets/fa-v4compatibility-7c377405.woff2 +0 -0
- data/lib/mihari/web/public/assets/fa-v4compatibility-8d9500e8.ttf +0 -0
- data/lib/mihari/web/public/assets/{index-07aa1ba2.css → index-625e95fe.css} +3 -3
- data/lib/mihari/web/public/assets/index-63900d73.js +50 -0
- data/lib/mihari/web/public/index.html +2 -2
- data/lib/mihari/web/public/redoc-static.html +26 -27
- data/lib/mihari.rb +11 -21
- data/mihari.gemspec +4 -4
- metadata +25 -111
- data/lib/mihari/cli/init.rb +0 -11
- data/lib/mihari/cli/validator.rb +0 -11
- data/lib/mihari/commands/init.rb +0 -51
- data/lib/mihari/commands/search.rb +0 -63
- data/lib/mihari/emitters/http.rb +0 -127
- data/lib/mihari/entities/source.rb +0 -9
- data/lib/mihari/status.rb +0 -55
- data/lib/mihari/web/endpoints/sources.rb +0 -19
- data/lib/mihari/web/public/assets/fa-brands-400-c61287c2.woff2 +0 -0
- data/lib/mihari/web/public/assets/fa-regular-400-5da313b0.woff2 +0 -0
- data/lib/mihari/web/public/assets/fa-regular-400-d7b19fe2.ttf +0 -0
- data/lib/mihari/web/public/assets/fa-solid-900-8f06540f.woff2 +0 -0
- data/lib/mihari/web/public/assets/fa-solid-900-e4f6a7e9.ttf +0 -0
- data/lib/mihari/web/public/assets/fa-v4compatibility-2ddb3b41.ttf +0 -0
- data/lib/mihari/web/public/assets/fa-v4compatibility-f46715c9.woff2 +0 -0
- data/lib/mihari/web/public/assets/index-a7fe697b.js +0 -63
- data/sig/lib/mihari/analyzers/base.rbs +0 -90
- data/sig/lib/mihari/analyzers/binaryedge.rbs +0 -26
- data/sig/lib/mihari/analyzers/censys.rbs +0 -41
- data/sig/lib/mihari/analyzers/circl.rbs +0 -31
- data/sig/lib/mihari/analyzers/crtsh.rbs +0 -17
- data/sig/lib/mihari/analyzers/dnpedia.rbs +0 -15
- data/sig/lib/mihari/analyzers/dnstwister.rbs +0 -25
- data/sig/lib/mihari/analyzers/feed.rbs +0 -20
- data/sig/lib/mihari/analyzers/onyphe.rbs +0 -34
- data/sig/lib/mihari/analyzers/otx.rbs +0 -33
- data/sig/lib/mihari/analyzers/passivetotal.rbs +0 -35
- data/sig/lib/mihari/analyzers/pulsedive.rbs +0 -27
- data/sig/lib/mihari/analyzers/rule.rbs +0 -68
- data/sig/lib/mihari/analyzers/securitytrails.rbs +0 -33
- data/sig/lib/mihari/analyzers/shodan.rbs +0 -36
- data/sig/lib/mihari/analyzers/urlscan.rbs +0 -31
- data/sig/lib/mihari/analyzers/virustotal.rbs +0 -31
- data/sig/lib/mihari/analyzers/virustotal_intelligence.rbs +0 -33
- data/sig/lib/mihari/analyzers/zoomeye.rbs +0 -35
- data/sig/lib/mihari/cli/base.rbs +0 -9
- data/sig/lib/mihari/cli/init.rbs +0 -7
- data/sig/lib/mihari/cli/main.rbs +0 -9
- data/sig/lib/mihari/cli/validator.rbs +0 -7
- data/sig/lib/mihari/commands/init.rbs +0 -9
- data/sig/lib/mihari/commands/json.rbs +0 -7
- data/sig/lib/mihari/commands/search.rbs +0 -35
- data/sig/lib/mihari/commands/validator.rbs +0 -9
- data/sig/lib/mihari/commands/web.rbs +0 -7
- data/sig/lib/mihari/constants.rbs +0 -5
- data/sig/lib/mihari/database.rbs +0 -25
- data/sig/lib/mihari/emitters/base.rbs +0 -18
- data/sig/lib/mihari/emitters/database.rbs +0 -9
- data/sig/lib/mihari/emitters/http.rbs +0 -35
- data/sig/lib/mihari/emitters/misp.rbs +0 -34
- data/sig/lib/mihari/emitters/slack.rbs +0 -73
- data/sig/lib/mihari/emitters/stdout.rbs +0 -9
- data/sig/lib/mihari/emitters/the_hive.rbs +0 -32
- data/sig/lib/mihari/emitters/webhook.rbs +0 -20
- data/sig/lib/mihari/enrichers/base.rbs +0 -12
- data/sig/lib/mihari/enrichers/google_public_dns.rbs +0 -18
- data/sig/lib/mihari/enrichers/ipinfo.rbs +0 -16
- data/sig/lib/mihari/errors.rbs +0 -10
- data/sig/lib/mihari/feed/parser.rbs +0 -11
- data/sig/lib/mihari/feed/reader.rbs +0 -56
- data/sig/lib/mihari/http.rbs +0 -64
- data/sig/lib/mihari/mixins/autonomous_system.rbs +0 -14
- data/sig/lib/mihari/mixins/configurable.rbs +0 -30
- data/sig/lib/mihari/mixins/configuration.rbs +0 -45
- data/sig/lib/mihari/mixins/disallowed_data_value.rbs +0 -23
- data/sig/lib/mihari/mixins/error_notification.rbs +0 -12
- data/sig/lib/mihari/mixins/hash.rbs +0 -14
- data/sig/lib/mihari/mixins/refang.rbs +0 -14
- data/sig/lib/mihari/mixins/retriable.rbs +0 -15
- data/sig/lib/mihari/models/alert.rbs +0 -18
- data/sig/lib/mihari/models/artifact.rbs +0 -69
- data/sig/lib/mihari/models/autonomous_system.rbs +0 -14
- data/sig/lib/mihari/models/cpe.rbs +0 -7
- data/sig/lib/mihari/models/dns.rbs +0 -19
- data/sig/lib/mihari/models/geolocation.rbs +0 -15
- data/sig/lib/mihari/models/port.rbs +0 -7
- data/sig/lib/mihari/models/reverse_dns.rbs +0 -14
- data/sig/lib/mihari/models/rule.rbs +0 -17
- data/sig/lib/mihari/models/tag.rbs +0 -5
- data/sig/lib/mihari/models/tagging.rbs +0 -4
- data/sig/lib/mihari/models/whois.rbs +0 -66
- data/sig/lib/mihari/status.rbs +0 -25
- data/sig/lib/mihari/structs/censys.rbs +0 -58
- data/sig/lib/mihari/structs/filters.rbs +0 -40
- data/sig/lib/mihari/structs/google_public_dns.rbs +0 -21
- data/sig/lib/mihari/structs/greynoise.rbs +0 -30
- data/sig/lib/mihari/structs/ipinfo.rbs +0 -17
- data/sig/lib/mihari/structs/onyphe.rbs +0 -25
- data/sig/lib/mihari/structs/rule.rbs +0 -57
- data/sig/lib/mihari/structs/shodan.rbs +0 -30
- data/sig/lib/mihari/structs/urlscan.rbs +0 -28
- data/sig/lib/mihari/structs/virustotal_intelligence.rbs +0 -33
- data/sig/lib/mihari/type_checker.rbs +0 -48
- data/sig/lib/mihari/types.rbs +0 -23
- data/sig/lib/mihari/version.rbs +0 -3
- data/sig/lib/mihari/web/app.rbs +0 -5
- data/sig/lib/mihari.rbs +0 -54
@@ -4,9 +4,19 @@ module Mihari
|
|
4
4
|
module Endpoints
|
5
5
|
class Rules < Grape::API
|
6
6
|
namespace :rules do
|
7
|
+
desc "Get Rule IDs", {
|
8
|
+
is_array: true,
|
9
|
+
success: Entities::RuleIDs,
|
10
|
+
summary: "Get rule IDs"
|
11
|
+
}
|
12
|
+
get "/ids" do
|
13
|
+
rule_ids = Mihari::Rule.distinct.pluck(:id)
|
14
|
+
present({ rule_ids: rule_ids }, with: Entities::RuleIDs)
|
15
|
+
end
|
16
|
+
|
7
17
|
desc "Search rules", {
|
8
18
|
is_array: true,
|
9
|
-
success: Entities::
|
19
|
+
success: Entities::RulesWithPagination,
|
10
20
|
failure: [{ code: 404, message: "Not found", model: Entities::Message }],
|
11
21
|
summary: "Search rules"
|
12
22
|
}
|
@@ -40,7 +50,13 @@ module Mihari
|
|
40
50
|
rules = Mihari::Rule.search(search_filter_with_pagenation)
|
41
51
|
total = Mihari::Rule.count(search_filter_with_pagenation.without_pagination)
|
42
52
|
|
43
|
-
present(
|
53
|
+
present(
|
54
|
+
{ rules: rules,
|
55
|
+
total: total,
|
56
|
+
current_page: page,
|
57
|
+
page_size: limit },
|
58
|
+
with: Entities::RulesWithPagination
|
59
|
+
)
|
44
60
|
end
|
45
61
|
|
46
62
|
desc "Get a rule", {
|
@@ -60,7 +76,7 @@ module Mihari
|
|
60
76
|
error!({ message: "ID:#{id} is not found" }, 404)
|
61
77
|
end
|
62
78
|
|
63
|
-
present rule
|
79
|
+
present rule, with: Entities::Rule
|
64
80
|
end
|
65
81
|
|
66
82
|
desc "Run a rule", {
|
@@ -74,14 +90,12 @@ module Mihari
|
|
74
90
|
id = params["id"].to_s
|
75
91
|
|
76
92
|
begin
|
77
|
-
rule = Mihari::Rule.find(id)
|
93
|
+
rule = Mihari::Structs::Rule.from_model(Mihari::Rule.find(id))
|
78
94
|
rescue ActiveRecord::RecordNotFound
|
79
95
|
error!({ message: "ID:#{id} is not found" }, 404)
|
80
96
|
end
|
81
97
|
|
82
|
-
|
83
|
-
analyzer = struct.to_analyzer
|
84
|
-
analyzer.run
|
98
|
+
rule.analyzer.run
|
85
99
|
|
86
100
|
status 201
|
87
101
|
present({ message: "ID:#{id} is ran successfully" }, with: Entities::Message)
|
@@ -121,14 +135,13 @@ module Mihari
|
|
121
135
|
end
|
122
136
|
|
123
137
|
begin
|
124
|
-
|
125
|
-
model.save
|
138
|
+
rule.model.save
|
126
139
|
rescue ActiveRecord::RecordNotUnique
|
127
140
|
error!({ message: "ID:#{rule.id} is already registered" }, 400)
|
128
141
|
end
|
129
142
|
|
130
143
|
status 201
|
131
|
-
present model
|
144
|
+
present rule.model, with: Entities::Rule
|
132
145
|
end
|
133
146
|
|
134
147
|
desc "Update a rule", {
|
@@ -150,7 +163,7 @@ module Mihari
|
|
150
163
|
end
|
151
164
|
|
152
165
|
begin
|
153
|
-
rule = Structs::Rule.from_yaml(yaml
|
166
|
+
rule = Structs::Rule.from_yaml(yaml)
|
154
167
|
rescue YAMLSyntaxError => e
|
155
168
|
error!({ message: e.message }, 400)
|
156
169
|
end
|
@@ -165,14 +178,13 @@ module Mihari
|
|
165
178
|
end
|
166
179
|
|
167
180
|
begin
|
168
|
-
|
169
|
-
model.save
|
181
|
+
rule.model.save
|
170
182
|
rescue ActiveRecord::RecordNotUnique
|
171
|
-
error!({ message: "ID:#{
|
183
|
+
error!({ message: "ID:#{id} is already registered" }, 400)
|
172
184
|
end
|
173
185
|
|
174
186
|
status 201
|
175
|
-
present model
|
187
|
+
present rule.model, with: Entities::Rule
|
176
188
|
end
|
177
189
|
|
178
190
|
desc "Delete a rule", {
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|