Skip to content

Commit

Permalink
Merge pull request #7581 from ywywZhou/merge_master
Browse files Browse the repository at this point in the history
Merge master
  • Loading branch information
normal-wls authored Oct 10, 2024
2 parents f8d72b0 + 49c5c73 commit 08196ea
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
3 changes: 2 additions & 1 deletion frontend/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"vue-router": "^3.0.1",
"vuedraggable": "^2.16.0",
"vuex": "^3.0.1",
"xlsx": "^0.18.5"
"xlsx": "^0.18.5",
"xss": "^1.0.15"
},
"devDependencies": {
"@babel/core": "^7.4.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<ErrorCode406 v-if="code === 406"></ErrorCode406>
<ErrorCode407 v-if="code === 407"></ErrorCode407>
<ErrorCode500 v-if="code === 500" :response-text="responseText"></ErrorCode500>
<div class="default-modal" v-if="code === 'default'" v-html="responseText"></div>
<div class="default-modal" v-if="code === 'default'" v-html="filterXSS(responseText)"></div>
</div>
</bk-dialog>
</template>
Expand Down
7 changes: 7 additions & 0 deletions frontend/desktop/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import './public-path.js'
import Vue from 'vue'
import VeeValidate, { Validator } from 'vee-validate'
import filterXSS from 'xss'
import router from './routers/index.js'
import store from './store/index.js'
import './directives/index.js'
Expand Down Expand Up @@ -211,6 +212,12 @@ Validator.localize({
}
})

Vue.prototype.filterXSS = input => filterXSS(input, {
whiteList: {
a: ['href']
}
})

new Vue({
i18n,
router,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,14 @@
return ''
}
if (typeof data === 'string') {
const info = data.replace(/\n/g, '<br>')
// 只渲染a标签,不过滤换行
let info = data.replace(/\n/g, '<br>')
info = this.filterXSS(info, {
whiteList: {
a: ['href'],
br: []
}
})
return info
} else {
return data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@
if (output.value === 'undefined' || output.value === '') {
return '--'
} else if (!output.preset && this.nodeDetailConfig.component_code === 'job_execute_task') {
return output.value
return this.filterXSS(JSON.stringify(output.value))
} else if (Array.isArray(output.value)) {
if (!output.value.length) return '--'
return output.value.reduce((acc, cur) => {
let str = cur
let str = this.filterXSS(cur)
if (this.isUrl(cur)) {
str = `<a style="color: #3a84ff; word-break: break-all;" target="_blank" href="${cur}">${cur}</a>`
}
Expand All @@ -128,7 +128,7 @@
if (this.isUrl(output.value)) {
return `<a style="color: #3a84ff; word-break: break-all;" target="_blank" href="${output.value}">${output.value}</a>`
}
return output.value
return this.filterXSS(JSON.stringify(output.value))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,14 @@
return ''
}
if (typeof data === 'string') {
const info = data.replace(/\n/g, '<br>')
// 只渲染a标签,不过滤换行
let info = data.replace(/\n/g, '<br>')
info = this.filterXSS(info, {
whiteList: {
a: ['href'],
br: []
}
})
return info
} else {
return data
Expand Down

0 comments on commit 08196ea

Please sign in to comment.