-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Minor
-
Component/s: wattspeed-plugin
Problems
== Inline Script Block
Line: 5
----
<script>
var apiToken = null;
function checkProjects() {
if(document.querySelector('#loading-projects'))
document.querySelector('#loading-projects').style.display = "table-row";
if(document.querySelector('#wattspeed-token'))
apiToken = document.querySelector('#wattspeed-token').value;
backend.getProjectsArray(apiToken, function(t) {
projectsCount = t.responseObject();
if(projectsCount === -1 || projectsCount === -2 || apiToken === null)
{
if(document.querySelector('#wattspeed-invalid-token'))
document.querySelector('#wattspeed-invalid-token').style.display = "table-row";
if(document.querySelector('#projects_dd'))
document.querySelector('#projects_dd').style.display = "none";
if(projectsCount === -1)
document.querySelector('#wattspeed-error-message').textContent = "Provided token is invalid";
if(projectsCount === -2)
document.querySelector('#wattspeed-error-message').textContent = "No webpages found in your Wattspeed account";
}
else
{
if(document.querySelector('#wattspeed-invalid-token'))
document.querySelector('#wattspeed-invalid-token').style.display = "none";
if(document.querySelector('#projects_dd'))
document.querySelector('#projects_dd').style.display = "table-row";
}
if(document.querySelector('#wattspeed-projects'))
{
let projectsElement = document.querySelector('#wattspeed-projects').parentNode.parentElement;
if(projectsCount > 0)
{
projectsElement.style.display = "table-row";
document.querySelector('#wattspeed-projects').style.display = "table-row";
document.querySelector('#wattspeed-projects').focus();
}
else
{
projectsElement.style.display = "none";
document.querySelector('#wattspeed-projects').style.display = "none";
}
}
if(document.querySelector('#loading-projects'))
document.querySelector('#loading-projects').style.display = "none";
});
}
setTimeout(function(){
checkProjects();
}, 50);
</script>
----
== Inline Event Handler
Line: 62
----
<f:textbox oninput="checkProjects()" id="wattspeed-token"/>
----
Solutions
https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks
https://www.jenkins.io/doc/developer/security/csp/#inline-event-handlers