Skip to content

Commit 32aeb04

Browse files
balakineajoshi-CB
authored andcommitted
[SECURITY-3535]
1 parent 6478447 commit 32aeb04

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/main/java/hudson/plugins/global_build_stats/GlobalBuildStatsPlugin.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import jakarta.servlet.ServletException;
2828

29+
import jenkins.model.Jenkins;
2930
import net.sf.json.JSONObject;
3031

3132
import org.jfree.chart.JFreeChart;
@@ -123,16 +124,32 @@ public GlobalBuildStatsApi(Object bean) {
123124
public void doJson(StaplerRequest2 req, StaplerResponse2 rsp)
124125
throws IOException, ServletException {
125126
if(!exposeChartData(req, rsp, Flavor.JSON)){
127+
Jenkins.get().checkPermission(getRequiredPermission());
126128
super.doJson(req, rsp);
127129
}
128130
}
129131
@Override
130132
public void doPython(StaplerRequest2 req, StaplerResponse2 rsp)
131133
throws IOException, ServletException {
132134
if(!exposeChartData(req, rsp, Flavor.PYTHON)){
135+
Jenkins.get().checkPermission(getRequiredPermission());
133136
super.doPython(req, rsp);
134137
}
135138
}
139+
@Override
140+
public void doXml(
141+
StaplerRequest2 req,
142+
StaplerResponse2 rsp,
143+
@QueryParameter String xpath,
144+
@QueryParameter String wrapper,
145+
@QueryParameter String tree,
146+
@QueryParameter int depth
147+
) throws IOException, ServletException {
148+
if (!exposeChartData(req, rsp, Flavor.XML)) {
149+
Jenkins.get().checkPermission(getRequiredPermission());
150+
super.doXml(req, rsp, xpath, wrapper, tree, depth);
151+
}
152+
}
136153

137154
private static boolean exposeChartData(StaplerRequest2 req, StaplerResponse2 rsp, Flavor flavor) throws ServletException, IOException{
138155
boolean chartDataHasBeenExposed = false;
@@ -456,7 +473,7 @@ public List<BuildStatConfiguration> getBuildStatConfigs() {
456473
return buildStatConfigs;
457474
}
458475

459-
public Permission getRequiredPermission(){
476+
public static Permission getRequiredPermission(){
460477
return Hudson.ADMINISTER;
461478
}
462479

0 commit comments

Comments
 (0)