-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Minor
-
Component/s: _unsorted
Problems
== Inline Script Block
Line: 7
----
<script>
const showWxWorkPluginSettingLoading = el => {
el.style.display = "block"
}
const closeWxWorkPluginSettingLoading = el => {
el.style.display = "none"
}
const findWxWorkPluginTestQuery = (el) => {
let id = el.querySelector('input[name="id"]').value;
let name = el.querySelector('input[name="name"]').value;
let webhook = el.querySelector('input[name="webhook"]').value;
let dict = {
id: id, name: name, webhook: webhook
}
let qs = "?"
for (let k in dict) {
qs += k + "=" + dict[k] + "&"
}
return qs
}
const sendWxWorkPluginRobotTest = async (el) => {
let $robotBox = el.closest('.wxwork-robot-config')
let url = el.getAttribute("data-request-url")
let method = el.getAttribute("data-request-method")
let loadingBox = el.nextSibling
let infoBox = loadingBox.nextSibling
// send ajax request with requestUrl
let requestUrl = url + "/" + method
showWxWorkPluginSettingLoading(loadingBox)
// send request
let res = await fetch(requestUrl + findWxWorkPluginTestQuery($robotBox), {
method: 'GET'
})
let resText = await res.text()
if (res.status === 200) {
infoBox.innerHTML = resText
} else {
infoBox.innerHTML = "测试异常!"
}
closeWxWorkPluginSettingLoading(loadingBox)
}
</script>
----
== Inline Event Handler
Line: 66
----
<input type="button" value="${%robotTest}" class="validate-button" style="float:right"
data-request-url="${descriptor.descriptorFullUrl}"
data-request-method="test"
data-validate-button-with="${with}"
onclick="sendWxWorkPluginRobotTest(this)"/>
----
Solutions
https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks
https://www.jenkins.io/doc/developer/security/csp/#inline-event-handlers