-
Notifications
You must be signed in to change notification settings - Fork 0
Sandboxed URL creation to prevent SSRF attacks #6
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
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 |
---|---|---|
|
@@ -54,6 +54,7 @@ | |
<sonar.projectKey>iluwatar_java-design-patterns</sonar.projectKey> | ||
<sonar.moduleKey>${project.artifactId}</sonar.moduleKey> | ||
<sonar.projectName>Java Design Patterns</sonar.projectName> | ||
<versions.java-security-toolkit>1.1.3</versions.java-security-toolkit> | ||
</properties> | ||
<modules> | ||
<module>abstract-factory</module> | ||
|
@@ -248,6 +249,11 @@ | |
<version>${system-lambda.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.github.pixee</groupId> | ||
<artifactId>java-security-toolkit</artifactId> | ||
<version>${versions.java-security-toolkit}</version> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
<dependencies> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code Review:
Summary:The code patch introduces a new dependency on |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,10 @@ | |
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This library holds security tools for protecting Java API calls. License: MIT ✅ | Open source ✅ | More facts |
||
<groupId>io.github.pixee</groupId> | ||
<artifactId>java-security-toolkit</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the provided code patch, here is a brief code review:
Consider the context of your project and determine the appropriate version and scope for the |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ | |
*/ | ||
package com.iluwatar.promise; | ||
|
||
import io.github.pixee.security.HostValidator; | ||
import io.github.pixee.security.Urls; | ||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.FileReader; | ||
|
@@ -98,7 +100,7 @@ public static Integer countLines(String fileLocation) { | |
*/ | ||
public static String downloadFile(String urlString) throws IOException { | ||
LOGGER.info("Downloading contents from url: {}", urlString); | ||
var url = new URL(urlString); | ||
var url = Urls.create(urlString, Urls.HTTP_PROTOCOLS, HostValidator.DENY_COMMON_INFRASTRUCTURE_TARGETS); | ||
var file = File.createTempFile("promise_pattern", null); | ||
try (var bufferedReader = new BufferedReader(new InputStreamReader(url.openStream())); | ||
var writer = new FileWriter(file)) { | ||
Comment on lines
101
to
106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Recommended Solution: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code Review Summary:Bug Risks:
Improvements:
Detailed Analysis:
By addressing these points, you can enhance the overall quality and maintainability of the codebase. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This library holds security tools for protecting Java API calls.
License: MIT ✅ | Open source ✅ | More facts