mihari 5.2.4 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -1
  3. data/README.md +0 -10
  4. data/Rakefile +7 -1
  5. data/build_frontend.sh +1 -1
  6. data/frontend/.eslintrc.cjs +22 -0
  7. data/frontend/.gitignore +18 -12
  8. data/frontend/.prettierrc.json +8 -0
  9. data/frontend/env.d.ts +5 -0
  10. data/frontend/package-lock.json +5095 -9661
  11. data/frontend/package.json +34 -24
  12. data/frontend/src/App.vue +5 -5
  13. data/frontend/src/api-helper.ts +38 -40
  14. data/frontend/src/api.ts +40 -40
  15. data/frontend/src/components/ErrorMessage.vue +8 -8
  16. data/frontend/src/components/Loading.vue +3 -3
  17. data/frontend/src/components/Navbar.vue +10 -27
  18. data/frontend/src/components/Pagination.vue +35 -42
  19. data/frontend/src/components/alert/Alert.vue +21 -26
  20. data/frontend/src/components/alert/Alerts.vue +23 -25
  21. data/frontend/src/components/alert/AlertsWithPagination.vue +34 -34
  22. data/frontend/src/components/alert/AlertsWrapper.vue +42 -49
  23. data/frontend/src/components/alert/Form.vue +39 -40
  24. data/frontend/src/components/artifact/AS.vue +7 -7
  25. data/frontend/src/components/artifact/Artifact.vue +66 -83
  26. data/frontend/src/components/artifact/ArtifactTag.vue +21 -27
  27. data/frontend/src/components/artifact/ArtifactTags.vue +8 -8
  28. data/frontend/src/components/artifact/ArtifactWrapper.vue +22 -25
  29. data/frontend/src/components/artifact/CPEs.vue +6 -6
  30. data/frontend/src/components/artifact/DnsRecords.vue +9 -9
  31. data/frontend/src/components/artifact/Ports.vue +6 -6
  32. data/frontend/src/components/artifact/ReverseDnsNames.vue +7 -7
  33. data/frontend/src/components/artifact/Tags.vue +6 -6
  34. data/frontend/src/components/artifact/WhoisRecord.vue +7 -9
  35. data/frontend/src/components/config/Configs.vue +7 -10
  36. data/frontend/src/components/config/ConfigsWrapper.vue +14 -20
  37. data/frontend/src/components/link/Link.vue +7 -7
  38. data/frontend/src/components/link/Links.vue +16 -21
  39. data/frontend/src/components/rule/EditRule.vue +22 -22
  40. data/frontend/src/components/rule/EditRuleWrapper.vue +22 -28
  41. data/frontend/src/components/rule/Form.vue +28 -28
  42. data/frontend/src/components/rule/InputForm.vue +31 -25
  43. data/frontend/src/components/rule/NewRule.vue +18 -18
  44. data/frontend/src/components/rule/Rule.vue +25 -27
  45. data/frontend/src/components/rule/RuleWrapper.vue +24 -31
  46. data/frontend/src/components/rule/Rules.vue +26 -30
  47. data/frontend/src/components/rule/RulesWrapper.vue +39 -42
  48. data/frontend/src/components/rule/YAML.vue +19 -22
  49. data/frontend/src/components/tag/Tag.vue +24 -32
  50. data/frontend/src/components/tag/Tags.vue +11 -11
  51. data/frontend/src/countries.ts +23 -23
  52. data/frontend/src/index.ts +9 -12
  53. data/frontend/src/links/anyrun.ts +10 -10
  54. data/frontend/src/links/base.ts +3 -3
  55. data/frontend/src/links/censys.ts +10 -10
  56. data/frontend/src/links/crtsh.ts +10 -10
  57. data/frontend/src/links/dnslytics.ts +18 -18
  58. data/frontend/src/links/greynoise.ts +10 -10
  59. data/frontend/src/links/index.ts +15 -15
  60. data/frontend/src/links/intezer.ts +10 -10
  61. data/frontend/src/links/otx.ts +14 -14
  62. data/frontend/src/links/securitytrails.ts +15 -15
  63. data/frontend/src/links/shodan.ts +10 -10
  64. data/frontend/src/links/urlscan.ts +19 -19
  65. data/frontend/src/links/virustotal.ts +27 -27
  66. data/frontend/src/main.ts +8 -8
  67. data/frontend/src/router/index.ts +20 -20
  68. data/frontend/src/rule.ts +6 -6
  69. data/frontend/src/shims-vue.d.ts +2 -2
  70. data/frontend/src/types.ts +91 -91
  71. data/frontend/src/utils.ts +23 -29
  72. data/frontend/src/views/Alerts.vue +7 -7
  73. data/frontend/src/views/Artifact.vue +17 -17
  74. data/frontend/src/views/Configs.vue +7 -7
  75. data/frontend/src/views/EditRule.vue +17 -17
  76. data/frontend/src/views/NewRule.vue +10 -10
  77. data/frontend/src/views/Rule.vue +17 -17
  78. data/frontend/src/views/Rules.vue +7 -7
  79. data/frontend/tests/utils.spec.ts +9 -0
  80. data/frontend/tsconfig.app.json +21 -0
  81. data/frontend/tsconfig.json +10 -36
  82. data/frontend/tsconfig.node.json +13 -0
  83. data/frontend/tsconfig.vitest.json +12 -0
  84. data/frontend/vite.config.ts +24 -0
  85. data/frontend/vitest.config.ts +21 -0
  86. data/lefthook.yml +4 -2
  87. data/lib/mihari/analyzers/base.rb +48 -14
  88. data/lib/mihari/analyzers/binaryedge.rb +10 -15
  89. data/lib/mihari/analyzers/censys.rb +12 -15
  90. data/lib/mihari/analyzers/circl.rb +10 -10
  91. data/lib/mihari/analyzers/crtsh.rb +10 -6
  92. data/lib/mihari/analyzers/dnstwister.rb +6 -8
  93. data/lib/mihari/analyzers/feed.rb +21 -10
  94. data/lib/mihari/analyzers/greynoise.rb +10 -20
  95. data/lib/mihari/analyzers/onyphe.rb +9 -14
  96. data/lib/mihari/analyzers/otx.rb +8 -9
  97. data/lib/mihari/analyzers/passivetotal.rb +10 -10
  98. data/lib/mihari/analyzers/pulsedive.rb +21 -31
  99. data/lib/mihari/analyzers/securitytrails.rb +8 -6
  100. data/lib/mihari/analyzers/shodan.rb +8 -13
  101. data/lib/mihari/analyzers/urlscan.rb +15 -20
  102. data/lib/mihari/analyzers/virustotal.rb +16 -26
  103. data/lib/mihari/analyzers/virustotal_intelligence.rb +11 -17
  104. data/lib/mihari/analyzers/zoomeye.rb +12 -17
  105. data/lib/mihari/config.rb +133 -0
  106. data/lib/mihari/constants.rb +3 -0
  107. data/lib/mihari/emitters/slack.rb +13 -3
  108. data/lib/mihari/errors.rb +1 -1
  109. data/lib/mihari/http.rb +2 -3
  110. data/lib/mihari/schemas/analyzer.rb +2 -0
  111. data/lib/mihari/type_checker.rb +6 -6
  112. data/lib/mihari/version.rb +1 -1
  113. data/lib/mihari/web/endpoints/configs.rb +5 -1
  114. data/lib/mihari/web/public/assets/{index-eed1bcd8.css → index-2ba8f0a6.css} +1 -1
  115. data/lib/mihari/web/public/assets/{index-ac4e5ffa.js → index-71285b15.js} +16 -16
  116. data/lib/mihari/web/public/index.html +2 -2
  117. data/lib/mihari/web/public/redoc-static.html +388 -2193
  118. data/lib/mihari.rb +9 -59
  119. data/mihari.gemspec +8 -8
  120. metadata +24 -62
  121. data/frontend/.browserslistrc +0 -3
  122. data/frontend/.eslintrc.js +0 -33
  123. data/frontend/babel.config.js +0 -3
  124. data/frontend/jest.config.js +0 -9
  125. data/frontend/tests/unit/utils.spec.ts +0 -7
  126. data/frontend/vite.config.js +0 -24
@@ -19,10 +19,7 @@
19
19
  {{ config.type }}
20
20
  </td>
21
21
  <td>
22
- <button
23
- class="button is-success is-small ml-1"
24
- v-if="config.isConfigured"
25
- >
22
+ <button class="button is-success is-small ml-1" v-if="config.isConfigured">
26
23
  <span class="icon is-small">
27
24
  <i class="fas fa-check"></i>
28
25
  </span>
@@ -52,17 +49,17 @@
52
49
  </template>
53
50
 
54
51
  <script lang="ts">
55
- import { defineComponent, PropType } from "vue";
52
+ import { defineComponent, type PropType } from "vue"
56
53
 
57
- import { Config } from "@/types";
54
+ import type { Config } from "@/types"
58
55
 
59
56
  export default defineComponent({
60
57
  name: "ConfigsItem",
61
58
  props: {
62
59
  configs: {
63
60
  type: Array as PropType<Config[]>,
64
- required: true,
65
- },
66
- },
67
- });
61
+ required: true
62
+ }
63
+ }
64
+ })
68
65
  </script>
@@ -1,40 +1,34 @@
1
1
  <template>
2
2
  <Loading v-if="getConfigsTask.isRunning"></Loading>
3
3
 
4
- <ErrorMessage
5
- v-if="getConfigsTask.isError"
6
- :error="getConfigsTask.last?.error"
7
- ></ErrorMessage>
4
+ <ErrorMessage v-if="getConfigsTask.isError" :error="getConfigsTask.last?.error"></ErrorMessage>
8
5
 
9
- <Configs
10
- :configs="getConfigsTask.last.value"
11
- v-if="getConfigsTask.last?.value"
12
- ></Configs>
6
+ <Configs :configs="getConfigsTask.last.value" v-if="getConfigsTask.last?.value"></Configs>
13
7
  </template>
14
8
 
15
9
  <script lang="ts">
16
- import { defineComponent, onMounted } from "vue";
10
+ import { defineComponent, onMounted } from "vue"
17
11
 
18
- import { generateGetConfigsTask } from "@/api-helper";
19
- import Configs from "@/components/config/Configs.vue";
20
- import ErrorMessage from "@/components/ErrorMessage.vue";
21
- import Loading from "@/components/Loading.vue";
12
+ import { generateGetConfigsTask } from "@/api-helper"
13
+ import Configs from "@/components/config/Configs.vue"
14
+ import ErrorMessage from "@/components/ErrorMessage.vue"
15
+ import Loading from "@/components/Loading.vue"
22
16
 
23
17
  export default defineComponent({
24
18
  name: "ConfigsWrapper",
25
19
  components: {
26
20
  Configs,
27
21
  Loading,
28
- ErrorMessage,
22
+ ErrorMessage
29
23
  },
30
24
  setup() {
31
- const getConfigsTask = generateGetConfigsTask();
25
+ const getConfigsTask = generateGetConfigsTask()
32
26
 
33
27
  onMounted(async () => {
34
- await getConfigsTask.perform();
35
- });
28
+ await getConfigsTask.perform()
29
+ })
36
30
 
37
- return { getConfigsTask };
38
- },
39
- });
31
+ return { getConfigsTask }
32
+ }
33
+ })
40
34
  </script>
@@ -6,23 +6,23 @@
6
6
  </template>
7
7
 
8
8
  <script lang="ts">
9
- import { defineComponent, PropType } from "vue";
9
+ import { defineComponent, type PropType } from "vue"
10
10
 
11
- import { Link } from "@/types";
11
+ import type { Link } from "@/types"
12
12
 
13
13
  export default defineComponent({
14
14
  name: "LinkItem",
15
15
  props: {
16
16
  data: {
17
17
  type: String,
18
- required: true,
18
+ required: true
19
19
  },
20
20
  link: {
21
21
  type: Object as PropType<Link>,
22
- required: true,
23
- },
24
- },
25
- });
22
+ required: true
23
+ }
24
+ }
25
+ })
26
26
  </script>
27
27
 
28
28
  <style scoped>
@@ -1,47 +1,42 @@
1
1
  <template>
2
2
  <div class="tags are-medium">
3
- <LinkComponent
4
- :data="data"
5
- :link="link"
6
- v-for="link in selectedLinks"
7
- :key="link.name"
8
- />
3
+ <LinkComponent :data="data" :link="link" v-for="link in selectedLinks" :key="link.name" />
9
4
  </div>
10
5
  </template>
11
6
 
12
7
  <script lang="ts">
13
- import { computed, defineComponent } from "vue";
8
+ import { computed, defineComponent } from "vue"
14
9
 
15
- import LinkComponent from "@/components/link/Link.vue";
16
- import { Links } from "@/links";
17
- import { Link } from "@/types";
10
+ import LinkComponent from "@/components/link/Link.vue"
11
+ import { Links } from "@/links"
12
+ import type { Link } from "@/types"
18
13
 
19
14
  export default defineComponent({
20
15
  name: "LinksItem",
21
16
  components: {
22
- LinkComponent,
17
+ LinkComponent
23
18
  },
24
19
  props: {
25
20
  data: {
26
21
  type: String,
27
- required: true,
22
+ required: true
28
23
  },
29
24
  type: {
30
25
  type: String,
31
- required: true,
32
- },
26
+ required: true
27
+ }
33
28
  },
34
29
  setup(props) {
35
- const links = Links;
30
+ const links = Links
36
31
  const selectedLinks = computed((): Link[] => {
37
32
  if (props.type === undefined) {
38
- return links;
33
+ return links
39
34
  }
40
35
 
41
- return links.filter((link) => link.type === props.type);
42
- });
36
+ return links.filter((link) => link.type === props.type)
37
+ })
43
38
 
44
- return { selectedLinks };
45
- },
46
- });
39
+ return { selectedLinks }
40
+ }
41
+ })
47
42
  </script>
@@ -23,52 +23,52 @@
23
23
  </template>
24
24
 
25
25
  <script lang="ts">
26
- import { defineComponent, PropType, ref } from "vue";
27
- import { useRouter } from "vue-router";
26
+ import { defineComponent, type PropType, ref } from "vue"
27
+ import { useRouter } from "vue-router"
28
28
 
29
- import { generateUpdateRuleTask } from "@/api-helper";
30
- import ErrorMessage from "@/components/ErrorMessage.vue";
31
- import InputForm from "@/components/rule/InputForm.vue";
32
- import { Rule } from "@/types";
29
+ import { generateUpdateRuleTask } from "@/api-helper"
30
+ import ErrorMessage from "@/components/ErrorMessage.vue"
31
+ import InputForm from "@/components/rule/InputForm.vue"
32
+ import type { Rule } from "@/types"
33
33
 
34
34
  export default defineComponent({
35
35
  name: "EditRule",
36
36
  components: {
37
37
  InputForm,
38
- ErrorMessage,
38
+ ErrorMessage
39
39
  },
40
40
  props: {
41
41
  rule: {
42
42
  type: Object as PropType<Rule>,
43
- required: true,
44
- },
43
+ required: true
44
+ }
45
45
  },
46
46
  setup(props) {
47
- const router = useRouter();
47
+ const router = useRouter()
48
48
 
49
- const yaml = ref(props.rule.yaml);
49
+ const yaml = ref(props.rule.yaml)
50
50
 
51
- const updateRuleTask = generateUpdateRuleTask();
51
+ const updateRuleTask = generateUpdateRuleTask()
52
52
 
53
53
  const updateYAML = (value: string) => {
54
- yaml.value = value;
55
- };
54
+ yaml.value = value
55
+ }
56
56
 
57
57
  const edit = async () => {
58
58
  const rule = await updateRuleTask.perform({
59
59
  id: props.rule.id,
60
- yaml: yaml.value,
61
- });
60
+ yaml: yaml.value
61
+ })
62
62
 
63
- router.push({ name: "Rule", params: { id: rule.id } });
64
- };
63
+ router.push({ name: "Rule", params: { id: rule.id } })
64
+ }
65
65
 
66
66
  return {
67
67
  edit,
68
68
  yaml,
69
69
  updateYAML,
70
- updateRuleTask,
71
- };
72
- },
73
- });
70
+ updateRuleTask
71
+ }
72
+ }
73
+ })
74
74
  </script>
@@ -1,56 +1,50 @@
1
1
  <template>
2
2
  <Loading v-if="getRuleTask.isRunning"></Loading>
3
3
 
4
- <ErrorMessage
5
- v-if="getRuleTask.isError"
6
- :error="getRuleTask.last?.error"
7
- ></ErrorMessage>
8
-
9
- <EditRule
10
- :rule="getRuleTask.last.value"
11
- v-if="getRuleTask.last?.value"
12
- ></EditRule>
4
+ <ErrorMessage v-if="getRuleTask.isError" :error="getRuleTask.last?.error"></ErrorMessage>
5
+
6
+ <EditRule :rule="getRuleTask.last.value" v-if="getRuleTask.last?.value"></EditRule>
13
7
  </template>
14
8
 
15
9
  <script lang="ts">
16
- import { defineComponent, onMounted, watch } from "vue";
10
+ import { defineComponent, onMounted, watch } from "vue"
17
11
 
18
- import { generateGetRuleTask } from "@/api-helper";
19
- import ErrorMessage from "@/components/ErrorMessage.vue";
20
- import Loading from "@/components/Loading.vue";
21
- import EditRule from "@/components/rule/EditRule.vue";
12
+ import { generateGetRuleTask } from "@/api-helper"
13
+ import ErrorMessage from "@/components/ErrorMessage.vue"
14
+ import Loading from "@/components/Loading.vue"
15
+ import EditRule from "@/components/rule/EditRule.vue"
22
16
 
23
17
  export default defineComponent({
24
18
  name: "EditRuleWrapper",
25
19
  components: {
26
20
  EditRule,
27
21
  Loading,
28
- ErrorMessage,
22
+ ErrorMessage
29
23
  },
30
24
  props: {
31
25
  id: {
32
26
  type: String,
33
- required: true,
34
- },
27
+ required: true
28
+ }
35
29
  },
36
30
  setup(props) {
37
- const getRuleTask = generateGetRuleTask();
31
+ const getRuleTask = generateGetRuleTask()
38
32
 
39
33
  const getRule = async () => {
40
- await getRuleTask.perform(props.id);
41
- };
34
+ await getRuleTask.perform(props.id)
35
+ }
42
36
 
43
37
  onMounted(async () => {
44
- await getRule();
45
- });
38
+ await getRule()
39
+ })
46
40
 
47
41
  watch(props, async () => {
48
- await getRule();
49
- });
42
+ await getRule()
43
+ })
50
44
 
51
45
  return {
52
- getRuleTask,
53
- };
54
- },
55
- });
46
+ getRuleTask
47
+ }
48
+ }
49
+ })
56
50
  </script>
@@ -88,46 +88,46 @@
88
88
  </template>
89
89
 
90
90
  <script lang="ts">
91
- import { defineComponent, PropType, ref, watch } from "vue";
92
- import { useRoute } from "vue-router";
91
+ import { defineComponent, type PropType, ref, watch } from "vue"
92
+ import { useRoute } from "vue-router"
93
93
 
94
- import { RuleSearchParams } from "@/types";
95
- import { normalizeQueryParam } from "@/utils";
94
+ import type { RuleSearchParams } from "@/types"
95
+ import { normalizeQueryParam } from "@/utils"
96
96
 
97
97
  export default defineComponent({
98
98
  name: "RulesForm",
99
99
  props: {
100
100
  tags: {
101
101
  type: Array as PropType<string[]>,
102
- required: true,
102
+ required: true
103
103
  },
104
104
  page: {
105
105
  type: Number,
106
- required: true,
106
+ required: true
107
107
  },
108
108
  tag: {
109
109
  type: String,
110
- required: false,
111
- },
110
+ required: false
111
+ }
112
112
  },
113
113
  setup(props) {
114
- const route = useRoute();
114
+ const route = useRoute()
115
115
 
116
- const description = ref<string | undefined>(undefined);
117
- const fromAt = ref<string | undefined>(undefined);
118
- const tagInput = ref<string | undefined>(props.tag);
119
- const title = ref<string | undefined>(undefined);
120
- const toAt = ref<string | undefined>(undefined);
116
+ const description = ref<string | undefined>(undefined)
117
+ const fromAt = ref<string | undefined>(undefined)
118
+ const tagInput = ref<string | undefined>(props.tag)
119
+ const title = ref<string | undefined>(undefined)
120
+ const toAt = ref<string | undefined>(undefined)
121
121
 
122
122
  const updateByQueryParams = () => {
123
- const tag_ = route.query["tag"];
123
+ const tag_ = route.query["tag"]
124
124
  if (tagInput.value === undefined) {
125
- tagInput.value = normalizeQueryParam(tag_);
125
+ tagInput.value = normalizeQueryParam(tag_)
126
126
  }
127
- };
127
+ }
128
128
 
129
129
  const getSearchParams = (): RuleSearchParams => {
130
- updateByQueryParams();
130
+ updateByQueryParams()
131
131
 
132
132
  const params: RuleSearchParams = {
133
133
  description: description.value === "" ? undefined : description.value,
@@ -135,17 +135,17 @@ export default defineComponent({
135
135
  tag: tagInput.value === "" ? undefined : tagInput.value,
136
136
  title: title.value === "" ? undefined : title.value,
137
137
  toAt: toAt.value === "" ? undefined : toAt.value,
138
- fromAt: fromAt.value === "" ? undefined : fromAt.value,
139
- };
140
- return params;
141
- };
138
+ fromAt: fromAt.value === "" ? undefined : fromAt.value
139
+ }
140
+ return params
141
+ }
142
142
 
143
143
  watch(
144
144
  () => props.tag,
145
145
  () => {
146
- tagInput.value = props.tag;
146
+ tagInput.value = props.tag
147
147
  }
148
- );
148
+ )
149
149
 
150
150
  return {
151
151
  description,
@@ -153,8 +153,8 @@ export default defineComponent({
153
153
  getSearchParams,
154
154
  title,
155
155
  toAt,
156
- tagInput,
157
- };
158
- },
159
- });
156
+ tagInput
157
+ }
158
+ }
159
+ })
160
160
  </script>
@@ -11,63 +11,69 @@
11
11
 
12
12
  <script lang="ts">
13
13
  // eslint-disable-next-line simple-import-sort/imports
14
- import "vue-prism-editor/dist/prismeditor.min.css";
14
+ import "vue-prism-editor/dist/prismeditor.min.css"
15
15
 
16
- import { defineComponent, ref, watchEffect } from "vue";
17
- import { PrismEditor } from "vue-prism-editor";
16
+ import { defineComponent, ref, watchEffect } from "vue"
17
+ import { PrismEditor } from "vue-prism-editor"
18
18
 
19
- import Prism from "prismjs";
19
+ import Prism from "prismjs"
20
20
 
21
- import "prismjs/components/prism-yaml";
22
- import "prismjs/plugins/custom-class/prism-custom-class";
23
- import "prismjs/themes/prism-twilight.css";
21
+ import "prismjs/components/prism-yaml"
22
+ import "prismjs/plugins/custom-class/prism-custom-class"
23
+ import "prismjs/themes/prism-twilight.css"
24
24
 
25
25
  export default defineComponent({
26
26
  name: "RuleInputForm",
27
27
  components: {
28
- PrismEditor,
28
+ PrismEditor
29
29
  },
30
30
  props: {
31
31
  yaml: {
32
32
  type: String,
33
- required: true,
34
- },
33
+ required: true
34
+ }
35
35
  },
36
36
  emits: ["update-yaml"],
37
37
  setup(props, context) {
38
- const yamlInput = ref(props.yaml);
39
- const wrapper = ref<HTMLElement | undefined>(undefined);
38
+ const yamlInput = ref(props.yaml)
39
+ const wrapper = ref<HTMLElement | undefined>(undefined)
40
40
 
41
41
  Prism.plugins.customClass.map({
42
42
  number: "prism-number",
43
- tag: "prism-tag",
44
- });
43
+ tag: "prism-tag"
44
+ })
45
45
 
46
46
  const highlighter = (code: string) => {
47
- return Prism.highlight(code, Prism.languages.yaml, "yaml");
48
- };
47
+ return Prism.highlight(code, Prism.languages.yaml, "yaml")
48
+ }
49
49
 
50
50
  watchEffect(() => {
51
- context.emit("update-yaml", yamlInput.value);
51
+ context.emit("update-yaml", yamlInput.value)
52
52
 
53
53
  // TODO: a dirty hack to change the default text color
54
54
  if (wrapper.value) {
55
- const strings = wrapper.value.querySelectorAll(":not(span.token)");
55
+ const strings = wrapper.value.querySelectorAll(":not(span.token)")
56
56
  strings.forEach((string) => {
57
- (string as HTMLElement).style.color = "white";
58
- });
57
+ ;(string as HTMLElement).style.color = "white"
58
+ })
59
59
  }
60
- });
60
+ })
61
61
 
62
- return { yamlInput, highlighter, wrapper };
63
- },
64
- });
62
+ return { yamlInput, highlighter, wrapper }
63
+ }
64
+ })
65
65
  </script>
66
66
 
67
67
  <style scoped>
68
68
  .my-editor {
69
69
  background: hsl(0, 0%, 8%);
70
- font-family: Fira code, Fira Mono, Consolas, Menlo, Courier, monospace;
70
+ font-family:
71
+ Fira code,
72
+ Fira Mono,
73
+ Consolas,
74
+ Menlo,
75
+ Courier,
76
+ monospace;
71
77
  font-size: 1em;
72
78
  line-height: 1.5;
73
79
  padding: 5px;
@@ -23,38 +23,38 @@
23
23
  </template>
24
24
 
25
25
  <script lang="ts">
26
- import { defineComponent, ref } from "vue";
27
- import { useRouter } from "vue-router";
26
+ import { defineComponent, ref } from "vue"
27
+ import { useRouter } from "vue-router"
28
28
 
29
- import { generateCreateRuleTask } from "@/api-helper";
30
- import ErrorMessage from "@/components/ErrorMessage.vue";
31
- import InputForm from "@/components/rule/InputForm.vue";
32
- import { getRuleTemplate } from "@/rule";
29
+ import { generateCreateRuleTask } from "@/api-helper"
30
+ import ErrorMessage from "@/components/ErrorMessage.vue"
31
+ import InputForm from "@/components/rule/InputForm.vue"
32
+ import { getRuleTemplate } from "@/rule"
33
33
 
34
34
  export default defineComponent({
35
35
  name: "NewRule",
36
36
  components: {
37
37
  InputForm,
38
- ErrorMessage,
38
+ ErrorMessage
39
39
  },
40
40
  setup() {
41
- const router = useRouter();
41
+ const router = useRouter()
42
42
 
43
- const yaml = ref(getRuleTemplate());
43
+ const yaml = ref(getRuleTemplate())
44
44
 
45
- const createRuleTask = generateCreateRuleTask();
45
+ const createRuleTask = generateCreateRuleTask()
46
46
 
47
47
  const updateYAML = (value: string) => {
48
- yaml.value = value;
49
- };
48
+ yaml.value = value
49
+ }
50
50
 
51
51
  const create = async () => {
52
- const rule = await createRuleTask.perform({ yaml: yaml.value });
52
+ const rule = await createRuleTask.perform({ yaml: yaml.value })
53
53
 
54
- router.push({ name: "Rule", params: { id: rule.id } });
55
- };
54
+ router.push({ name: "Rule", params: { id: rule.id } })
55
+ }
56
56
 
57
- return { yaml, create, updateYAML, createRuleTask };
58
- },
59
- });
57
+ return { yaml, create, updateYAML, createRuleTask }
58
+ }
59
+ })
60
60
  </script>
@@ -51,58 +51,56 @@
51
51
  </template>
52
52
 
53
53
  <script lang="ts">
54
- import { defineComponent, PropType } from "vue";
55
- import { useRouter } from "vue-router";
54
+ import { defineComponent, type PropType } from "vue"
55
+ import { useRouter } from "vue-router"
56
56
 
57
- import { generateDeleteRuleTask, generateRunRuleTask } from "@/api-helper";
58
- import Alerts from "@/components/alert/AlertsWithPagination.vue";
59
- import ErrorMessage from "@/components/ErrorMessage.vue";
60
- import Loading from "@/components/Loading.vue";
61
- import YAML from "@/components/rule/YAML.vue";
62
- import { Rule } from "@/types";
57
+ import { generateDeleteRuleTask, generateRunRuleTask } from "@/api-helper"
58
+ import Alerts from "@/components/alert/AlertsWithPagination.vue"
59
+ import ErrorMessage from "@/components/ErrorMessage.vue"
60
+ import Loading from "@/components/Loading.vue"
61
+ import YAML from "@/components/rule/YAML.vue"
62
+ import type { Rule } from "@/types"
63
63
 
64
64
  export default defineComponent({
65
65
  name: "RuleItem",
66
66
  props: {
67
67
  rule: {
68
68
  type: Object as PropType<Rule>,
69
- required: true,
70
- },
69
+ required: true
70
+ }
71
71
  },
72
72
  components: {
73
73
  YAML,
74
74
  Alerts,
75
75
  Loading,
76
- ErrorMessage,
76
+ ErrorMessage
77
77
  },
78
78
  emits: ["refresh"],
79
79
  setup(props, context) {
80
- const router = useRouter();
80
+ const router = useRouter()
81
81
 
82
- const deleteRuleTask = generateDeleteRuleTask();
83
- const runRuleTask = generateRunRuleTask();
82
+ const deleteRuleTask = generateDeleteRuleTask()
83
+ const runRuleTask = generateRunRuleTask()
84
84
 
85
85
  const deleteRule = async () => {
86
- const result = window.confirm(
87
- `Are you sure you want to delete ${props.rule.id}?`
88
- );
86
+ const result = window.confirm(`Are you sure you want to delete ${props.rule.id}?`)
89
87
 
90
88
  if (result) {
91
- await deleteRuleTask.perform(props.rule.id);
92
- router.push("/");
89
+ await deleteRuleTask.perform(props.rule.id)
90
+ router.push("/")
93
91
  }
94
- };
92
+ }
95
93
 
96
94
  const runRule = async () => {
97
- await runRuleTask.perform(props.rule.id);
98
- context.emit("refresh");
99
- };
95
+ await runRuleTask.perform(props.rule.id)
96
+ context.emit("refresh")
97
+ }
100
98
 
101
99
  return {
102
100
  deleteRule,
103
101
  runRule,
104
- runRuleTask,
105
- };
106
- },
107
- });
102
+ runRuleTask
103
+ }
104
+ }
105
+ })
108
106
  </script>