|
26 | 26 |
|
27 | 27 | import jakarta.servlet.ServletException;
|
28 | 28 |
|
| 29 | +import jenkins.model.Jenkins; |
29 | 30 | import net.sf.json.JSONObject;
|
30 | 31 |
|
31 | 32 | import org.jfree.chart.JFreeChart;
|
@@ -123,16 +124,32 @@ public GlobalBuildStatsApi(Object bean) {
|
123 | 124 | public void doJson(StaplerRequest2 req, StaplerResponse2 rsp)
|
124 | 125 | throws IOException, ServletException {
|
125 | 126 | if(!exposeChartData(req, rsp, Flavor.JSON)){
|
| 127 | + Jenkins.get().checkPermission(getRequiredPermission()); |
126 | 128 | super.doJson(req, rsp);
|
127 | 129 | }
|
128 | 130 | }
|
129 | 131 | @Override
|
130 | 132 | public void doPython(StaplerRequest2 req, StaplerResponse2 rsp)
|
131 | 133 | throws IOException, ServletException {
|
132 | 134 | if(!exposeChartData(req, rsp, Flavor.PYTHON)){
|
| 135 | + Jenkins.get().checkPermission(getRequiredPermission()); |
133 | 136 | super.doPython(req, rsp);
|
134 | 137 | }
|
135 | 138 | }
|
| 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 | + } |
136 | 153 |
|
137 | 154 | private static boolean exposeChartData(StaplerRequest2 req, StaplerResponse2 rsp, Flavor flavor) throws ServletException, IOException{
|
138 | 155 | boolean chartDataHasBeenExposed = false;
|
@@ -456,7 +473,7 @@ public List<BuildStatConfiguration> getBuildStatConfigs() {
|
456 | 473 | return buildStatConfigs;
|
457 | 474 | }
|
458 | 475 |
|
459 |
| - public Permission getRequiredPermission(){ |
| 476 | + public static Permission getRequiredPermission(){ |
460 | 477 | return Hudson.ADMINISTER;
|
461 | 478 | }
|
462 | 479 |
|
|
0 commit comments