Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: stored XSS in triggers view via trigger name (#17712)

boojack2d7e425ff326
diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.ts
index 11819d7cb0..23ec9006f2 100644
--- a/frontend/src/utils/util.ts
+++ b/frontend/src/utils/util.ts
@@ -200,6 +200,9 @@ export function getHighlightHTMLByRegExp(
caseSensitive = false,
className = "text-accent"
) {
+ if (!pattern || (Array.isArray(pattern) && pattern.length === 0)) {
+ return s;
+ }
pattern = Array.isArray(pattern)
? pattern.map((kw) => escapeRegExp(kw)).join("|")
: escapeRegExp(pattern);
diff --git a/frontend/src/views/sql-editor/EditorPanel/common/EllipsisCell.vue b/frontend/src/views/sql-editor/EditorPanel/common/EllipsisCell.vue
index d0a062f586..8e19c41a80 100644
--- a/frontend/src/views/sql-editor/EditorPanel/common/EllipsisCell.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/common/EllipsisCell.vue
@@ -19,6 +19,7 @@
</template>
<script setup lang="ts">
+import { escape } from "lodash-es";
import { NPerformantEllipsis } from "naive-ui";
import { computed } from "vue";
import { getHighlightHTMLByRegExp, type VueClass } from "@/utils";
@@ -37,14 +38,29 @@ const props = defineProps<{
const html = computed(() => {
const { content, keyword } = props;
- if (!keyword) return content;
- return getHighlightHTMLByRegExp(content, keyword);
+ const kw = (keyword ?? "").trim();
+ if (!kw) {
+ return escape(content);
+ }
+ return getHighlightHTMLByRegExp(
+ escape(content),
+ escape(kw),
+ false /* !caseSensitive */
+ );
});
const tooltipHTML = computed(() => {
const { keyword, tooltip } = props;
if (typeof tooltip === "string") {
- return getHighlightHTMLByRegExp(tooltip, keyword ?? "");
+ const kw = (keyword ?? "").trim();
+ if (!kw) {
+ return escape(tooltip);
+ }
+ return getHighlightHTMLByRegExp(
+ escape(tooltip),
+ escape(kw),
+ false /* !caseSensitive */
+ );
}
return html.value;
});