mihari 7.0.3 → 7.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mihari/commands/rule.rb +0 -2
- data/lib/mihari/rule.rb +13 -1
- data/lib/mihari/version.rb +1 -1
- data/lib/mihari/web/endpoints/ip_addresses.rb +9 -5
- data/lib/mihari/web/endpoints/rules.rb +6 -5
- data/lib/mihari/web/middleware/capture_exceptions.rb +0 -2
- data/lib/mihari/web/public/assets/{index-cQUcyII5.js → index-yeHDhqt5.js} +17 -17
- data/lib/mihari/web/public/index.html +1 -1
- data/mihari.gemspec +5 -4
- data/mkdocs.yml +1 -1
- metadata +33 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5859aa404d85ccc45008979195ace2c4104cc86336b65afacbeece226c7def5
|
4
|
+
data.tar.gz: 75f6687159420d8f0d7b5f2f13fbab7f523881ad55a66574a7a9ec612cf720ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9db820d33af592d9b2953a01e745ce05c3a297a6cbefb409e147fd90ab5d02070722abbba18b3f282bf9abcc1cc85f50d2579ab2774ea26074d74b6aea8d6073
|
7
|
+
data.tar.gz: 8218aaf062e8ecad9cf01f58188de497ffba135ce42269e7ff87b82d49cf96c0a46c0aa273e752da1f97b288ffead8569fa00c8d6452701273e9694bcf4dba74
|
data/lib/mihari/commands/rule.rb
CHANGED
data/lib/mihari/rule.rb
CHANGED
@@ -231,7 +231,7 @@ module Mihari
|
|
231
231
|
#
|
232
232
|
def diff?
|
233
233
|
model = Mihari::Models::Rule.find(id)
|
234
|
-
model.data !=
|
234
|
+
model.data != diff_comparable_data
|
235
235
|
rescue ActiveRecord::RecordNotFound
|
236
236
|
false
|
237
237
|
end
|
@@ -272,6 +272,18 @@ module Mihari
|
|
272
272
|
|
273
273
|
private
|
274
274
|
|
275
|
+
#
|
276
|
+
# @return [Hash]
|
277
|
+
#
|
278
|
+
def diff_comparable_data
|
279
|
+
# data is serialized as JSON so dates (created_on & updated_on) are stringified in there
|
280
|
+
# thus dates & (hash) keys have to be stringified when comparing
|
281
|
+
data.deep_dup.tap do |data|
|
282
|
+
data[:created_on] = data[:created_on].to_s
|
283
|
+
data[:updated_on] = data[:updated_on].to_s
|
284
|
+
end.deep_stringify_keys
|
285
|
+
end
|
286
|
+
|
275
287
|
#
|
276
288
|
# Check whether a value is a falsepositive value or not
|
277
289
|
#
|
data/lib/mihari/version.rb
CHANGED
@@ -8,13 +8,16 @@ module Mihari
|
|
8
8
|
#
|
9
9
|
class IPAddresses < Grape::API
|
10
10
|
namespace :ip_addresses do
|
11
|
-
desc "Get
|
11
|
+
desc "Get IP address data", {
|
12
12
|
success: Entities::IPAddress,
|
13
|
-
failure: [
|
14
|
-
|
13
|
+
failure: [
|
14
|
+
{ code: 404, model: Entities::ErrorMessage },
|
15
|
+
{ code: 422, model: Entities::ErrorMessage }
|
16
|
+
],
|
17
|
+
summary: "Get IP address data"
|
15
18
|
}
|
16
19
|
params do
|
17
|
-
requires :ip, type: String
|
20
|
+
requires :ip, type: String
|
18
21
|
end
|
19
22
|
get "/:ip", requirements: { ip: %r{[^/]+} } do
|
20
23
|
ip = params[:ip].to_s
|
@@ -34,7 +37,8 @@ module Mihari
|
|
34
37
|
failure = result.failure
|
35
38
|
case failure
|
36
39
|
when Mihari::StatusCodeError
|
37
|
-
error!({ message: "
|
40
|
+
error!({ message: "IP:#{ip} not found" }, failure.status_code) if failure.status_code == 404
|
41
|
+
error!({ message: "IP format invalid" }, failure.status_code) if failure.status_code == 422
|
38
42
|
end
|
39
43
|
raise failure
|
40
44
|
end
|
@@ -17,7 +17,10 @@ module Mihari
|
|
17
17
|
def call(yaml, overwrite: true)
|
18
18
|
rule = Rule.from_yaml(yaml)
|
19
19
|
|
20
|
-
|
20
|
+
# To invoke ActiveRecord::RecordNotFound
|
21
|
+
Models::Rule.find(rule.id) if overwrite
|
22
|
+
|
23
|
+
raise IntegrityError, "ID:#{rule.id} already registered" if rule.exists? && !overwrite
|
21
24
|
|
22
25
|
rule.update_or_create
|
23
26
|
rule
|
@@ -141,13 +144,11 @@ module Mihari
|
|
141
144
|
summary: "Update a rule"
|
142
145
|
}
|
143
146
|
params do
|
144
|
-
requires :id, type: String, documentation: { param_type: "body" }
|
145
147
|
requires :yaml, type: String, documentation: { param_type: "body" }
|
146
148
|
end
|
147
149
|
put "/" do
|
148
150
|
status 201
|
149
151
|
|
150
|
-
id = params[:id].to_s
|
151
152
|
yaml = params[:yaml].to_s
|
152
153
|
|
153
154
|
result = RuleCreateUpdater.result(yaml, overwrite: true)
|
@@ -156,11 +157,11 @@ module Mihari
|
|
156
157
|
failure = result.failure
|
157
158
|
case failure
|
158
159
|
when ActiveRecord::RecordNotFound
|
159
|
-
error!({ message: "
|
160
|
+
error!({ message: "Rule not found" }, 404)
|
160
161
|
when Psych::SyntaxError
|
161
162
|
error!({ message: failure.message }, 422)
|
162
163
|
when ValidationError
|
163
|
-
error!({ message: "Rule format
|
164
|
+
error!({ message: "Rule format invalid", detail: failure.errors.to_h }, 422)
|
164
165
|
end
|
165
166
|
raise failure
|
166
167
|
end
|