OpenFeign / feign

Feign makes writing java http clients easier
Apache License 2.0
9.51k stars 1.93k forks source link

Fix code scanning alert no. 13: Cross-site scripting #2610

Closed velo closed 1 month ago

velo commented 1 month ago

Fixes https://github.com/OpenFeign/feign/security/code-scanning/13

To fix the cross-site scripting vulnerability, we need to ensure that any user-provided data included in the HTTP response is properly sanitized or encoded. In this case, we can use a library like Apache Commons Text to escape the content of the files before including them in the response. This will prevent any malicious scripts from being executed in the user's browser.

  1. Add the Apache Commons Text library to the project dependencies if it is not already included.
  2. Import the necessary classes from the Apache Commons Text library.
  3. Escape the content of the files using StringEscapeUtils.escapeHtml4 before including them in the result variable.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.