mihari 4.1.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -1
  3. data/README.md +1 -1
  4. data/Rakefile +5 -0
  5. data/config.ru +0 -1
  6. data/lib/mihari/analyzers/base.rb +18 -10
  7. data/lib/mihari/analyzers/rule.rb +1 -1
  8. data/lib/mihari/cli/base.rb +0 -4
  9. data/lib/mihari/commands/init.rb +1 -1
  10. data/lib/mihari/commands/search.rb +11 -58
  11. data/lib/mihari/commands/validator.rb +1 -2
  12. data/lib/mihari/database.rb +1 -1
  13. data/lib/mihari/emitters/base.rb +5 -2
  14. data/lib/mihari/emitters/slack.rb +40 -4
  15. data/lib/mihari/enrichers/base.rb +5 -2
  16. data/lib/mihari/enrichers/ipinfo.rb +4 -3
  17. data/lib/mihari/{web/entities → entities}/alert.rb +0 -0
  18. data/lib/mihari/{web/entities → entities}/artifact.rb +0 -0
  19. data/lib/mihari/{web/entities → entities}/autonomous_system.rb +0 -0
  20. data/lib/mihari/{web/entities → entities}/command.rb +0 -0
  21. data/lib/mihari/{web/entities → entities}/config.rb +0 -0
  22. data/lib/mihari/{web/entities → entities}/dns.rb +0 -0
  23. data/lib/mihari/{web/entities → entities}/geolocation.rb +0 -0
  24. data/lib/mihari/{web/entities → entities}/ip_address.rb +0 -0
  25. data/lib/mihari/{web/entities → entities}/message.rb +0 -0
  26. data/lib/mihari/{web/entities → entities}/reverse_dns.rb +0 -0
  27. data/lib/mihari/{web/entities → entities}/rule.rb +0 -0
  28. data/lib/mihari/{web/entities → entities}/source.rb +0 -0
  29. data/lib/mihari/{web/entities → entities}/tag.rb +0 -0
  30. data/lib/mihari/{web/entities → entities}/whois.rb +0 -0
  31. data/lib/mihari/errors.rb +2 -0
  32. data/lib/mihari/feed/reader.rb +11 -55
  33. data/lib/mihari/http.rb +94 -0
  34. data/lib/mihari/mixins/error_notification.rb +20 -0
  35. data/lib/mihari/mixins/retriable.rb +12 -2
  36. data/lib/mihari/mixins/rule.rb +1 -2
  37. data/lib/mihari/structs/ipinfo.rb +2 -3
  38. data/lib/mihari/structs/rule.rb +30 -0
  39. data/lib/mihari/structs/shodan.rb +9 -1
  40. data/lib/mihari/version.rb +1 -1
  41. data/lib/mihari/web/api.rb +0 -20
  42. data/lib/mihari/web/app.rb +3 -3
  43. data/lib/mihari/web/endpoints/rules.rb +3 -1
  44. data/lib/mihari/web/middleware/error_notification_adapter.rb +19 -0
  45. data/lib/mihari/web/public/index.html +1 -1
  46. data/lib/mihari/web/public/redoc-static.html +1881 -165
  47. data/lib/mihari/web/public/static/css/app.43138058.css +1 -0
  48. data/lib/mihari/web/public/static/css/chunk-vendors.3ed9b08e.css +7 -0
  49. data/lib/mihari/web/public/static/fonts/fa-brands-400.1fd0b4d7.ttf +0 -0
  50. data/lib/mihari/web/public/static/fonts/fa-brands-400.5d5236fb.woff2 +0 -0
  51. data/lib/mihari/web/public/static/fonts/fa-regular-400.64b3730e.woff2 +0 -0
  52. data/lib/mihari/web/public/static/fonts/fa-regular-400.95a8a8af.ttf +0 -0
  53. data/lib/mihari/web/public/static/fonts/fa-solid-900.6115ad71.woff2 +0 -0
  54. data/lib/mihari/web/public/static/fonts/fa-solid-900.f0203cfc.ttf +0 -0
  55. data/lib/mihari/web/public/static/fonts/fa-v4compatibility.e1023515.ttf +0 -0
  56. data/lib/mihari/web/public/static/js/app-legacy.46b666f0.js +2 -0
  57. data/lib/mihari/web/public/static/js/app-legacy.46b666f0.js.map +1 -0
  58. data/lib/mihari/web/public/static/js/app.4818aedd.js +2 -0
  59. data/lib/mihari/web/public/static/js/app.4818aedd.js.map +1 -0
  60. data/lib/mihari/web/public/static/js/app.b88ce341.js +35 -0
  61. data/lib/mihari/web/public/static/js/app.b88ce341.js.map +1 -0
  62. data/lib/mihari/web/public/static/js/chunk-vendors-legacy.c99e452e.js +17 -0
  63. data/lib/mihari/web/public/static/js/chunk-vendors-legacy.c99e452e.js.map +1 -0
  64. data/lib/mihari/web/public/static/js/chunk-vendors.15e84e22.js +23 -0
  65. data/lib/mihari/web/public/static/js/chunk-vendors.15e84e22.js.map +1 -0
  66. data/lib/mihari.rb +63 -15
  67. data/mihari.gemspec +12 -12
  68. data/sig/lib/mihari/emitters/slack.rbs +29 -1
  69. data/sig/lib/mihari/feed/reader.rbs +2 -2
  70. data/sig/lib/mihari/http.rbs +65 -0
  71. data/sig/lib/mihari/mixins/error_notification.rbs +12 -0
  72. data/sig/lib/mihari/structs/rule.rbs +6 -0
  73. data/sig/lib/mihari.rbs +4 -8
  74. metadata +88 -73
  75. data/lib/mihari/cli/mixins/utils.rb +0 -72
  76. data/lib/mihari/emitters/stdout.rb +0 -22
  77. data/lib/mihari/notifiers/base.rb +0 -24
  78. data/lib/mihari/notifiers/exception_notifier.rb +0 -126
  79. data/lib/mihari/notifiers/slack.rb +0 -63
  80. data/sig/lib/mihari/cli/mixins/utils.rbs +0 -50
  81. data/sig/lib/mihari/notifiers/base.rbs +0 -18
  82. data/sig/lib/mihari/notifiers/exception_notifier.rbs +0 -75
  83. data/sig/lib/mihari/notifiers/slack.rbs +0 -50
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mihari
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-23 00:00:00.000000000 Z
11
+ date: 2022-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.2'
89
+ version: '1.3'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.2'
96
+ version: '1.3'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rack-test
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -156,28 +156,28 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '3.10'
159
+ version: '3.11'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '3.10'
166
+ version: '3.11'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: standard
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '1.5'
173
+ version: '1.7'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '1.5'
180
+ version: '1.7'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: steep
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -240,14 +240,14 @@ dependencies:
240
240
  requirements:
241
241
  - - '='
242
242
  - !ruby/object:Gem::Version
243
- version: 7.0.1
243
+ version: 7.0.2.2
244
244
  type: :runtime
245
245
  prerelease: false
246
246
  version_requirements: !ruby/object:Gem::Requirement
247
247
  requirements:
248
248
  - - '='
249
249
  - !ruby/object:Gem::Version
250
- version: 7.0.1
250
+ version: 7.0.2.2
251
251
  - !ruby/object:Gem::Dependency
252
252
  name: addressable
253
253
  requirement: !ruby/object:Gem::Requirement
@@ -268,14 +268,14 @@ dependencies:
268
268
  requirements:
269
269
  - - "~>"
270
270
  - !ruby/object:Gem::Version
271
- version: '1.2'
271
+ version: '2.0'
272
272
  type: :runtime
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
276
  - - "~>"
277
277
  - !ruby/object:Gem::Version
278
- version: '1.2'
278
+ version: '2.0'
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: binaryedge
281
281
  requirement: !ruby/object:Gem::Requirement
@@ -304,20 +304,6 @@ dependencies:
304
304
  - - "~>"
305
305
  - !ruby/object:Gem::Version
306
306
  version: '0.1'
307
- - !ruby/object:Gem::Dependency
308
- name: colorize
309
- requirement: !ruby/object:Gem::Requirement
310
- requirements:
311
- - - "~>"
312
- - !ruby/object:Gem::Version
313
- version: '0.8'
314
- type: :runtime
315
- prerelease: false
316
- version_requirements: !ruby/object:Gem::Requirement
317
- requirements:
318
- - - "~>"
319
- - !ruby/object:Gem::Version
320
- version: '0.8'
321
307
  - !ruby/object:Gem::Dependency
322
308
  name: crtsh-rb
323
309
  requirement: !ruby/object:Gem::Requirement
@@ -450,14 +436,14 @@ dependencies:
450
436
  requirements:
451
437
  - - '='
452
438
  - !ruby/object:Gem::Version
453
- version: 1.7.0
439
+ version: 1.8.0
454
440
  type: :runtime
455
441
  prerelease: false
456
442
  version_requirements: !ruby/object:Gem::Requirement
457
443
  requirements:
458
444
  - - '='
459
445
  - !ruby/object:Gem::Version
460
- version: 1.7.0
446
+ version: 1.8.0
461
447
  - !ruby/object:Gem::Dependency
462
448
  name: email_address
463
449
  requirement: !ruby/object:Gem::Requirement
@@ -556,20 +542,6 @@ dependencies:
556
542
  - - "~>"
557
543
  - !ruby/object:Gem::Version
558
544
  version: '1.0'
559
- - !ruby/object:Gem::Dependency
560
- name: http
561
- requirement: !ruby/object:Gem::Requirement
562
- requirements:
563
- - - "~>"
564
- - !ruby/object:Gem::Version
565
- version: '5.0'
566
- type: :runtime
567
- prerelease: false
568
- version_requirements: !ruby/object:Gem::Requirement
569
- requirements:
570
- - - "~>"
571
- - !ruby/object:Gem::Version
572
- version: '5.0'
573
545
  - !ruby/object:Gem::Dependency
574
546
  name: jr-cli
575
547
  requirement: !ruby/object:Gem::Requirement
@@ -644,14 +616,14 @@ dependencies:
644
616
  name: normalize_country
645
617
  requirement: !ruby/object:Gem::Requirement
646
618
  requirements:
647
- - - '='
619
+ - - "~>"
648
620
  - !ruby/object:Gem::Version
649
621
  version: '0.3'
650
622
  type: :runtime
651
623
  prerelease: false
652
624
  version_requirements: !ruby/object:Gem::Requirement
653
625
  requirements:
654
- - - '='
626
+ - - "~>"
655
627
  - !ruby/object:Gem::Version
656
628
  version: '0.3'
657
629
  - !ruby/object:Gem::Dependency
@@ -730,14 +702,14 @@ dependencies:
730
702
  requirements:
731
703
  - - "~>"
732
704
  - !ruby/object:Gem::Version
733
- version: '1.4'
705
+ version: '2.0'
734
706
  type: :runtime
735
707
  prerelease: false
736
708
  version_requirements: !ruby/object:Gem::Requirement
737
709
  requirements:
738
710
  - - "~>"
739
711
  - !ruby/object:Gem::Version
740
- version: '1.4'
712
+ version: '2.0'
741
713
  - !ruby/object:Gem::Dependency
742
714
  name: public_suffix
743
715
  requirement: !ruby/object:Gem::Requirement
@@ -772,14 +744,14 @@ dependencies:
772
744
  requirements:
773
745
  - - '='
774
746
  - !ruby/object:Gem::Version
775
- version: 5.5.2
747
+ version: 5.6.2
776
748
  type: :runtime
777
749
  prerelease: false
778
750
  version_requirements: !ruby/object:Gem::Requirement
779
751
  requirements:
780
752
  - - '='
781
753
  - !ruby/object:Gem::Version
782
- version: 5.5.2
754
+ version: 5.6.2
783
755
  - !ruby/object:Gem::Dependency
784
756
  name: rack
785
757
  requirement: !ruby/object:Gem::Requirement
@@ -850,6 +822,34 @@ dependencies:
850
822
  - - "~>"
851
823
  - !ruby/object:Gem::Version
852
824
  version: '1.0'
825
+ - !ruby/object:Gem::Dependency
826
+ name: semantic_logger
827
+ requirement: !ruby/object:Gem::Requirement
828
+ requirements:
829
+ - - "~>"
830
+ - !ruby/object:Gem::Version
831
+ version: '4.10'
832
+ type: :runtime
833
+ prerelease: false
834
+ version_requirements: !ruby/object:Gem::Requirement
835
+ requirements:
836
+ - - "~>"
837
+ - !ruby/object:Gem::Version
838
+ version: '4.10'
839
+ - !ruby/object:Gem::Dependency
840
+ name: sentry-ruby
841
+ requirement: !ruby/object:Gem::Requirement
842
+ requirements:
843
+ - - "~>"
844
+ - !ruby/object:Gem::Version
845
+ version: 5.1.1
846
+ type: :runtime
847
+ prerelease: false
848
+ version_requirements: !ruby/object:Gem::Requirement
849
+ requirements:
850
+ - - "~>"
851
+ - !ruby/object:Gem::Version
852
+ version: 5.1.1
853
853
  - !ruby/object:Gem::Dependency
854
854
  name: shodanx
855
855
  requirement: !ruby/object:Gem::Requirement
@@ -912,14 +912,14 @@ dependencies:
912
912
  requirements:
913
913
  - - '='
914
914
  - !ruby/object:Gem::Version
915
- version: 1.1.0
915
+ version: 1.2.1
916
916
  type: :runtime
917
917
  prerelease: false
918
918
  version_requirements: !ruby/object:Gem::Requirement
919
919
  requirements:
920
920
  - - '='
921
921
  - !ruby/object:Gem::Version
922
- version: 1.1.0
922
+ version: 1.2.1
923
923
  - !ruby/object:Gem::Dependency
924
924
  name: thread_safe
925
925
  requirement: !ruby/object:Gem::Requirement
@@ -1080,7 +1080,6 @@ files:
1080
1080
  - lib/mihari/cli/base.rb
1081
1081
  - lib/mihari/cli/init.rb
1082
1082
  - lib/mihari/cli/main.rb
1083
- - lib/mihari/cli/mixins/utils.rb
1084
1083
  - lib/mihari/cli/validator.rb
1085
1084
  - lib/mihari/commands/init.rb
1086
1085
  - lib/mihari/commands/search.rb
@@ -1092,18 +1091,33 @@ files:
1092
1091
  - lib/mihari/emitters/database.rb
1093
1092
  - lib/mihari/emitters/misp.rb
1094
1093
  - lib/mihari/emitters/slack.rb
1095
- - lib/mihari/emitters/stdout.rb
1096
1094
  - lib/mihari/emitters/the_hive.rb
1097
1095
  - lib/mihari/emitters/webhook.rb
1098
1096
  - lib/mihari/enrichers/base.rb
1099
1097
  - lib/mihari/enrichers/ipinfo.rb
1098
+ - lib/mihari/entities/alert.rb
1099
+ - lib/mihari/entities/artifact.rb
1100
+ - lib/mihari/entities/autonomous_system.rb
1101
+ - lib/mihari/entities/command.rb
1102
+ - lib/mihari/entities/config.rb
1103
+ - lib/mihari/entities/dns.rb
1104
+ - lib/mihari/entities/geolocation.rb
1105
+ - lib/mihari/entities/ip_address.rb
1106
+ - lib/mihari/entities/message.rb
1107
+ - lib/mihari/entities/reverse_dns.rb
1108
+ - lib/mihari/entities/rule.rb
1109
+ - lib/mihari/entities/source.rb
1110
+ - lib/mihari/entities/tag.rb
1111
+ - lib/mihari/entities/whois.rb
1100
1112
  - lib/mihari/errors.rb
1101
1113
  - lib/mihari/feed/parser.rb
1102
1114
  - lib/mihari/feed/reader.rb
1115
+ - lib/mihari/http.rb
1103
1116
  - lib/mihari/mixins/autonomous_system.rb
1104
1117
  - lib/mihari/mixins/configurable.rb
1105
1118
  - lib/mihari/mixins/database.rb
1106
1119
  - lib/mihari/mixins/disallowed_data_value.rb
1120
+ - lib/mihari/mixins/error_notification.rb
1107
1121
  - lib/mihari/mixins/refang.rb
1108
1122
  - lib/mihari/mixins/retriable.rb
1109
1123
  - lib/mihari/mixins/rule.rb
@@ -1117,9 +1131,6 @@ files:
1117
1131
  - lib/mihari/models/tag.rb
1118
1132
  - lib/mihari/models/tagging.rb
1119
1133
  - lib/mihari/models/whois.rb
1120
- - lib/mihari/notifiers/base.rb
1121
- - lib/mihari/notifiers/exception_notifier.rb
1122
- - lib/mihari/notifiers/slack.rb
1123
1134
  - lib/mihari/schemas/analyzer.rb
1124
1135
  - lib/mihari/schemas/macros.rb
1125
1136
  - lib/mihari/schemas/rule.rb
@@ -1147,36 +1158,29 @@ files:
1147
1158
  - lib/mihari/web/endpoints/rules.rb
1148
1159
  - lib/mihari/web/endpoints/sources.rb
1149
1160
  - lib/mihari/web/endpoints/tags.rb
1150
- - lib/mihari/web/entities/alert.rb
1151
- - lib/mihari/web/entities/artifact.rb
1152
- - lib/mihari/web/entities/autonomous_system.rb
1153
- - lib/mihari/web/entities/command.rb
1154
- - lib/mihari/web/entities/config.rb
1155
- - lib/mihari/web/entities/dns.rb
1156
- - lib/mihari/web/entities/geolocation.rb
1157
- - lib/mihari/web/entities/ip_address.rb
1158
- - lib/mihari/web/entities/message.rb
1159
- - lib/mihari/web/entities/reverse_dns.rb
1160
- - lib/mihari/web/entities/rule.rb
1161
- - lib/mihari/web/entities/source.rb
1162
- - lib/mihari/web/entities/tag.rb
1163
- - lib/mihari/web/entities/whois.rb
1164
1161
  - lib/mihari/web/middleware/connection_adapter.rb
1162
+ - lib/mihari/web/middleware/error_notification_adapter.rb
1165
1163
  - lib/mihari/web/public/index.html
1166
1164
  - lib/mihari/web/public/redoc-static.html
1165
+ - lib/mihari/web/public/static/css/app.43138058.css
1166
+ - lib/mihari/web/public/static/css/chunk-vendors.3ed9b08e.css
1167
1167
  - lib/mihari/web/public/static/favicon.ico
1168
1168
  - lib/mihari/web/public/static/fonts/fa-brands-400.099a9556.woff
1169
1169
  - lib/mihari/web/public/static/fonts/fa-brands-400.1a575a41.woff
1170
+ - lib/mihari/web/public/static/fonts/fa-brands-400.1fd0b4d7.ttf
1170
1171
  - lib/mihari/web/public/static/fonts/fa-brands-400.30cc681d.eot
1171
1172
  - lib/mihari/web/public/static/fonts/fa-brands-400.3b89dd10.ttf
1172
1173
  - lib/mihari/web/public/static/fonts/fa-brands-400.513aa607.ttf
1173
1174
  - lib/mihari/web/public/static/fonts/fa-brands-400.592643a8.eot
1175
+ - lib/mihari/web/public/static/fonts/fa-brands-400.5d5236fb.woff2
1174
1176
  - lib/mihari/web/public/static/fonts/fa-brands-400.ed311c7a.woff2
1175
1177
  - lib/mihari/web/public/static/fonts/fa-brands-400.f7307680.woff2
1176
1178
  - lib/mihari/web/public/static/fonts/fa-regular-400.1f77739c.ttf
1179
+ - lib/mihari/web/public/static/fonts/fa-regular-400.64b3730e.woff2
1177
1180
  - lib/mihari/web/public/static/fonts/fa-regular-400.7124eb50.woff
1178
1181
  - lib/mihari/web/public/static/fonts/fa-regular-400.7630483d.eot
1179
1182
  - lib/mihari/web/public/static/fonts/fa-regular-400.766913e6.ttf
1183
+ - lib/mihari/web/public/static/fonts/fa-regular-400.95a8a8af.ttf
1180
1184
  - lib/mihari/web/public/static/fonts/fa-regular-400.b0e2db3b.eot
1181
1185
  - lib/mihari/web/public/static/fonts/fa-regular-400.b91d376b.woff2
1182
1186
  - lib/mihari/web/public/static/fonts/fa-regular-400.d1d7e3b4.woff
@@ -1184,17 +1188,22 @@ files:
1184
1188
  - lib/mihari/web/public/static/fonts/fa-solid-900.0c6bfc66.eot
1185
1189
  - lib/mihari/web/public/static/fonts/fa-solid-900.1042e8ca.eot
1186
1190
  - lib/mihari/web/public/static/fonts/fa-solid-900.605ed792.ttf
1191
+ - lib/mihari/web/public/static/fonts/fa-solid-900.6115ad71.woff2
1187
1192
  - lib/mihari/web/public/static/fonts/fa-solid-900.9fe5a17c.woff
1188
1193
  - lib/mihari/web/public/static/fonts/fa-solid-900.b9625119.ttf
1189
1194
  - lib/mihari/web/public/static/fonts/fa-solid-900.d745348d.woff
1190
1195
  - lib/mihari/web/public/static/fonts/fa-solid-900.d824df7e.woff2
1191
1196
  - lib/mihari/web/public/static/fonts/fa-solid-900.e8a427e1.woff2
1197
+ - lib/mihari/web/public/static/fonts/fa-solid-900.f0203cfc.ttf
1198
+ - lib/mihari/web/public/static/fonts/fa-v4compatibility.e1023515.ttf
1192
1199
  - lib/mihari/web/public/static/img/fa-brands-400.1d5619cd.svg
1193
1200
  - lib/mihari/web/public/static/img/fa-brands-400.ba7ed552.svg
1194
1201
  - lib/mihari/web/public/static/img/fa-regular-400.0bb42845.svg
1195
1202
  - lib/mihari/web/public/static/img/fa-regular-400.c5d109be.svg
1196
1203
  - lib/mihari/web/public/static/img/fa-solid-900.376c1f97.svg
1197
1204
  - lib/mihari/web/public/static/img/fa-solid-900.37bc7099.svg
1205
+ - lib/mihari/web/public/static/js/app-legacy.46b666f0.js
1206
+ - lib/mihari/web/public/static/js/app-legacy.46b666f0.js.map
1198
1207
  - lib/mihari/web/public/static/js/app.06d5cf1c.js
1199
1208
  - lib/mihari/web/public/static/js/app.06d5cf1c.js.map
1200
1209
  - lib/mihari/web/public/static/js/app.0a0cc502.js
@@ -1205,6 +1214,8 @@ files:
1205
1214
  - lib/mihari/web/public/static/js/app.365f1907.js.map
1206
1215
  - lib/mihari/web/public/static/js/app.378da3dc.js
1207
1216
  - lib/mihari/web/public/static/js/app.378da3dc.js.map
1217
+ - lib/mihari/web/public/static/js/app.4818aedd.js
1218
+ - lib/mihari/web/public/static/js/app.4818aedd.js.map
1208
1219
  - lib/mihari/web/public/static/js/app.49ab738a.js
1209
1220
  - lib/mihari/web/public/static/js/app.49ab738a.js.map
1210
1221
  - lib/mihari/web/public/static/js/app.5dc97aae.js
@@ -1219,6 +1230,8 @@ files:
1219
1230
  - lib/mihari/web/public/static/js/app.ab213f7c.js.map
1220
1231
  - lib/mihari/web/public/static/js/app.b5914c39.js
1221
1232
  - lib/mihari/web/public/static/js/app.b5914c39.js.map
1233
+ - lib/mihari/web/public/static/js/app.b88ce341.js
1234
+ - lib/mihari/web/public/static/js/app.b88ce341.js.map
1222
1235
  - lib/mihari/web/public/static/js/app.cb1fa7be.js
1223
1236
  - lib/mihari/web/public/static/js/app.cb1fa7be.js.map
1224
1237
  - lib/mihari/web/public/static/js/app.cccddb2b.js
@@ -1229,6 +1242,10 @@ files:
1229
1242
  - lib/mihari/web/public/static/js/app.f2b8890f.js.map
1230
1243
  - lib/mihari/web/public/static/js/app.fbc19869.js
1231
1244
  - lib/mihari/web/public/static/js/app.fbc19869.js.map
1245
+ - lib/mihari/web/public/static/js/chunk-vendors-legacy.c99e452e.js
1246
+ - lib/mihari/web/public/static/js/chunk-vendors-legacy.c99e452e.js.map
1247
+ - lib/mihari/web/public/static/js/chunk-vendors.15e84e22.js
1248
+ - lib/mihari/web/public/static/js/chunk-vendors.15e84e22.js.map
1232
1249
  - mihari.gemspec
1233
1250
  - renovate.json
1234
1251
  - sig/lib/mihari.rbs
@@ -1255,7 +1272,6 @@ files:
1255
1272
  - sig/lib/mihari/cli/base.rbs
1256
1273
  - sig/lib/mihari/cli/init.rbs
1257
1274
  - sig/lib/mihari/cli/main.rbs
1258
- - sig/lib/mihari/cli/mixins/utils.rbs
1259
1275
  - sig/lib/mihari/cli/validator.rbs
1260
1276
  - sig/lib/mihari/commands/init.rbs
1261
1277
  - sig/lib/mihari/commands/json.rbs
@@ -1276,10 +1292,12 @@ files:
1276
1292
  - sig/lib/mihari/errors.rbs
1277
1293
  - sig/lib/mihari/feed/parser.rbs
1278
1294
  - sig/lib/mihari/feed/reader.rbs
1295
+ - sig/lib/mihari/http.rbs
1279
1296
  - sig/lib/mihari/mixins/autonomous_system.rbs
1280
1297
  - sig/lib/mihari/mixins/configurable.rbs
1281
1298
  - sig/lib/mihari/mixins/configuration.rbs
1282
1299
  - sig/lib/mihari/mixins/disallowed_data_value.rbs
1300
+ - sig/lib/mihari/mixins/error_notification.rbs
1283
1301
  - sig/lib/mihari/mixins/hash.rbs
1284
1302
  - sig/lib/mihari/mixins/refang.rbs
1285
1303
  - sig/lib/mihari/mixins/retriable.rbs
@@ -1294,9 +1312,6 @@ files:
1294
1312
  - sig/lib/mihari/models/tag.rbs
1295
1313
  - sig/lib/mihari/models/tagging.rbs
1296
1314
  - sig/lib/mihari/models/whois.rbs
1297
- - sig/lib/mihari/notifiers/base.rbs
1298
- - sig/lib/mihari/notifiers/exception_notifier.rbs
1299
- - sig/lib/mihari/notifiers/slack.rbs
1300
1315
  - sig/lib/mihari/status.rbs
1301
1316
  - sig/lib/mihari/structs/alert.rbs
1302
1317
  - sig/lib/mihari/structs/censys.rbs
@@ -1,72 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mihari
4
- module CLI
5
- module Mixins
6
- module Utils
7
- #
8
- # Send an exception notification if there is any error in a block
9
- #
10
- # @return [Nil]
11
- #
12
- def with_error_handling
13
- yield
14
- rescue StandardError => e
15
- notifier = Notifiers::ExceptionNotifier.new
16
- notifier.notify e
17
- end
18
-
19
- #
20
- # Check required keys in JSON
21
- #
22
- # @param [Hash] json
23
- #
24
- # @return [Boolean]
25
- #
26
- def required_alert_keys?(json)
27
- %w[title description artifacts].all? { |key| json.key? key }
28
- end
29
-
30
- #
31
- # Run analyzer
32
- #
33
- # @param [Class<Mihari::Analyzers::Base>] analyzer_class
34
- # @param [String] query
35
- # @param [Hash] options
36
- #
37
- # @return [nil]
38
- #
39
- def run_analyzer(analyzer_class, query:, options:)
40
- # options = Thor::CoreExt::HashWithIndifferentAccess
41
- # ref. https://www.rubydoc.info/github/wycats/thor/Thor/CoreExt/HashWithIndifferentAccess
42
- # so need to covert it to a plain hash
43
- hash_options = options.to_hash
44
-
45
- hash_options = hash_options.symbolize_keys
46
- hash_options = normalize_options(hash_options)
47
-
48
- analyzer = analyzer_class.new(query, **hash_options)
49
-
50
- analyzer.ignore_old_artifacts = options[:ignore_old_artifacts] || false
51
- analyzer.ignore_threshold = options[:ignore_threshold] || 0
52
-
53
- analyzer.run
54
- end
55
-
56
- #
57
- # Normalize options (reject keys not for analyzers)
58
- #
59
- # @param [Hash] options
60
- #
61
- # @return [Hash]
62
- #
63
- def normalize_options(options)
64
- [:ignore_old_artifacts, :ignore_threshold].each do |ignore_key|
65
- options.delete(ignore_key)
66
- end
67
- options
68
- end
69
- end
70
- end
71
- end
72
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mihari
4
- module Emitters
5
- class StandardOutput < Base
6
- def valid?
7
- true
8
- end
9
-
10
- def emit(title:, description:, artifacts:, source:, tags:)
11
- h = {
12
- title: title,
13
- description: description,
14
- artifacts: artifacts.map(&:data),
15
- source: source,
16
- tags: tags
17
- }
18
- puts JSON.pretty_generate(h)
19
- end
20
- end
21
- end
22
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mihari
4
- module Notifiers
5
- class Base
6
- # Validate notifier availability
7
- #
8
- # @return [Boolean]
9
- #
10
- def valid?
11
- raise NotImplementedError, "You must implement #{self.class}##{__method__}"
12
- end
13
-
14
- #
15
- # Send a notification
16
- #
17
- # @return [nil]
18
- #
19
- def notify
20
- raise NotImplementedError, "You must implement #{self.class}##{__method__}"
21
- end
22
- end
23
- end
24
- end
@@ -1,126 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mihari
4
- module Notifiers
5
- class ExceptionNotifier
6
- def initialize
7
- @backtrace_lines = 10
8
- @color = "danger"
9
-
10
- @slack = Notifiers::Slack.new
11
- end
12
-
13
- def valid?
14
- @slack.valid?
15
- end
16
-
17
- def notify(exception)
18
- notify_to_stdout exception
19
-
20
- clean_message = exception.message.tr("`", "'")
21
- attachments = to_attachments(exception, clean_message)
22
- notify_to_slack(text: clean_message, attachments: attachments) if @slack.valid?
23
- end
24
-
25
- #
26
- # Send notification to Slack
27
- #
28
- # @param [String] text
29
- # @param [Array<Hash>] attachments
30
- #
31
- # @return [nil]
32
- #
33
- def notify_to_slack(text:, attachments:)
34
- @slack.notify(text: text, attachments: attachments)
35
- end
36
-
37
- #
38
- # Send notification to STDOUT
39
- #
40
- # @param [Exception] exception
41
- #
42
- # @return [nil]
43
- #
44
- def notify_to_stdout(exception)
45
- text = to_text(exception.class).chomp
46
- message = "#{text}: #{exception.message}"
47
- puts message
48
- puts format_backtrace(exception.backtrace) if exception.backtrace
49
- end
50
-
51
- #
52
- # Convert exception to attachments (for Slack)
53
- #
54
- # @param [Exception] exception
55
- # @param [String] clean_message
56
- #
57
- # @return [Array<Hash>]
58
- #
59
- def to_attachments(exception, clean_message)
60
- text = to_text(exception.class)
61
- backtrace = exception.backtrace
62
- fields = to_fields(clean_message, backtrace)
63
-
64
- [color: @color, text: text, fields: fields, mrkdwn_in: %w[text fields]]
65
- end
66
-
67
- #
68
- # Convert exception class to text
69
- #
70
- # @param [Class<Exception>] exception_class
71
- #
72
- # @return [String]
73
- #
74
- def to_text(exception_class)
75
- measure_word = /^[aeiou]/i.match?(exception_class.to_s) ? "An" : "A"
76
- exception_name = "*#{measure_word}* `#{exception_class}`"
77
- "#{exception_name} *occured in background*\n"
78
- end
79
-
80
- #
81
- # Convert clean_message and backtrace into fields (for Slack)
82
- #
83
- # @param [String] clean_message
84
- # @param [Array] backtrace
85
- #
86
- # @return [Array<Hash>]
87
- #
88
- def to_fields(clean_message, backtrace)
89
- fields = [
90
- { title: "Exception", value: clean_message },
91
- { title: "Hostname", value: hostname }
92
- ]
93
-
94
- if backtrace
95
- formatted_backtrace = format_backtrace(backtrace)
96
- fields << { title: "Backtrace", value: formatted_backtrace }
97
- end
98
- fields
99
- end
100
-
101
- #
102
- # Hostname of runnning instance
103
- #
104
- # @return [String]
105
- #
106
- def hostname
107
- Socket.gethostname
108
- rescue StandardError => _e
109
- "N/A"
110
- end
111
-
112
- #
113
- # Format backtrace in string
114
- #
115
- # @param [Array] backtrace
116
- #
117
- # @return [String]
118
- #
119
- def format_backtrace(backtrace)
120
- return nil unless backtrace
121
-
122
- "```#{backtrace.first(@backtrace_lines).join("\n")}```"
123
- end
124
- end
125
- end
126
- end