This product is not supported for your selected Datadog site. ().
Cette page n'est pas encore disponible en français, sa traduction est en cours. Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
@RequestMapping("/redirect")publicvoidredirect(@RequestParam()Stringurl,Stringa)throwsMalformedURLException{URLnewUrl=newURL(url);// Bad: User-controlled input used directlyURLnewUrl=newURL(url+"/path");}@RequestMapping("/api")publicvoidapiEndpoint(@RequestParamStringhost){Stringurl1="http://"+host+"/api/resource";// Bad: User input concatenated into URLStringurl2="http://".concat(host);Stringurl3="https://";url3+=host;Stringurl4=String.format("https://%v",host);Stringurl5="https://%v";Stringurl6=String.format(url5,host)}@RequestMapping("/fetch")publicvoidfetchData(@RequestParamStringendpoint){StringBuildersb=newStringBuilder("https://example.com");sb.append(endpoint);// Bad: User input appended to base URL}
Compliant Code Examples
@RequestMapping("/safe-redirect")publicvoidsafeRedirect(@RequestParamStringpath)throwsMalformedURLException{StringbaseUrl="https://safe.example.com";URLnewUrl=newURL(baseUrl+URLEncoder.encode(path,"UTF-8"));// Good: User input only affects the path, not the host}
1
2
rulesets:- java-security # Rules to enforce Java security.