mihari 5.7.0 → 5.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/lib/mihari/actor.rb +10 -4
  4. data/lib/mihari/commands/alert.rb +6 -4
  5. data/lib/mihari/commands/search.rb +10 -29
  6. data/lib/mihari/enrichers/ipinfo.rb +1 -1
  7. data/lib/mihari/entities/tag.rb +1 -0
  8. data/lib/mihari/rule.rb +14 -0
  9. data/lib/mihari/service.rb +12 -2
  10. data/lib/mihari/services/alert_builder.rb +81 -8
  11. data/lib/mihari/services/alert_runner.rb +3 -10
  12. data/lib/mihari/services/rule_builder.rb +8 -10
  13. data/lib/mihari/services/rule_runner.rb +2 -25
  14. data/lib/mihari/structs/binaryedge.rb +9 -0
  15. data/lib/mihari/structs/censys.rb +0 -14
  16. data/lib/mihari/structs/fofa.rb +3 -0
  17. data/lib/mihari/structs/google_public_dns.rb +0 -4
  18. data/lib/mihari/structs/greynoise.rb +0 -6
  19. data/lib/mihari/structs/hunterhow.rb +0 -6
  20. data/lib/mihari/structs/ipinfo.rb +0 -2
  21. data/lib/mihari/structs/onyphe.rb +0 -4
  22. data/lib/mihari/structs/shodan.rb +0 -2
  23. data/lib/mihari/structs/urlscan.rb +0 -6
  24. data/lib/mihari/structs/virustotal_intelligence.rb +0 -8
  25. data/lib/mihari/version.rb +1 -1
  26. data/lib/mihari/web/app.rb +20 -17
  27. data/lib/mihari/web/endpoints/alerts.rb +75 -38
  28. data/lib/mihari/web/endpoints/artifacts.rb +60 -53
  29. data/lib/mihari/web/endpoints/ip_addresses.rb +19 -4
  30. data/lib/mihari/web/endpoints/rules.rb +132 -88
  31. data/lib/mihari/web/endpoints/tags.rb +15 -13
  32. data/lib/mihari/web/public/assets/{index-821134e2.js → index-07fafab5.js} +4 -3
  33. data/lib/mihari/web/public/index.html +1 -1
  34. data/lib/mihari.rb +0 -1
  35. data/mihari.gemspec +1 -1
  36. data/mkdocs.yml +1 -0
  37. metadata +3 -130
  38. data/docs/alternatives.md +0 -5
  39. data/docs/analyzers/binaryedge.md +0 -26
  40. data/docs/analyzers/censys.md +0 -31
  41. data/docs/analyzers/circl.md +0 -37
  42. data/docs/analyzers/crtsh.md +0 -26
  43. data/docs/analyzers/dnstwister.md +0 -25
  44. data/docs/analyzers/feed.md +0 -73
  45. data/docs/analyzers/fofa.md +0 -31
  46. data/docs/analyzers/greynoise.md +0 -26
  47. data/docs/analyzers/hunterhow.md +0 -33
  48. data/docs/analyzers/index.md +0 -104
  49. data/docs/analyzers/onyphe.md +0 -26
  50. data/docs/analyzers/otx.md +0 -28
  51. data/docs/analyzers/passivetotal.md +0 -52
  52. data/docs/analyzers/pulsedive.md +0 -28
  53. data/docs/analyzers/securitytrails.md +0 -41
  54. data/docs/analyzers/shodan.md +0 -26
  55. data/docs/analyzers/urlscan.md +0 -28
  56. data/docs/analyzers/virustotal.md +0 -43
  57. data/docs/analyzers/virustotal_intelligence.md +0 -33
  58. data/docs/analyzers/zoomeye.md +0 -38
  59. data/docs/configuration.md +0 -35
  60. data/docs/emitters/database.md +0 -22
  61. data/docs/emitters/hive.md +0 -26
  62. data/docs/emitters/index.md +0 -36
  63. data/docs/emitters/misp.md +0 -21
  64. data/docs/emitters/slack.md +0 -21
  65. data/docs/emitters/webhook.md +0 -63
  66. data/docs/enrichers/google_public_dns.md +0 -19
  67. data/docs/enrichers/index.md +0 -35
  68. data/docs/enrichers/ipinfo.md +0 -26
  69. data/docs/enrichers/shodan.md +0 -22
  70. data/docs/enrichers/whois.md +0 -17
  71. data/docs/github_actions.md +0 -43
  72. data/docs/index.md +0 -11
  73. data/docs/installation.md +0 -31
  74. data/docs/requirements.md +0 -13
  75. data/docs/rule.md +0 -168
  76. data/docs/tags.md +0 -3
  77. data/docs/usage.md +0 -103
  78. data/frontend/.eslintrc.cjs +0 -22
  79. data/frontend/.gitignore +0 -31
  80. data/frontend/.prettierrc.json +0 -8
  81. data/frontend/README.md +0 -3
  82. data/frontend/env.d.ts +0 -5
  83. data/frontend/index.html +0 -21
  84. data/frontend/package-lock.json +0 -7219
  85. data/frontend/package.json +0 -67
  86. data/frontend/public/favicon.ico +0 -0
  87. data/frontend/scripts/swagger_doc_to_yaml.rb +0 -23
  88. data/frontend/src/App.vue +0 -27
  89. data/frontend/src/ace-config.ts +0 -6
  90. data/frontend/src/api-helper.ts +0 -111
  91. data/frontend/src/api.ts +0 -105
  92. data/frontend/src/components/ErrorMessage.vue +0 -31
  93. data/frontend/src/components/Loading.vue +0 -15
  94. data/frontend/src/components/Navbar.vue +0 -42
  95. data/frontend/src/components/Pagination.vue +0 -119
  96. data/frontend/src/components/alert/Alert.vue +0 -87
  97. data/frontend/src/components/alert/Alerts.vue +0 -63
  98. data/frontend/src/components/alert/AlertsWithPagination.vue +0 -90
  99. data/frontend/src/components/alert/AlertsWrapper.vue +0 -128
  100. data/frontend/src/components/alert/Form.vue +0 -169
  101. data/frontend/src/components/artifact/AS.vue +0 -23
  102. data/frontend/src/components/artifact/Artifact.vue +0 -287
  103. data/frontend/src/components/artifact/ArtifactTag.vue +0 -64
  104. data/frontend/src/components/artifact/ArtifactTags.vue +0 -29
  105. data/frontend/src/components/artifact/ArtifactWrapper.vue +0 -57
  106. data/frontend/src/components/artifact/CPEs.vue +0 -23
  107. data/frontend/src/components/artifact/DnsRecords.vue +0 -32
  108. data/frontend/src/components/artifact/Ports.vue +0 -23
  109. data/frontend/src/components/artifact/ReverseDnsNames.vue +0 -23
  110. data/frontend/src/components/artifact/Tags.vue +0 -29
  111. data/frontend/src/components/artifact/WhoisRecord.vue +0 -44
  112. data/frontend/src/components/config/Configs.vue +0 -65
  113. data/frontend/src/components/config/ConfigsWrapper.vue +0 -32
  114. data/frontend/src/components/link/Link.vue +0 -32
  115. data/frontend/src/components/link/Links.vue +0 -42
  116. data/frontend/src/components/rule/EditRule.vue +0 -72
  117. data/frontend/src/components/rule/EditRuleWrapper.vue +0 -48
  118. data/frontend/src/components/rule/Form.vue +0 -158
  119. data/frontend/src/components/rule/InputForm.vue +0 -45
  120. data/frontend/src/components/rule/NewRule.vue +0 -57
  121. data/frontend/src/components/rule/Rule.vue +0 -100
  122. data/frontend/src/components/rule/RuleWrapper.vue +0 -53
  123. data/frontend/src/components/rule/Rules.vue +0 -84
  124. data/frontend/src/components/rule/RulesWrapper.vue +0 -121
  125. data/frontend/src/components/rule/YAML.vue +0 -37
  126. data/frontend/src/components/tag/Tag.vue +0 -65
  127. data/frontend/src/components/tag/Tags.vue +0 -37
  128. data/frontend/src/countries.ts +0 -350
  129. data/frontend/src/index.ts +0 -20
  130. data/frontend/src/links/anyrun.ts +0 -19
  131. data/frontend/src/links/base.ts +0 -14
  132. data/frontend/src/links/censys.ts +0 -20
  133. data/frontend/src/links/crtsh.ts +0 -20
  134. data/frontend/src/links/dnslytics.ts +0 -38
  135. data/frontend/src/links/greynoise.ts +0 -20
  136. data/frontend/src/links/index.ts +0 -40
  137. data/frontend/src/links/intezer.ts +0 -20
  138. data/frontend/src/links/otx.ts +0 -33
  139. data/frontend/src/links/securitytrails.ts +0 -38
  140. data/frontend/src/links/shodan.ts +0 -20
  141. data/frontend/src/links/urlscan.ts +0 -50
  142. data/frontend/src/links/virustotal.ts +0 -72
  143. data/frontend/src/main.ts +0 -41
  144. data/frontend/src/router/index.ts +0 -57
  145. data/frontend/src/rule.ts +0 -14
  146. data/frontend/src/shims-vue.d.ts +0 -6
  147. data/frontend/src/swagger.yaml +0 -771
  148. data/frontend/src/types.ts +0 -188
  149. data/frontend/src/utils.ts +0 -54
  150. data/frontend/src/views/Alerts.vue +0 -20
  151. data/frontend/src/views/Artifact.vue +0 -39
  152. data/frontend/src/views/Configs.vue +0 -20
  153. data/frontend/src/views/EditRule.vue +0 -39
  154. data/frontend/src/views/NewRule.vue +0 -26
  155. data/frontend/src/views/Rule.vue +0 -39
  156. data/frontend/src/views/Rules.vue +0 -20
  157. data/frontend/tests/utils.spec.ts +0 -9
  158. data/frontend/tsconfig.app.json +0 -21
  159. data/frontend/tsconfig.json +0 -14
  160. data/frontend/tsconfig.node.json +0 -13
  161. data/frontend/tsconfig.vitest.json +0 -12
  162. data/frontend/vite.config.ts +0 -24
  163. data/frontend/vitest.config.ts +0 -21
  164. data/lib/mihari/services/alert_proxy.rb +0 -97
@@ -1,32 +0,0 @@
1
- <template>
2
- <Loading v-if="getConfigsTask.isRunning"></Loading>
3
- <ErrorMessage v-if="getConfigsTask.isError" :error="getConfigsTask.last?.error"></ErrorMessage>
4
- <Configs :configs="getConfigsTask.last.value" v-if="getConfigsTask.last?.value"></Configs>
5
- </template>
6
-
7
- <script lang="ts">
8
- import { defineComponent, onMounted } from "vue"
9
-
10
- import { generateGetConfigsTask } from "@/api-helper"
11
- import Configs from "@/components/config/Configs.vue"
12
- import ErrorMessage from "@/components/ErrorMessage.vue"
13
- import Loading from "@/components/Loading.vue"
14
-
15
- export default defineComponent({
16
- name: "ConfigsWrapper",
17
- components: {
18
- Configs,
19
- Loading,
20
- ErrorMessage
21
- },
22
- setup() {
23
- const getConfigsTask = generateGetConfigsTask()
24
-
25
- onMounted(async () => {
26
- await getConfigsTask.perform()
27
- })
28
-
29
- return { getConfigsTask }
30
- }
31
- })
32
- </script>
@@ -1,32 +0,0 @@
1
- <template>
2
- <a :href="link.href(data)" class="tag is-white" target="_blank">
3
- <img :src="link.favicon()" alt="favicon" />
4
- <span>{{ link.name }}</span>
5
- </a>
6
- </template>
7
-
8
- <script lang="ts">
9
- import { defineComponent, type PropType } from "vue"
10
-
11
- import type { Link } from "@/types"
12
-
13
- export default defineComponent({
14
- name: "LinkItem",
15
- props: {
16
- data: {
17
- type: String,
18
- required: true
19
- },
20
- link: {
21
- type: Object as PropType<Link>,
22
- required: true
23
- }
24
- }
25
- })
26
- </script>
27
-
28
- <style scoped>
29
- .tag img {
30
- margin-right: 5px;
31
- }
32
- </style>
@@ -1,42 +0,0 @@
1
- <template>
2
- <div class="tags are-medium">
3
- <LinkComponent :data="data" :link="link" v-for="link in selectedLinks" :key="link.name" />
4
- </div>
5
- </template>
6
-
7
- <script lang="ts">
8
- import { computed, defineComponent } from "vue"
9
-
10
- import LinkComponent from "@/components/link/Link.vue"
11
- import { Links } from "@/links"
12
- import type { Link } from "@/types"
13
-
14
- export default defineComponent({
15
- name: "LinksItem",
16
- components: {
17
- LinkComponent
18
- },
19
- props: {
20
- data: {
21
- type: String,
22
- required: true
23
- },
24
- type: {
25
- type: String,
26
- required: true
27
- }
28
- },
29
- setup(props) {
30
- const links = Links
31
- const selectedLinks = computed((): Link[] => {
32
- if (props.type === undefined) {
33
- return links
34
- }
35
-
36
- return links.filter((link) => link.type === props.type)
37
- })
38
-
39
- return { selectedLinks }
40
- }
41
- })
42
- </script>
@@ -1,72 +0,0 @@
1
- <template>
2
- <div class="column">
3
- <h2 class="is-size-2 mb-4">Edit rule: {{ rule.id }}</h2>
4
- <InputForm v-model:yaml="yaml" @update-yaml="updateYAML"></InputForm>
5
- <div class="field is-grouped is-grouped-centered">
6
- <p class="control">
7
- <a class="button is-primary" @click="edit">
8
- <span class="icon is-small">
9
- <font-awesome-icon icon="edit"></font-awesome-icon>
10
- </span>
11
- <span>Edit</span>
12
- </a>
13
- </p>
14
- </div>
15
- <div v-if="updateRuleTask.last?.error">
16
- <hr />
17
- <ErrorMessage :error="updateRuleTask.last?.error"></ErrorMessage>
18
- </div>
19
- </div>
20
- </template>
21
-
22
- <script lang="ts">
23
- import { defineComponent, type PropType, toRef } from "vue"
24
- import { useRouter } from "vue-router"
25
-
26
- import { generateUpdateRuleTask } from "@/api-helper"
27
- import ErrorMessage from "@/components/ErrorMessage.vue"
28
- import InputForm from "@/components/rule/InputForm.vue"
29
- import type { Rule } from "@/types"
30
-
31
- export default defineComponent({
32
- name: "EditRule",
33
- components: {
34
- InputForm,
35
- ErrorMessage
36
- },
37
- props: {
38
- rule: {
39
- type: Object as PropType<Rule>,
40
- required: true
41
- }
42
- },
43
- setup(props) {
44
- const router = useRouter()
45
-
46
- const rule = toRef(props, "rule")
47
- const yaml = toRef(rule.value, "yaml")
48
-
49
- const updateRuleTask = generateUpdateRuleTask()
50
-
51
- const updateYAML = (value: string) => {
52
- yaml.value = value
53
- }
54
-
55
- const edit = async () => {
56
- const rule = await updateRuleTask.perform({
57
- id: props.rule.id,
58
- yaml: yaml.value
59
- })
60
-
61
- router.push({ name: "Rule", params: { id: rule.id } })
62
- }
63
-
64
- return {
65
- edit,
66
- yaml,
67
- updateYAML,
68
- updateRuleTask
69
- }
70
- }
71
- })
72
- </script>
@@ -1,48 +0,0 @@
1
- <template>
2
- <Loading v-if="getRuleTask.isRunning"></Loading>
3
- <ErrorMessage v-if="getRuleTask.isError" :error="getRuleTask.last?.error"></ErrorMessage>
4
- <EditRule :rule="getRuleTask.last.value" v-if="getRuleTask.last?.value"></EditRule>
5
- </template>
6
-
7
- <script lang="ts">
8
- import { defineComponent, onMounted, watch } from "vue"
9
-
10
- import { generateGetRuleTask } from "@/api-helper"
11
- import ErrorMessage from "@/components/ErrorMessage.vue"
12
- import Loading from "@/components/Loading.vue"
13
- import EditRule from "@/components/rule/EditRule.vue"
14
-
15
- export default defineComponent({
16
- name: "EditRuleWrapper",
17
- components: {
18
- EditRule,
19
- Loading,
20
- ErrorMessage
21
- },
22
- props: {
23
- id: {
24
- type: String,
25
- required: true
26
- }
27
- },
28
- setup(props) {
29
- const getRuleTask = generateGetRuleTask()
30
-
31
- const getRule = async () => {
32
- await getRuleTask.perform(props.id)
33
- }
34
-
35
- onMounted(async () => {
36
- await getRule()
37
- })
38
-
39
- watch(props, async () => {
40
- await getRule()
41
- })
42
-
43
- return {
44
- getRuleTask
45
- }
46
- }
47
- })
48
- </script>
@@ -1,158 +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">Title</label>
7
- </div>
8
- <div class="field-body">
9
- <div class="field">
10
- <p class="control">
11
- <input class="input" type="text" v-model="title" />
12
- </p>
13
- </div>
14
- </div>
15
- </div>
16
- </div>
17
- <div class="column">
18
- <div class="field is-horizontal">
19
- <div class="field-label is-normal">
20
- <label class="label">Description</label>
21
- </div>
22
- <div class="field-body">
23
- <div class="field">
24
- <p class="control">
25
- <input class="input" type="text" v-model="description" />
26
- </p>
27
- </div>
28
- </div>
29
- </div>
30
- </div>
31
- </div>
32
- <div class="columns">
33
- <div class="column">
34
- <div class="field is-horizontal">
35
- <div class="field-label is-normal">
36
- <label class="label">Tag</label>
37
- </div>
38
- <div class="field-body">
39
- <div class="field">
40
- <div class="control">
41
- <div class="select">
42
- <select v-model="tagInput">
43
- <option></option>
44
- <option v-for="tag_ in tags" :key="tag_">
45
- {{ tag_ }}
46
- </option>
47
- </select>
48
- </div>
49
- </div>
50
- </div>
51
- </div>
52
- </div>
53
- </div>
54
- <div class="column"></div>
55
- </div>
56
- <div class="columns">
57
- <div class="column">
58
- <div class="field is-horizontal">
59
- <div class="field-label is-normal">
60
- <label class="label">From</label>
61
- </div>
62
- <div class="field-body">
63
- <div class="field">
64
- <p class="control">
65
- <input class="input" type="date" v-model="fromAt" />
66
- </p>
67
- </div>
68
- </div>
69
- </div>
70
- </div>
71
- <div class="column">
72
- <div class="field is-horizontal">
73
- <div class="field-label is-normal">
74
- <label class="label">To</label>
75
- </div>
76
- <div class="field-body">
77
- <div class="field">
78
- <p class="control">
79
- <input class="input" type="date" v-model="toAt" />
80
- </p>
81
- </div>
82
- </div>
83
- </div>
84
- </div>
85
- </div>
86
- </template>
87
-
88
- <script lang="ts">
89
- import { defineComponent, type PropType, ref, toRef, watch } from "vue"
90
- import { useRoute } from "vue-router"
91
-
92
- import type { RuleSearchParams } from "@/types"
93
- import { normalizeQueryParam } from "@/utils"
94
-
95
- export default defineComponent({
96
- name: "RulesForm",
97
- props: {
98
- tags: {
99
- type: Array as PropType<string[]>,
100
- required: true
101
- },
102
- page: {
103
- type: Number,
104
- required: true
105
- },
106
- tag: {
107
- type: String,
108
- required: false
109
- }
110
- },
111
- setup(props) {
112
- const route = useRoute()
113
-
114
- const description = ref<string | undefined>(undefined)
115
- const fromAt = ref<string | undefined>(undefined)
116
- const tagInput = toRef(props, "tag")
117
- const title = ref<string | undefined>(undefined)
118
- const toAt = ref<string | undefined>(undefined)
119
-
120
- const updateByQueryParams = () => {
121
- const tag_ = route.query["tag"]
122
- if (tagInput.value === undefined) {
123
- tagInput.value = normalizeQueryParam(tag_)
124
- }
125
- }
126
-
127
- const getSearchParams = (): RuleSearchParams => {
128
- updateByQueryParams()
129
-
130
- const params: RuleSearchParams = {
131
- description: description.value === "" ? undefined : description.value,
132
- page: props.page,
133
- tag: tagInput.value === "" ? undefined : tagInput.value,
134
- title: title.value === "" ? undefined : title.value,
135
- toAt: toAt.value === "" ? undefined : toAt.value,
136
- fromAt: fromAt.value === "" ? undefined : fromAt.value
137
- }
138
- return params
139
- }
140
-
141
- watch(
142
- () => props.tag,
143
- () => {
144
- tagInput.value = props.tag
145
- }
146
- )
147
-
148
- return {
149
- description,
150
- fromAt,
151
- getSearchParams,
152
- title,
153
- toAt,
154
- tagInput
155
- }
156
- }
157
- })
158
- </script>
@@ -1,45 +0,0 @@
1
- <template>
2
- <div class="block">
3
- <VAceEditor
4
- class="vue-ace-editor"
5
- v-model:value="yamlInput"
6
- lang="yaml"
7
- theme="monokai"
8
- :options="{
9
- fontSize: 16,
10
- minLines: 6,
11
- maxLines: 10000
12
- }"
13
- ></VAceEditor>
14
- </div>
15
- </template>
16
-
17
- <script lang="ts">
18
- import "@/ace-config"
19
-
20
- import { defineComponent, toRef, watchEffect } from "vue"
21
- import { VAceEditor } from "vue3-ace-editor"
22
-
23
- export default defineComponent({
24
- name: "RuleInputForm",
25
- components: {
26
- VAceEditor
27
- },
28
- props: {
29
- yaml: {
30
- type: String,
31
- required: true
32
- }
33
- },
34
- emits: ["update-yaml"],
35
- setup(props, context) {
36
- const yamlInput = toRef(props, "yaml")
37
-
38
- watchEffect(() => {
39
- context.emit("update-yaml", yamlInput.value)
40
- })
41
-
42
- return { yamlInput }
43
- }
44
- })
45
- </script>
@@ -1,57 +0,0 @@
1
- <template>
2
- <div class="column">
3
- <h2 class="is-size-2 mb-4">New rule</h2>
4
- <InputForm v-model:yaml="yaml" @update-yaml="updateYAML"></InputForm>
5
- <div class="field is-grouped is-grouped-centered">
6
- <p class="control">
7
- <a class="button is-primary" @click="create">
8
- <span class="icon is-small">
9
- <font-awesome-icon icon="plus"></font-awesome-icon>
10
- </span>
11
- <span>Create</span>
12
- </a>
13
- </p>
14
- </div>
15
- <div v-if="createRuleTask.last?.error">
16
- <hr />
17
- <ErrorMessage :error="createRuleTask.last?.error"></ErrorMessage>
18
- </div>
19
- </div>
20
- </template>
21
-
22
- <script lang="ts">
23
- import { defineComponent, ref } from "vue"
24
- import { useRouter } from "vue-router"
25
-
26
- import { generateCreateRuleTask } from "@/api-helper"
27
- import ErrorMessage from "@/components/ErrorMessage.vue"
28
- import InputForm from "@/components/rule/InputForm.vue"
29
- import { getRuleTemplate } from "@/rule"
30
-
31
- export default defineComponent({
32
- name: "NewRule",
33
- components: {
34
- InputForm,
35
- ErrorMessage
36
- },
37
- setup() {
38
- const router = useRouter()
39
-
40
- const yaml = ref(getRuleTemplate())
41
-
42
- const createRuleTask = generateCreateRuleTask()
43
-
44
- const updateYAML = (value: string) => {
45
- yaml.value = value
46
- }
47
-
48
- const create = async () => {
49
- const rule = await createRuleTask.perform({ yaml: yaml.value })
50
-
51
- router.push({ name: "Rule", params: { id: rule.id } })
52
- }
53
-
54
- return { yaml, create, updateYAML, createRuleTask }
55
- }
56
- })
57
- </script>
@@ -1,100 +0,0 @@
1
- <template>
2
- <div class="column">
3
- <div v-if="runRuleTask.isRunning">
4
- <Loading></Loading>
5
- <hr />
6
- </div>
7
- <div v-if="runRuleTask.last?.error">
8
- <ErrorMessage :error="runRuleTask.last.error"></ErrorMessage>
9
- <hr />
10
- </div>
11
- <h2 class="is-size-2 mb-4">Rule</h2>
12
- <p class="block is-clearfix">
13
- <span class="buttons is-pulled-right">
14
- <button class="button is-primary is-light is-small" @click="runRule">
15
- <span>Run</span>
16
- <span class="icon is-small">
17
- <font-awesome-icon icon="arrow-right"></font-awesome-icon>
18
- </span>
19
- </button>
20
- <router-link
21
- class="button is-info is-light is-small"
22
- :to="{ name: 'EditRule', params: { id: rule.id } }"
23
- >
24
- <span>Edit</span>
25
- <span class="icon is-small">
26
- <font-awesome-icon icon="edit"></font-awesome-icon>
27
- </span>
28
- </router-link>
29
- <button class="button is-light is-small" @click="deleteRule">
30
- <span>Delete</span>
31
- <span class="icon is-small">
32
- <font-awesome-icon icon="times"></font-awesome-icon>
33
- </span>
34
- </button>
35
- </span>
36
- </p>
37
- <YAML :yaml="rule.yaml"></YAML>
38
- </div>
39
- <hr />
40
- <div class="column">
41
- <h2 class="is-size-2 mb-4">Related alerts</h2>
42
-
43
- <Alerts :ruleId="rule.id"></Alerts>
44
- </div>
45
- </template>
46
-
47
- <script lang="ts">
48
- import { defineComponent, type PropType } from "vue"
49
- import { useRouter } from "vue-router"
50
-
51
- import { generateDeleteRuleTask, generateRunRuleTask } from "@/api-helper"
52
- import Alerts from "@/components/alert/AlertsWithPagination.vue"
53
- import ErrorMessage from "@/components/ErrorMessage.vue"
54
- import Loading from "@/components/Loading.vue"
55
- import YAML from "@/components/rule/YAML.vue"
56
- import type { Rule } from "@/types"
57
-
58
- export default defineComponent({
59
- name: "RuleItem",
60
- props: {
61
- rule: {
62
- type: Object as PropType<Rule>,
63
- required: true
64
- }
65
- },
66
- components: {
67
- YAML,
68
- Alerts,
69
- Loading,
70
- ErrorMessage
71
- },
72
- emits: ["refresh"],
73
- setup(props, context) {
74
- const router = useRouter()
75
-
76
- const deleteRuleTask = generateDeleteRuleTask()
77
- const runRuleTask = generateRunRuleTask()
78
-
79
- const deleteRule = async () => {
80
- const result = window.confirm(`Are you sure you want to delete ${props.rule.id}?`)
81
-
82
- if (result) {
83
- await deleteRuleTask.perform(props.rule.id)
84
- router.push("/")
85
- }
86
- }
87
-
88
- const runRule = async () => {
89
- await runRuleTask.perform(props.rule.id)
90
- context.emit("refresh")
91
- }
92
-
93
- return {
94
- deleteRule,
95
- runRule,
96
- runRuleTask
97
- }
98
- }
99
- })
100
- </script>
@@ -1,53 +0,0 @@
1
- <template>
2
- <Loading v-if="getRuleTask.isRunning"></Loading>
3
- <ErrorMessage v-if="getRuleTask.isError" :error="getRuleTask.last?.error"></ErrorMessage>
4
- <Rule :rule="getRuleTask.last.value" @refresh="refresh" v-if="getRuleTask.last?.value"></Rule>
5
- </template>
6
-
7
- <script lang="ts">
8
- import { defineComponent, onMounted, watch } from "vue"
9
-
10
- import { generateGetRuleTask } from "@/api-helper"
11
- import ErrorMessage from "@/components/ErrorMessage.vue"
12
- import Loading from "@/components/Loading.vue"
13
- import Rule from "@/components/rule/Rule.vue"
14
-
15
- export default defineComponent({
16
- name: "RuleWrapper",
17
- components: {
18
- Rule,
19
- Loading,
20
- ErrorMessage
21
- },
22
- props: {
23
- id: {
24
- type: String,
25
- required: true
26
- }
27
- },
28
- setup(props) {
29
- const getRuleTask = generateGetRuleTask()
30
-
31
- const getRule = async () => {
32
- await getRuleTask.perform(props.id)
33
- }
34
-
35
- const refresh = async () => {
36
- await getRule()
37
- }
38
-
39
- onMounted(async () => {
40
- await getRule()
41
- })
42
-
43
- watch(props, async () => {
44
- await getRule()
45
- })
46
-
47
- return {
48
- getRuleTask,
49
- refresh
50
- }
51
- }
52
- })
53
- </script>