Skip to content

Commit

Permalink
Fix code scanning alert no. 62: Uncontrolled data used in path expres…
Browse files Browse the repository at this point in the history
…sion

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
lfoppiano and github-advanced-security[bot] authored Nov 30, 2024
1 parent e99d8d4 commit c3008ec
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,11 @@ public void run() {
public Response resultTraining(String token) {
Response response = null;
try {
// Validate the token to prevent directory traversal
if (token.contains("..") || token.contains("/") || token.contains("\\")) {
throw new GrobidServiceException("Invalid token", Status.BAD_REQUEST);
}

// access report file under token subdirectory
File home = GrobidProperties.getInstance().getGrobidHomePath();
String tokenPath = home.getAbsolutePath() + "/training-history/" + token;
Expand Down

0 comments on commit c3008ec

Please sign in to comment.