|
170 | 170 | import jenkins.model.details.Detail; |
171 | 171 | import jenkins.model.details.DetailFactory; |
172 | 172 | import jenkins.model.details.DetailGroup; |
| 173 | +import jenkins.telemetry.impl.PasswordMasking; |
173 | 174 | import jenkins.util.SystemProperties; |
174 | 175 | import org.apache.commons.jelly.JellyContext; |
175 | 176 | import org.apache.commons.jelly.JellyTagException; |
@@ -2256,32 +2257,64 @@ public String getPasswordValue(Object o) { |
2256 | 2257 | if (o instanceof Secret || Secret.BLANK_NONSECRET_PASSWORD_FIELDS_WITHOUT_ITEM_CONFIGURE) { |
2257 | 2258 | if (req != null) { |
2258 | 2259 | if (NON_RECURSIVE_PASSWORD_MASKING_PERMISSION_CHECK) { |
| 2260 | + List<Ancestor> ancestors = req.getAncestors(); |
| 2261 | + String closestAncestor = ancestors.isEmpty() ? "unknown" : |
| 2262 | + ancestors.getLast().getObject().getClass().getName(); |
| 2263 | + |
2259 | 2264 | Item item = req.findAncestorObject(Item.class); |
2260 | 2265 | if (item != null && !item.hasPermission(Item.CONFIGURE)) { |
| 2266 | + PasswordMasking.recordMasking( |
| 2267 | + item.getClass().getName(), |
| 2268 | + closestAncestor, |
| 2269 | + getJellyViewsInformationForCurrentRequest() |
| 2270 | + ); |
2261 | 2271 | return "********"; |
2262 | 2272 | } |
2263 | 2273 | Computer computer = req.findAncestorObject(Computer.class); |
2264 | 2274 | if (computer != null && !computer.hasPermission(Computer.CONFIGURE)) { |
| 2275 | + PasswordMasking.recordMasking( |
| 2276 | + computer.getClass().getName(), |
| 2277 | + closestAncestor, |
| 2278 | + getJellyViewsInformationForCurrentRequest() |
| 2279 | + ); |
2265 | 2280 | return "********"; |
2266 | 2281 | } |
2267 | 2282 | } else { |
2268 | 2283 | List<Ancestor> ancestors = req.getAncestors(); |
| 2284 | + String closestAncestor = ancestors.isEmpty() ? "unknown" : |
| 2285 | + ancestors.getLast().getObject().getClass().getName(); |
| 2286 | + |
2269 | 2287 | for (Ancestor ancestor : Iterators.reverse(ancestors)) { |
2270 | 2288 | Object type = ancestor.getObject(); |
2271 | 2289 | if (type instanceof Item item) { |
2272 | 2290 | if (!item.hasPermission(Item.CONFIGURE)) { |
| 2291 | + PasswordMasking.recordMasking( |
| 2292 | + item.getClass().getName(), |
| 2293 | + closestAncestor, |
| 2294 | + getJellyViewsInformationForCurrentRequest() |
| 2295 | + ); |
2273 | 2296 | return "********"; |
2274 | 2297 | } |
2275 | 2298 | break; |
2276 | 2299 | } |
2277 | 2300 | if (type instanceof Computer computer) { |
2278 | 2301 | if (!computer.hasPermission(Computer.CONFIGURE)) { |
| 2302 | + PasswordMasking.recordMasking( |
| 2303 | + computer.getClass().getName(), |
| 2304 | + closestAncestor, |
| 2305 | + getJellyViewsInformationForCurrentRequest() |
| 2306 | + ); |
2279 | 2307 | return "********"; |
2280 | 2308 | } |
2281 | 2309 | break; |
2282 | 2310 | } |
2283 | 2311 | if (type instanceof View view) { |
2284 | 2312 | if (!view.hasPermission(View.CONFIGURE)) { |
| 2313 | + PasswordMasking.recordMasking( |
| 2314 | + view.getClass().getName(), |
| 2315 | + closestAncestor, |
| 2316 | + getJellyViewsInformationForCurrentRequest() |
| 2317 | + ); |
2285 | 2318 | return "********"; |
2286 | 2319 | } |
2287 | 2320 | break; |
|
0 commit comments