mihari 5.6.2 → 5.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -1
  3. data/README.md +1 -0
  4. data/config.ru +1 -1
  5. data/lib/mihari/actor.rb +18 -2
  6. data/lib/mihari/analyzers/base.rb +13 -12
  7. data/lib/mihari/analyzers/binaryedge.rb +4 -1
  8. data/lib/mihari/analyzers/censys.rb +4 -2
  9. data/lib/mihari/analyzers/circl.rb +4 -1
  10. data/lib/mihari/analyzers/crtsh.rb +4 -1
  11. data/lib/mihari/analyzers/dnstwister.rb +4 -1
  12. data/lib/mihari/analyzers/feed.rb +3 -0
  13. data/lib/mihari/analyzers/fofa.rb +65 -0
  14. data/lib/mihari/analyzers/greynoise.rb +4 -1
  15. data/lib/mihari/analyzers/hunterhow.rb +6 -1
  16. data/lib/mihari/analyzers/onyphe.rb +4 -1
  17. data/lib/mihari/analyzers/otx.rb +4 -1
  18. data/lib/mihari/analyzers/passivetotal.rb +4 -1
  19. data/lib/mihari/analyzers/pulsedive.rb +3 -0
  20. data/lib/mihari/analyzers/securitytrails.rb +4 -1
  21. data/lib/mihari/analyzers/shodan.rb +4 -1
  22. data/lib/mihari/analyzers/urlscan.rb +4 -1
  23. data/lib/mihari/analyzers/virustotal.rb +4 -1
  24. data/lib/mihari/analyzers/virustotal_intelligence.rb +4 -1
  25. data/lib/mihari/analyzers/zoomeye.rb +5 -2
  26. data/lib/mihari/cli/alert.rb +3 -0
  27. data/lib/mihari/cli/base.rb +3 -0
  28. data/lib/mihari/cli/database.rb +3 -0
  29. data/lib/mihari/cli/main.rb +3 -0
  30. data/lib/mihari/cli/rule.rb +3 -0
  31. data/lib/mihari/clients/base.rb +3 -0
  32. data/lib/mihari/clients/binaryedge.rb +5 -2
  33. data/lib/mihari/clients/censys.rb +7 -4
  34. data/lib/mihari/clients/circl.rb +3 -0
  35. data/lib/mihari/clients/crtsh.rb +3 -0
  36. data/lib/mihari/clients/dnstwister.rb +3 -0
  37. data/lib/mihari/clients/fofa.rb +83 -0
  38. data/lib/mihari/clients/greynoise.rb +5 -2
  39. data/lib/mihari/clients/hunterhow.rb +5 -2
  40. data/lib/mihari/clients/misp.rb +3 -0
  41. data/lib/mihari/clients/onyphe.rb +5 -2
  42. data/lib/mihari/clients/otx.rb +3 -0
  43. data/lib/mihari/clients/passivetotal.rb +3 -0
  44. data/lib/mihari/clients/publsedive.rb +4 -1
  45. data/lib/mihari/clients/securitytrails.rb +3 -0
  46. data/lib/mihari/clients/shodan.rb +5 -2
  47. data/lib/mihari/clients/the_hive.rb +3 -0
  48. data/lib/mihari/clients/urlscan.rb +7 -4
  49. data/lib/mihari/clients/virustotal.rb +5 -2
  50. data/lib/mihari/clients/zoomeye.rb +3 -0
  51. data/lib/mihari/commands/alert.rb +9 -16
  52. data/lib/mihari/commands/database.rb +3 -0
  53. data/lib/mihari/commands/rule.rb +10 -1
  54. data/lib/mihari/commands/search.rb +13 -29
  55. data/lib/mihari/commands/version.rb +3 -0
  56. data/lib/mihari/commands/web.rb +4 -1
  57. data/lib/mihari/config.rb +139 -150
  58. data/lib/mihari/constants.rb +1 -1
  59. data/lib/mihari/database.rb +6 -0
  60. data/lib/mihari/emitters/base.rb +13 -11
  61. data/lib/mihari/emitters/database.rb +4 -1
  62. data/lib/mihari/emitters/misp.rb +7 -4
  63. data/lib/mihari/emitters/slack.rb +3 -3
  64. data/lib/mihari/emitters/the_hive.rb +3 -3
  65. data/lib/mihari/emitters/webhook.rb +4 -3
  66. data/lib/mihari/enrichers/base.rb +15 -9
  67. data/lib/mihari/enrichers/google_public_dns.rb +6 -5
  68. data/lib/mihari/enrichers/ipinfo.rb +11 -9
  69. data/lib/mihari/enrichers/shodan.rb +4 -6
  70. data/lib/mihari/enrichers/whois.rb +12 -9
  71. data/lib/mihari/entities/tag.rb +1 -0
  72. data/lib/mihari/errors.rb +6 -0
  73. data/lib/mihari/feed/parser.rb +3 -0
  74. data/lib/mihari/feed/reader.rb +3 -0
  75. data/lib/mihari/http.rb +6 -0
  76. data/lib/mihari/mixins/autonomous_system.rb +3 -0
  77. data/lib/mihari/mixins/configurable.rb +3 -0
  78. data/lib/mihari/mixins/error_notification.rb +3 -0
  79. data/lib/mihari/mixins/falsepositive.rb +3 -0
  80. data/lib/mihari/mixins/refang.rb +3 -0
  81. data/lib/mihari/mixins/retriable.rb +6 -2
  82. data/lib/mihari/models/alert.rb +7 -4
  83. data/lib/mihari/models/artifact.rb +6 -0
  84. data/lib/mihari/models/autonomous_system.rb +4 -1
  85. data/lib/mihari/models/cpe.rb +4 -1
  86. data/lib/mihari/models/dns.rb +4 -1
  87. data/lib/mihari/models/geolocation.rb +4 -1
  88. data/lib/mihari/models/port.rb +4 -1
  89. data/lib/mihari/models/reverse_dns.rb +4 -1
  90. data/lib/mihari/models/rule.rb +6 -3
  91. data/lib/mihari/models/tag.rb +3 -0
  92. data/lib/mihari/models/tagging.rb +3 -0
  93. data/lib/mihari/models/whois.rb +4 -3
  94. data/lib/mihari/rule.rb +31 -12
  95. data/lib/mihari/schemas/alert.rb +3 -0
  96. data/lib/mihari/schemas/analyzer.rb +11 -0
  97. data/lib/mihari/schemas/emitter.rb +3 -0
  98. data/lib/mihari/schemas/enricher.rb +3 -0
  99. data/lib/mihari/schemas/macros.rb +4 -0
  100. data/lib/mihari/schemas/mixins.rb +5 -0
  101. data/lib/mihari/schemas/rule.rb +3 -0
  102. data/lib/mihari/service.rb +26 -0
  103. data/lib/mihari/services/alert_builder.rb +85 -9
  104. data/lib/mihari/services/alert_runner.rb +8 -19
  105. data/lib/mihari/services/rule_builder.rb +13 -12
  106. data/lib/mihari/services/rule_runner.rb +7 -32
  107. data/lib/mihari/structs/binaryedge.rb +22 -28
  108. data/lib/mihari/structs/censys.rb +48 -141
  109. data/lib/mihari/structs/config.rb +19 -30
  110. data/lib/mihari/structs/filters.rb +38 -0
  111. data/lib/mihari/structs/fofa.rb +47 -0
  112. data/lib/mihari/structs/google_public_dns.rb +10 -32
  113. data/lib/mihari/structs/greynoise.rb +33 -90
  114. data/lib/mihari/structs/hunterhow.rb +24 -28
  115. data/lib/mihari/structs/ipinfo.rb +14 -37
  116. data/lib/mihari/structs/onyphe.rb +31 -80
  117. data/lib/mihari/structs/shodan.rb +47 -114
  118. data/lib/mihari/structs/urlscan.rb +24 -69
  119. data/lib/mihari/structs/virustotal_intelligence.rb +20 -64
  120. data/lib/mihari/type_checker.rb +4 -0
  121. data/lib/mihari/types.rb +3 -0
  122. data/lib/mihari/version.rb +1 -1
  123. data/lib/mihari/web/api.rb +15 -10
  124. data/lib/mihari/web/app.rb +64 -56
  125. data/lib/mihari/web/endpoints/alerts.rb +127 -85
  126. data/lib/mihari/web/endpoints/artifacts.rb +91 -79
  127. data/lib/mihari/web/endpoints/configs.rb +18 -13
  128. data/lib/mihari/web/endpoints/ip_addresses.rb +35 -15
  129. data/lib/mihari/web/endpoints/rules.rb +236 -187
  130. data/lib/mihari/web/endpoints/tags.rb +42 -35
  131. data/lib/mihari/web/middleware/connection_adapter.rb +16 -9
  132. data/lib/mihari/web/middleware/error_notification_adapter.rb +17 -10
  133. data/lib/mihari/web/public/assets/{index-28d4c79d.js → index-07fafab5.js} +31 -30
  134. data/lib/mihari/web/public/assets/mode-yaml-24faa242.js +8 -0
  135. data/lib/mihari/web/public/index.html +1 -1
  136. data/lib/mihari.rb +24 -6
  137. data/mihari.gemspec +9 -2
  138. data/mkdocs.yml +4 -2
  139. metadata +38 -133
  140. data/docs/alternatives.md +0 -5
  141. data/docs/analyzers/binaryedge.md +0 -26
  142. data/docs/analyzers/censys.md +0 -31
  143. data/docs/analyzers/circl.md +0 -37
  144. data/docs/analyzers/crtsh.md +0 -26
  145. data/docs/analyzers/dnstwister.md +0 -25
  146. data/docs/analyzers/feed.md +0 -73
  147. data/docs/analyzers/greynoise.md +0 -26
  148. data/docs/analyzers/hunterhow.md +0 -33
  149. data/docs/analyzers/index.md +0 -103
  150. data/docs/analyzers/onyphe.md +0 -26
  151. data/docs/analyzers/otx.md +0 -28
  152. data/docs/analyzers/passivetotal.md +0 -52
  153. data/docs/analyzers/pulsedive.md +0 -28
  154. data/docs/analyzers/securitytrails.md +0 -41
  155. data/docs/analyzers/shodan.md +0 -26
  156. data/docs/analyzers/urlscan.md +0 -28
  157. data/docs/analyzers/virustotal.md +0 -43
  158. data/docs/analyzers/virustotal_intelligence.md +0 -33
  159. data/docs/analyzers/zoomeye.md +0 -38
  160. data/docs/configuration.md +0 -35
  161. data/docs/emitters/database.md +0 -22
  162. data/docs/emitters/hive.md +0 -26
  163. data/docs/emitters/index.md +0 -36
  164. data/docs/emitters/misp.md +0 -21
  165. data/docs/emitters/slack.md +0 -21
  166. data/docs/emitters/webhook.md +0 -63
  167. data/docs/enrichers/google_public_dns.md +0 -19
  168. data/docs/enrichers/index.md +0 -35
  169. data/docs/enrichers/ipinfo.md +0 -26
  170. data/docs/enrichers/shodan.md +0 -22
  171. data/docs/enrichers/whois.md +0 -17
  172. data/docs/github_actions.md +0 -43
  173. data/docs/index.md +0 -11
  174. data/docs/installation.md +0 -31
  175. data/docs/requirements.md +0 -13
  176. data/docs/rule.md +0 -168
  177. data/docs/tags.md +0 -3
  178. data/docs/usage.md +0 -103
  179. data/frontend/.eslintrc.cjs +0 -22
  180. data/frontend/.gitignore +0 -31
  181. data/frontend/.prettierrc.json +0 -8
  182. data/frontend/README.md +0 -3
  183. data/frontend/env.d.ts +0 -5
  184. data/frontend/index.html +0 -21
  185. data/frontend/package-lock.json +0 -7219
  186. data/frontend/package.json +0 -67
  187. data/frontend/public/favicon.ico +0 -0
  188. data/frontend/scripts/swagger_doc_to_yaml.rb +0 -23
  189. data/frontend/src/App.vue +0 -27
  190. data/frontend/src/ace-config.ts +0 -6
  191. data/frontend/src/api-helper.ts +0 -111
  192. data/frontend/src/api.ts +0 -105
  193. data/frontend/src/components/ErrorMessage.vue +0 -31
  194. data/frontend/src/components/Loading.vue +0 -15
  195. data/frontend/src/components/Navbar.vue +0 -42
  196. data/frontend/src/components/Pagination.vue +0 -119
  197. data/frontend/src/components/alert/Alert.vue +0 -87
  198. data/frontend/src/components/alert/Alerts.vue +0 -63
  199. data/frontend/src/components/alert/AlertsWithPagination.vue +0 -90
  200. data/frontend/src/components/alert/AlertsWrapper.vue +0 -128
  201. data/frontend/src/components/alert/Form.vue +0 -182
  202. data/frontend/src/components/artifact/AS.vue +0 -29
  203. data/frontend/src/components/artifact/Artifact.vue +0 -287
  204. data/frontend/src/components/artifact/ArtifactTag.vue +0 -64
  205. data/frontend/src/components/artifact/ArtifactTags.vue +0 -29
  206. data/frontend/src/components/artifact/ArtifactWrapper.vue +0 -57
  207. data/frontend/src/components/artifact/CPEs.vue +0 -23
  208. data/frontend/src/components/artifact/DnsRecords.vue +0 -38
  209. data/frontend/src/components/artifact/Ports.vue +0 -23
  210. data/frontend/src/components/artifact/ReverseDnsNames.vue +0 -31
  211. data/frontend/src/components/artifact/Tags.vue +0 -29
  212. data/frontend/src/components/artifact/WhoisRecord.vue +0 -44
  213. data/frontend/src/components/config/Configs.vue +0 -65
  214. data/frontend/src/components/config/ConfigsWrapper.vue +0 -32
  215. data/frontend/src/components/link/Link.vue +0 -32
  216. data/frontend/src/components/link/Links.vue +0 -42
  217. data/frontend/src/components/rule/EditRule.vue +0 -72
  218. data/frontend/src/components/rule/EditRuleWrapper.vue +0 -48
  219. data/frontend/src/components/rule/Form.vue +0 -158
  220. data/frontend/src/components/rule/InputForm.vue +0 -45
  221. data/frontend/src/components/rule/NewRule.vue +0 -57
  222. data/frontend/src/components/rule/Rule.vue +0 -100
  223. data/frontend/src/components/rule/RuleWrapper.vue +0 -53
  224. data/frontend/src/components/rule/Rules.vue +0 -84
  225. data/frontend/src/components/rule/RulesWrapper.vue +0 -121
  226. data/frontend/src/components/rule/YAML.vue +0 -37
  227. data/frontend/src/components/tag/Tag.vue +0 -65
  228. data/frontend/src/components/tag/Tags.vue +0 -37
  229. data/frontend/src/countries.ts +0 -350
  230. data/frontend/src/index.ts +0 -20
  231. data/frontend/src/links/anyrun.ts +0 -19
  232. data/frontend/src/links/base.ts +0 -14
  233. data/frontend/src/links/censys.ts +0 -20
  234. data/frontend/src/links/crtsh.ts +0 -20
  235. data/frontend/src/links/dnslytics.ts +0 -38
  236. data/frontend/src/links/greynoise.ts +0 -20
  237. data/frontend/src/links/index.ts +0 -40
  238. data/frontend/src/links/intezer.ts +0 -20
  239. data/frontend/src/links/otx.ts +0 -33
  240. data/frontend/src/links/securitytrails.ts +0 -38
  241. data/frontend/src/links/shodan.ts +0 -20
  242. data/frontend/src/links/urlscan.ts +0 -50
  243. data/frontend/src/links/virustotal.ts +0 -72
  244. data/frontend/src/main.ts +0 -41
  245. data/frontend/src/router/index.ts +0 -57
  246. data/frontend/src/rule.ts +0 -14
  247. data/frontend/src/shims-vue.d.ts +0 -6
  248. data/frontend/src/swagger.yaml +0 -771
  249. data/frontend/src/types.ts +0 -188
  250. data/frontend/src/utils.ts +0 -54
  251. data/frontend/src/views/Alerts.vue +0 -20
  252. data/frontend/src/views/Artifact.vue +0 -39
  253. data/frontend/src/views/Configs.vue +0 -20
  254. data/frontend/src/views/EditRule.vue +0 -39
  255. data/frontend/src/views/NewRule.vue +0 -26
  256. data/frontend/src/views/Rule.vue +0 -39
  257. data/frontend/src/views/Rules.vue +0 -20
  258. data/frontend/tests/utils.spec.ts +0 -9
  259. data/frontend/tsconfig.app.json +0 -21
  260. data/frontend/tsconfig.json +0 -14
  261. data/frontend/tsconfig.node.json +0 -13
  262. data/frontend/tsconfig.vitest.json +0 -12
  263. data/frontend/vite.config.ts +0 -24
  264. data/frontend/vitest.config.ts +0 -21
  265. data/lib/mihari/services/alert_proxy.rb +0 -92
  266. data/lib/mihari/templates/rule.yml.erb +0 -5
  267. data/lib/mihari/web/public/assets/mode-yaml-a21faa53.js +0 -8
@@ -1,63 +0,0 @@
1
- <template>
2
- <Alert
3
- v-for="(alert, index) in alerts.alerts"
4
- :alert="alert"
5
- :key="index"
6
- @refresh-page="refreshPage"
7
- @update-tag="updateTag"
8
- ></Alert>
9
- <Pagination
10
- :total="alerts.total"
11
- :currentPage="alerts.currentPage"
12
- :pageSize="alerts.pageSize"
13
- @update-page="updatePage"
14
- ></Pagination>
15
- <p class="help">({{ alerts.total }} results in total, {{ alerts.alerts.length }} shown)</p>
16
- </template>
17
-
18
- <script lang="ts">
19
- import { defineComponent, type PropType } from "vue"
20
-
21
- import Alert from "@/components/alert/Alert.vue"
22
- import Pagination from "@/components/Pagination.vue"
23
- import type { Alerts } from "@/types"
24
-
25
- export default defineComponent({
26
- name: "AlertsItem",
27
- components: {
28
- Alert,
29
- Pagination
30
- },
31
- props: {
32
- alerts: {
33
- type: Object as PropType<Alerts>,
34
- required: true
35
- }
36
- },
37
- emits: ["update-page", "refresh-page", "update-tag"],
38
- setup(_, context) {
39
- const scrollToTop = () => {
40
- window.scrollTo({
41
- top: 0
42
- })
43
- }
44
-
45
- const updatePage = (page: number) => {
46
- scrollToTop()
47
- context.emit("update-page", page)
48
- }
49
-
50
- const refreshPage = () => {
51
- scrollToTop()
52
- context.emit("refresh-page")
53
- }
54
-
55
- const updateTag = (tag: string) => {
56
- scrollToTop()
57
- context.emit("update-tag", tag)
58
- }
59
-
60
- return { updatePage, updateTag, refreshPage }
61
- }
62
- })
63
- </script>
@@ -1,90 +0,0 @@
1
- <template>
2
- <Loading v-if="getAlertsTask.isRunning"></Loading>
3
- <Alerts
4
- :alerts="getAlertsTask.last.value"
5
- v-if="getAlertsTask.last?.value"
6
- @refresh-page="refreshPage"
7
- @update-page="updatePage"
8
- @update-tag="updateTag"
9
- >
10
- </Alerts>
11
- </template>
12
-
13
- <script lang="ts">
14
- import { defineComponent, nextTick, onMounted, ref, watch } from "vue"
15
-
16
- import { generateGetAlertsTask } from "@/api-helper"
17
- import Alerts from "@/components/alert/Alerts.vue"
18
- import Loading from "@/components/Loading.vue"
19
- import type { AlertSearchParams } from "@/types"
20
-
21
- export default defineComponent({
22
- name: "AlertsWithPagination",
23
- props: {
24
- ruleId: {
25
- type: String
26
- },
27
- artifact: {
28
- type: String
29
- }
30
- },
31
- components: {
32
- Alerts,
33
- Loading
34
- },
35
- setup(props) {
36
- const page = ref(1)
37
- const tag = ref<string | undefined>(undefined)
38
-
39
- const getAlertsTask = generateGetAlertsTask()
40
-
41
- const getAlerts = async () => {
42
- const params: AlertSearchParams = {
43
- artifact: props.artifact,
44
- page: page.value,
45
- ruleId: props.ruleId,
46
- tag: tag.value,
47
- toAt: undefined,
48
- fromAt: undefined
49
- }
50
- return await getAlertsTask.perform(params)
51
- }
52
-
53
- const updatePage = (newPage: number) => {
54
- page.value = newPage
55
- }
56
-
57
- const resetPage = () => {
58
- page.value = 1
59
- }
60
-
61
- const refreshPage = async () => {
62
- resetPage()
63
- await getAlerts()
64
- }
65
-
66
- const updateTag = (newTag: string | undefined) => {
67
- if (tag.value === newTag) {
68
- tag.value = undefined
69
- } else {
70
- tag.value = newTag
71
- }
72
- }
73
-
74
- onMounted(async () => {
75
- await getAlerts()
76
- })
77
-
78
- watch([props, page, tag], async () => {
79
- nextTick(async () => await getAlerts())
80
- })
81
-
82
- return {
83
- getAlertsTask,
84
- refreshPage,
85
- updatePage,
86
- updateTag
87
- }
88
- }
89
- })
90
- </script>
@@ -1,128 +0,0 @@
1
- <template>
2
- <div class="box mb-6">
3
- <FormComponent
4
- ref="form"
5
- :ruleSet="getRuleSetTask.last?.value || []"
6
- :tags="getTagsTask.last?.value || []"
7
- :page="page"
8
- :tag="tag"
9
- ></FormComponent>
10
- <hr />
11
- <div class="columns">
12
- <div class="column">
13
- <div class="field is-grouped is-grouped-centered">
14
- <p class="control">
15
- <a class="button is-primary" @click="search">
16
- <span class="icon is-small">
17
- <font-awesome-icon icon="search"></font-awesome-icon>
18
- </span>
19
- <span>Search</span>
20
- </a>
21
- </p>
22
- </div>
23
- </div>
24
- </div>
25
- </div>
26
- <div v-if="getAlertsTask.performCount > 0">
27
- <hr />
28
- <Loading v-if="getAlertsTask.isRunning"></Loading>
29
- <ErrorMessage v-if="getAlertsTask.isError" :error="getAlertsTask.last?.error"></ErrorMessage>
30
- <AlertsComponent
31
- :alerts="getAlertsTask.last.value"
32
- v-if="getAlertsTask.last?.value"
33
- @refresh-page="refreshPage"
34
- @update-page="updatePage"
35
- @update-tag="updateTag"
36
- ></AlertsComponent>
37
- </div>
38
- </template>
39
-
40
- <script lang="ts">
41
- import { defineComponent, nextTick, onMounted, ref, watch } from "vue"
42
-
43
- import { generateGetAlertsTask, generateGetRuleSetTask, generateGetTagsTask } from "@/api-helper"
44
- import AlertsComponent from "@/components/alert/Alerts.vue"
45
- import FormComponent from "@/components/alert/Form.vue"
46
- import ErrorMessage from "@/components/ErrorMessage.vue"
47
- import Loading from "@/components/Loading.vue"
48
- import type { AlertSearchParams } from "@/types"
49
-
50
- export default defineComponent({
51
- name: "AlertsWrapper",
52
- components: {
53
- AlertsComponent,
54
- FormComponent,
55
- Loading,
56
- ErrorMessage
57
- },
58
- setup() {
59
- const page = ref(1)
60
- const tag = ref<string | undefined>(undefined)
61
- const form = ref<InstanceType<typeof FormComponent>>()
62
-
63
- const getAlertsTask = generateGetAlertsTask()
64
- const getTagsTask = generateGetTagsTask()
65
- const getRuleSetTask = generateGetRuleSetTask()
66
-
67
- const getAlerts = async () => {
68
- const params = form.value?.getSearchParams() as AlertSearchParams
69
- return await getAlertsTask.perform(params)
70
- }
71
-
72
- const updatePage = (newPage: number) => {
73
- page.value = newPage
74
- }
75
-
76
- const resetPage = () => {
77
- page.value = 1
78
- }
79
-
80
- const search = async () => {
81
- // reset page
82
- resetPage()
83
-
84
- await getAlerts()
85
- }
86
-
87
- const updateTag = (newTag: string | undefined) => {
88
- if (tag.value === newTag) {
89
- tag.value = undefined
90
- } else {
91
- tag.value = newTag
92
- }
93
-
94
- nextTick(async () => await search())
95
- }
96
-
97
- const refreshPage = async () => {
98
- // it is just an alias of search
99
- // this function will be invoked when an alert is deleted
100
- await search()
101
- }
102
-
103
- onMounted(async () => {
104
- getTagsTask.perform()
105
- getRuleSetTask.perform()
106
-
107
- await getAlerts()
108
- })
109
-
110
- watch([page, tag], async () => {
111
- nextTick(async () => await getAlerts())
112
- })
113
-
114
- return {
115
- getAlertsTask,
116
- getRuleSetTask,
117
- getTagsTask,
118
- refreshPage,
119
- search,
120
- tag,
121
- updatePage,
122
- updateTag,
123
- form,
124
- page
125
- }
126
- }
127
- })
128
- </script>
@@ -1,182 +0,0 @@
1
- <template>
2
- <div class="columns">
3
- <div class="column">
4
- <div class="field is-horizontal">
5
- <div class="field-label is-normal">
6
- <label class="label">Rule</label>
7
- </div>
8
- <div class="field-body">
9
- <div class="field">
10
- <div class="control">
11
- <div class="select">
12
- <select v-model="ruleId">
13
- <option></option>
14
- <option v-for="ruleId_ in ruleSet" :key="ruleId_">
15
- {{ ruleId_ }}
16
- </option>
17
- </select>
18
- </div>
19
- </div>
20
- </div>
21
- </div>
22
- </div>
23
- </div>
24
- <div class="column">
25
- <div class="field is-horizontal">
26
- <div class="field-label is-normal">
27
- <label class="label">Artifact</label>
28
- </div>
29
- <div class="field-body">
30
- <div class="field">
31
- <p class="control">
32
- <input class="input" type="text" v-model="artifact" />
33
- </p>
34
- </div>
35
- </div>
36
- </div>
37
- </div>
38
- </div>
39
- <div class="columns">
40
- <div class="column">
41
- <div class="field is-horizontal">
42
- <div class="field-label is-normal">
43
- <label class="label">Tag</label>
44
- </div>
45
- <div class="field-body">
46
- <div class="field">
47
- <div class="control">
48
- <div class="select">
49
- <select v-model="tagInput">
50
- <option></option>
51
- <option v-for="tag_ in tags" :key="tag_">
52
- {{ tag_ }}
53
- </option>
54
- </select>
55
- </div>
56
- </div>
57
- </div>
58
- </div>
59
- </div>
60
- </div>
61
- <div class="column"></div>
62
- </div>
63
- <div class="columns">
64
- <div class="column">
65
- <div class="field is-horizontal">
66
- <div class="field-label is-normal">
67
- <label class="label">From</label>
68
- </div>
69
- <div class="field-body">
70
- <div class="field">
71
- <p class="control">
72
- <input class="input" type="date" v-model="fromAt" />
73
- </p>
74
- </div>
75
- </div>
76
- </div>
77
- </div>
78
- <div class="column">
79
- <div class="field is-horizontal">
80
- <div class="field-label is-normal">
81
- <label class="label">To</label>
82
- </div>
83
- <div class="field-body">
84
- <div class="field">
85
- <p class="control">
86
- <input class="input" type="date" v-model="toAt" />
87
- </p>
88
- </div>
89
- </div>
90
- </div>
91
- </div>
92
- </div>
93
- </template>
94
-
95
- <script lang="ts">
96
- import { defineComponent, type PropType, ref, toRef, watch } from "vue"
97
- import { useRoute } from "vue-router"
98
-
99
- import type { AlertSearchParams } from "@/types"
100
- import { normalizeQueryParam } from "@/utils"
101
-
102
- export default defineComponent({
103
- name: "AlertsForm",
104
- props: {
105
- tags: {
106
- type: Array as PropType<string[]>,
107
- required: true
108
- },
109
- ruleSet: {
110
- type: Array as PropType<string[]>,
111
- required: true
112
- },
113
- page: {
114
- type: Number,
115
- required: true
116
- },
117
- tag: {
118
- type: String,
119
- required: false
120
- }
121
- },
122
- setup(props) {
123
- const route = useRoute()
124
-
125
- const artifact = ref<string | undefined>(undefined)
126
- const fromAt = ref<string | undefined>(undefined)
127
- const tagInput = toRef(props, "tag")
128
- const ruleId = ref<string | undefined>(undefined)
129
- const toAt = ref<string | undefined>(undefined)
130
- const asn = ref<number | undefined>(undefined)
131
- const dnsRecord = ref<string | undefined>(undefined)
132
- const reverseDnsName = ref<string | undefined>(undefined)
133
-
134
- const updateByQueryParams = () => {
135
- const asn_ = route.query["asn"]
136
- const normalizedAsn = normalizeQueryParam(asn_)
137
- asn.value = normalizedAsn === undefined ? undefined : parseInt(normalizedAsn)
138
-
139
- const dnsRecord_ = route.query["dnsRecord"]
140
- dnsRecord.value = normalizeQueryParam(dnsRecord_)
141
-
142
- const reverseDnsName_ = route.query["reverseDnsName"]
143
- reverseDnsName.value = normalizeQueryParam(reverseDnsName_)
144
-
145
- const tag_ = route.query["tag"]
146
- if (tagInput.value === undefined) {
147
- tagInput.value = normalizeQueryParam(tag_)
148
- }
149
- }
150
-
151
- const getSearchParams = (): AlertSearchParams => {
152
- updateByQueryParams()
153
-
154
- const params: AlertSearchParams = {
155
- artifact: artifact.value === "" ? undefined : artifact.value,
156
- page: props.page,
157
- ruleId: ruleId.value === "" ? undefined : ruleId.value,
158
- tag: tagInput.value === "" ? undefined : tagInput.value,
159
- toAt: toAt.value === "" ? undefined : toAt.value,
160
- fromAt: fromAt.value === "" ? undefined : fromAt.value
161
- }
162
- return params
163
- }
164
-
165
- watch(
166
- () => props.tag,
167
- () => {
168
- tagInput.value = props.tag
169
- }
170
- )
171
-
172
- return {
173
- artifact,
174
- fromAt,
175
- getSearchParams,
176
- ruleId,
177
- toAt,
178
- tagInput
179
- }
180
- }
181
- })
182
- </script>
@@ -1,29 +0,0 @@
1
- <template>
2
- <div class="tags are-medium">
3
- <router-link
4
- class="tag"
5
- :to="{
6
- name: 'Alerts',
7
- query: { asn: autonomousSystem.asn }
8
- }"
9
- >
10
- {{ autonomousSystem.asn }}
11
- </router-link>
12
- </div>
13
- </template>
14
-
15
- <script lang="ts">
16
- import { defineComponent, type PropType } from "vue"
17
-
18
- import type { AutonomousSystem } from "@/types"
19
-
20
- export default defineComponent({
21
- name: "AS",
22
- props: {
23
- autonomousSystem: {
24
- type: Object as PropType<AutonomousSystem>,
25
- required: true
26
- }
27
- }
28
- })
29
- </script>