-
Notifications
You must be signed in to change notification settings - Fork 1
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
Adding code with some deep sinks #1
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.owasp.webgoat.lessons.vulnerablecomponents; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import org.hsqldb.lib.FileUtil; | ||
import org.jsoup.helper.DataUtil; | ||
import org.springframework.util.FileSystemUtils; | ||
import org.springframework.util.StringUtils; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class DSAST { | ||
@PostMapping("/DAST/Spring/delete") | ||
public void springDelete(@RequestParam String input) { | ||
|
||
String directory = "./target/directory"; | ||
String[] filenames = StringUtils.commaDelimitedListToStringArray(input); | ||
for (String filename : filenames) { | ||
var file = new File(directory, filename); | ||
FileSystemUtils.deleteRecursively(file); | ||
Check warning Code scanning / SonarCloudsquad-2 Accessing files should not lead to filesystem oracle attacks Medium
Change this code to not construct the path from user-controlled data. See more on SonarCloud
|
||
} | ||
} | ||
|
||
@PostMapping("/DAST/hsqldb/delete") | ||
public void hsqldbDelete(@RequestParam String filename) { | ||
|
||
String directory = "./target/directory"; | ||
var file = new File(directory, filename); | ||
FileUtil.getFileUtil().delete(filename); | ||
Check failure Code scanning / SonarCloudsquad-2 I/O function calls should not be vulnerable to path injection attacks High
Change this code to not construct the path from user-controlled data. See more on SonarCloud
|
||
} | ||
|
||
public void jsoupLoad(@RequestParam String filename) throws IOException { | ||
|
||
String directory = "./target/directory"; | ||
var file = new File(directory, filename); | ||
DataUtil.load(file, "utf-8", "uri://"); | ||
Check failure Code scanning / SonarCloudsquad-2 I/O function calls should not be vulnerable to path injection attacks High
Change this code to not construct the path from user-controlled data. See more on SonarCloud
|
||
} | ||
} |
Check failure
Code scanning / SonarCloudsquad-2
I/O function calls should not be vulnerable to path injection attacks High