mihari 5.2.4 → 5.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -1
  3. data/README.md +0 -10
  4. data/Rakefile +13 -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 +5213 -9655
  11. data/frontend/package.json +38 -25
  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 +4 -4
  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 +22 -27
  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 +43 -50
  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 +69 -86
  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 +9 -12
  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 +23 -23
  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 +19 -19
  44. data/frontend/src/components/rule/Rule.vue +28 -30
  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 +40 -43
  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 +38 -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-b17c40c6.css} +1 -5
  115. data/lib/mihari/web/public/assets/index-f740e4f9.js +799 -0
  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 +29 -117
  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
  127. data/lib/mihari/web/public/assets/fa-brands-400-20c4a58b.ttf +0 -0
  128. data/lib/mihari/web/public/assets/fa-brands-400-74833209.woff2 +0 -0
  129. data/lib/mihari/web/public/assets/fa-regular-400-528d022d.ttf +0 -0
  130. data/lib/mihari/web/public/assets/fa-regular-400-8e7e5ea1.woff2 +0 -0
  131. data/lib/mihari/web/public/assets/fa-solid-900-67a65763.ttf +0 -0
  132. data/lib/mihari/web/public/assets/fa-solid-900-7152a693.woff2 +0 -0
  133. data/lib/mihari/web/public/assets/fa-v4compatibility-0515a423.ttf +0 -0
  134. data/lib/mihari/web/public/assets/fa-v4compatibility-694a17c3.woff2 +0 -0
  135. data/lib/mihari/web/public/assets/index-ac4e5ffa.js +0 -50
@@ -19,18 +19,15 @@
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
- <i class="fas fa-check"></i>
24
+ <font-awesome-icon icon="check"></font-awesome-icon>
28
25
  </span>
29
26
  <span>Yes</span>
30
27
  </button>
31
28
  <button class="button is-warning is-small ml-1" v-else>
32
29
  <span class="icon is-small">
33
- <i class="fas fa-exclamation"></i>
30
+ <font-awesome-icon icon="exclamation"></font-awesome-icon>
34
31
  </span>
35
32
  <span>No</span>
36
33
  </button>
@@ -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>
@@ -8,7 +8,7 @@
8
8
  <p class="control">
9
9
  <a class="button is-primary" @click="edit">
10
10
  <span class="icon is-small">
11
- <i class="fas fa-edit"></i>
11
+ <font-awesome-icon icon="edit"></font-awesome-icon>
12
12
  </span>
13
13
  <span>Edit</span>
14
14
  </a>
@@ -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;
@@ -8,7 +8,7 @@
8
8
  <p class="control">
9
9
  <a class="button is-primary" @click="create">
10
10
  <span class="icon is-small">
11
- <i class="fas fa-plus"></i>
11
+ <font-awesome-icon icon="plus"></font-awesome-icon>
12
12
  </span>
13
13
  <span>Create</span>
14
14
  </a>
@@ -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>