jenkinsci / jenkinsci/arestocats-plugin

[JENKINS-74681] [arestocats] Extract inline script block in org/jenkinsci/plugins/arestocats/ArestocatsProjectResultsAction/index.jelly

Open
#11 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
0
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Problem

```
== Inline Script Block
Line: 9
----

var results = ${it.results};
var charts = [];
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawCharts);
function drawCharts(){
results.forEach( ( result, index ) => {
var data = new google.visualization.DataTable();
data.addColumn( 'string', 'X' );
var testcase = Object.keys(result)[0];
var measurements = result[testcase];
var labeling = measurements["outcomes"];
labeling.forEach( label => {
data.addColumn( 'number', label );
});
data.addRows(measurements["data"]);
var options = {
'title': testcase,
isStacked: true,
chartArea: {
left: 100,
width: 600
},
width: 1000,
hAxis: {
title: 'Build Nr.'
},
vAxis: {
title: 'test-cases'
}
};
var div = document.createElement( "div" );
div.setAttribute( "id", testcase );
document.getElementById( "main-panel" ).appendChild( div );
var chart = new google.visualization.AreaChart( document.getElementById( testcase ) );
chart.draw( data, options );
charts.push( chart );
} );
}

----

```

Solution

https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks

---
Originally reported by basil, imported from: [arestocats] Extract inline script block in org/jenkinsci/plugins/arestocats/ArestocatsProjectResultsAction/index.jelly


  • status: Open
  • priority: Minor
  • component(s): _unsorted
  • label(s): CSP
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 2025-12-08

Raw content of original issue

Problem


== Inline Script Block

Line: 9
----
<script type="text/javascript">
var results = ${it.results};
var charts = [];
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawCharts);
function drawCharts(){
results.forEach( ( result, index ) => {
var data = new google.visualization.DataTable();
data.addColumn( 'string', 'X' );
var testcase = Object.keys(result)[0];
var measurements = result[testcase];
var labeling = measurements["outcomes"];
labeling.forEach( label => {
data.addColumn( 'number', label );
});
data.addRows(measurements["data"]);
var options = {
'title': testcase,
isStacked: true,
chartArea: {
left: 100,
width: 600
},
width: 1000,
hAxis: {
title: 'Build Nr.'
},
vAxis: {
title: 'test-cases'
}
};
var div = document.createElement( "div" );
div.setAttribute( "id", testcase );
document.getElementById( "main-panel" ).appendChild( div );
var chart = new google.visualization.AreaChart( document.getElementById( testcase ) );
chart.draw( data, options );
charts.push( chart );
} );
}
</script>
----

Solution

https://www.jenkins.io/doc/developer/security/csp/#inline-javascript-blocks

Contributor guide

Open the contributing guide

Research direction

Start with org/jenkinsci/plugins/arestocats/ArestocatsProjectResultsAction/index.jelly and inspect the inline script at line 9. Read the linked Jenkins CSP guidance, then determine the project’s existing pattern for external resources. Done means the chart code is no longer inline and the results page retains its current chart behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
security
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.