Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@velo
Copy link
Member

@velo velo commented Oct 21, 2024

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

To fix the cross-site scripting vulnerability, we need to sanitize the user input before including it in the response. The best way to do this is to use a library that provides HTML escaping functionality to ensure that any potentially malicious characters in the filename are properly encoded.

We will:

  1. Import the StringEscapeUtils class from the Apache Commons Text library.
  2. Use the escapeHtml4 method to sanitize the filename before appending it to the response.

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

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Comment on lines 171 to +172
return ResponseEntity.status(status)
.body(file.getOriginalFilename() + ':' + file.getContentType());
.body(sanitizedFilename + ':' + file.getContentType());

Check warning

Code scanning / CodeQL

Cross-site scripting

Cross-site scripting vulnerability due to a [user-provided value](1). Cross-site scripting vulnerability due to a [user-provided value](2).

Copilot Autofix

AI over 1 year ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

@velo velo merged commit d99f15a into master Oct 21, 2024
@velo velo deleted the alert-autofix-8 branch October 21, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants