-
Task
-
Resolution: Unresolved
-
Minor
Note
While testing this plugin, evaluate whether the third-party libraries in src/main/webapp are compatible with CSP in restrictive mode. The plugin may need to be upgraded from jQuery 1.x to 3.x to fully function in CSP restrictive mode.
Problems
== Inline Script Block Line: 37 ---- <script>jQuery.noConflict();</script> ---- == Inline Script Block Line: 38 ---- <script> // Following form is necessary with jQuery.noConflict() to avoid conflict with prototype.js jQuery(function ($) { $(document).ready(function() { <j:if test="${it.ContentAvailable == false}"> // Redirect case no result is available window.location.href="${it.RootPageURL}"; </j:if> <j:if test="${it.NumberOfHeads == 1}"> var heads = 1; var list_heads = [0]; </j:if> <j:if test="${it.NumberOfHeads == 2}"> var heads = 2; var list_heads = [0,1]; </j:if> <j:if test="${it.NumberOfHeads == 3}"> var heads = 3; var list_heads = [0,1,2]; </j:if> <j:if test="${it.NumberOfHeads == 4}"> var heads = 4; var list_heads = [0,1,2,3]; </j:if> var table_1 = $$('#raw_results').DataTable( { scrollX: true, scrollCollapse: true, sDom: 'tp', pageLength: 10, fixedColumns: { leftColumns: heads }, columnDefs: [{ targets: heads, visible: false, searchable: false }], "language": { "zeroRecords": "${it.ZeroRecordsWord}", "emptyTable": "${it.EmptyTableWord}", "paginate": { "first": "${it.FirstWord}", "previous": "${it.PreviousWord}", "next": "${it.NextWord}", "last": "${it.LastWord}" } } } ); var table_2 = $$('#condensed_results').DataTable( { scrollX: true, scrollCollapse: true, sDom: 'tp', pageLength: 10, fixedColumns: { leftColumns: heads }, columnDefs: [{ targets: heads, visible: false, searchable: false }], "language": { "zeroRecords": "${it.ZeroRecordsWord}", "emptyTable": "${it.EmptyTableWord}", "paginate": { "first": "${it.FirstWord}", "previous": "${it.PreviousWord}", "next": "${it.NextWord}", "last": "${it.LastWord}" } } } ); // Synchronize column sorting var changedFlag = false; table_1.on('order.dt', function(){ if(changedFlag == true) { changedFlag = false; return; } changedFlag = true; var order = table_1.order(); var valid = (heads > order[0][0]); if (valid){ table_2.order( order ).draw(); } } ); table_2.on('order.dt', function(){ if(changedFlag == true) { changedFlag = false; return; } changedFlag = true; var order = table_2.order() var valid = (heads > order[0][0]); if (valid){ table_1.order( order ).draw(); } } ); // Synchronize table search field $$('#searchField_1').on( 'change keydown paste input', function () { table_1.search($$(this).val()).draw(); table_2.search($$(this).val()).draw(); $$('#searchField_2').val($$(this).val()); } ); $$('#searchField_2').on( 'change keydown paste input', function () { table_1.search($$(this).val()).draw(); table_2.search($$(this).val()).draw(); $$('#searchField_1').val($$(this).val()); } ); // Synchronize table number of entries $$("#nEntries_1").on( 'change', function(){ table_1.page.len($$(this).val()).draw(); table_2.page.len($$(this).val()).draw(); $$('#nEntries_2').val($$(this).val()); } ); $$("#nEntries_2").on( 'change', function(){ table_1.page.len($$(this).val()).draw(); table_2.page.len($$(this).val()).draw(); $$('#nEntries_1').val($$(this).val()); } ); table_1.page.len($$("#nEntries_1").val()).draw(); table_2.page.len($$("#nEntries_1").val()).draw(); // Synchronize table pagination table_1.on('page.dt', function(){ table_2.page( table_1.page() ).draw( 'page' ); } ); table_2.on('page.dt', function(){ table_1.page( table_2.page() ).draw( 'page' ); } ); // Allow user to expand/contract content by clicking on title $$('.expand_rawResults').click(function(){ $$('#div_rawResults').slideToggle('fast'); if (document.getElementById("icon_rawResults").getAttribute("number") == 0) { document.getElementById("icon_rawResults").src = "${rootURL}/plugin/benchmark/images/sort_both.png"; document.getElementById("icon_rawResults").setAttribute("number", "1"); } else { document.getElementById("icon_rawResults").src = "${rootURL}/plugin/benchmark/images/sort_desc.png"; document.getElementById("icon_rawResults").setAttribute("number", "0"); } }); $$('.expand_condensedResults').click(function(){ $$('#div_condensedResults').slideToggle('fast'); if (document.getElementById("icon_condensedResults").getAttribute("number") == 0) { document.getElementById("icon_condensedResults").src = "${rootURL}/plugin/benchmark/images/sort_both.png"; document.getElementById("icon_condensedResults").setAttribute("number", "1"); } else { document.getElementById("icon_condensedResults").src = "${rootURL}/plugin/benchmark/images/sort_desc.png"; document.getElementById("icon_condensedResults").setAttribute("number", "0"); } }); <j:set var="resultPageURL" value="${it.ResultPageURL}"/> var resultPageURL = "${resultPageURL}"; var BchPub = <st:bind value="${it}"/> table_1.on( 'click', 'tr', function () { BchPub.setResultSelected($('#raw_results').DataTable().row($(this)).data()[heads]); window.location.href = resultPageURL; } ); table_2.on( 'click', 'tr', function () { BchPub.setResultSelected($('#condensed_results').DataTable().row($(this)).data()[heads]); window.location.href = resultPageURL; } ); $("#btn-save-raw").click( function() { BchPub.getCSVRawTable( function(t){ var text = t.responseObject(); var blob = new Blob([text], {type: "text/plain;charset=utf-8"}); saveAs(blob, "benchmark-raw.csv"); }); BchPub.getCSVRawStateTable( function(t){ var text = t.responseObject(); var blob = new Blob([text], {type: "text/plain;charset=utf-8"}); saveAs(blob, "benchmark-raw-state.csv"); }); }); $("#btn-save-con").click( function() { BchPub.getCSVCondensedTable( function(t){ var text = t.responseObject(); var blob = new Blob([text], {type: "text/plain;charset=utf-8"}); saveAs(blob, "benchmark-condensed.csv"); }); }); // Sent ping to the backend to reset the clock that counts down content deletion setInterval(BchPub.resetClock, 30000); // Every 30s } ); } ); </script> ----
Solution
https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks