Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardening suggestions for WebGoat_12_23 / test-algo-de-github-pixeebot #111

Open
wants to merge 3 commits into
base: test-algo-de-github-pixeebot
Choose a base branch
from

Conversation

pixee-b1171e79b0e16eb5[bot]
Copy link

I've reviewed the recently opened PR (110 - Test algo de GitHub pixeebot) and have identified some area(s) that could benefit from additional hardening measures.

These changes should help prevent potential security vulnerabilities and improve overall code quality.

Thank you for your consideration!
🧚🤖 Powered by Pixeebot

Feedback | Community | Docs

public static class EncryptionExample {

public byte[] encrypt(String text) throws Exception {
int a, b, c;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split variable declarations into their own statements.

@@ -126,18 +127,12 @@ public ModelAndView getFiles(HttpServletRequest request) {
return modelAndView;
}

private void print2() {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unused private method.

@@ -79,8 +80,8 @@ public ModelAndView importFile(@RequestParam("file") MultipartFile myFile) throw
var user = (WebGoatUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
var destinationDir = new File(fileLocation, user.getUsername());
destinationDir.mkdirs();
myFile.transferTo(new File(destinationDir, myFile.getOriginalFilename()));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrapped the file name with a sanitizer call that takes out path escaping characters

@@ -79,8 +80,8 @@ public ModelAndView importFile(@RequestParam("file") MultipartFile myFile) throw
var user = (WebGoatUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
var destinationDir = new File(fileLocation, user.getUsername());
destinationDir.mkdirs();
myFile.transferTo(new File(destinationDir, myFile.getOriginalFilename()));
log.debug("File saved to {}", new File(destinationDir, myFile.getOriginalFilename()));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrapped the file name with a sanitizer call that takes out path escaping characters

Copy link

sonarcloud bot commented Jul 4, 2024

@carlosu7
Copy link
Owner

carlosu7 commented Jul 8, 2024

@pixeebot next

@pixee-b1171e79b0e16eb5
Copy link
Author

@carlosu7, I opened PR #113, go check it out!

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.

1 participant