Skip to content

chore(QTDI-1086) Improve path manipulation detection #976

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
System.out.println(type + " deployed successfully.");
}

private static Properties installJars(final File m2Root, final boolean forceOverwrite) {

Check failure on line 300 in component-tools/src/main/java/org/talend/sdk/component/tools/exec/CarMain.java

View check run for this annotation

sonar-eks / Component Runtime Sonarqube Results

component-tools/src/main/java/org/talend/sdk/component/tools/exec/CarMain.java#L300

Refactor this method to reduce its Cognitive Complexity from 16 to the 15 allowed.
String mainGav = null;
final Properties properties = new Properties();
try (final JarInputStream jar =
Expand All @@ -310,7 +310,7 @@
if (entry.getName().startsWith("MAVEN-INF/repository/")) {
final String path = entry.getName().substring("MAVEN-INF/repository/".length());
final File output = new File(m2Root, path);
if (!output.getCanonicalPath().startsWith(m2Root.getCanonicalPath())) {
if (!output.getCanonicalPath().startsWith(m2Root.getCanonicalPath() + File.separator)) {
throw new IOException("The output file is not contained in the destination directory");
}
if (!output.exists() || forceOverwrite) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private static void unzip(final InputStream read, final File destination, final
path = path.replaceFirst("^[^/]+/", "");
}
final File file = new File(destination, path);
if (!file.getCanonicalPath().startsWith(destination.getCanonicalPath())) {
if (!file.getCanonicalPath().startsWith(destination.getCanonicalPath() + File.separator)) {
throw new IOException("The output file is not contained in the destination directory");
}

Expand Down
Loading