Skip to content

Commit fb518ad

Browse files
committed
feat: prevent path traversal attacks
1 parent b739ab5 commit fb518ad

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJAXRSSpecServerCodegen.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import io.swagger.codegen.CodegenParameter;
88
import io.swagger.codegen.CodegenProperty;
99
import io.swagger.codegen.SupportingFile;
10-
import io.swagger.codegen.utils.SecureFileUtils;
1110
import io.swagger.models.Operation;
1211
import io.swagger.models.Swagger;
1312
import io.swagger.models.parameters.Parameter;
@@ -198,11 +197,7 @@ public void preprocessSwagger(Swagger swagger) {
198197
//copy input swagger to output folder
199198
try {
200199
String swaggerJson = Json.pretty(swagger);
201-
SecureFileUtils.validatePath(outputFolder);
202-
File outputFile = new File(outputFolder + File.separator + "swagger.json");
203-
FileUtils.writeStringToFile(outputFile, swaggerJson, StandardCharsets.UTF_8);
204-
} catch (SecurityException e) {
205-
throw new RuntimeException("Security violation: attempted to write to unsafe file path: " + outputFolder + File.separator + "swagger.json", e);
200+
FileUtils.writeStringToFile(new File(outputFolder + File.separator + "swagger.json"), swaggerJson, StandardCharsets.UTF_8);
206201
} catch (IOException e) {
207202
throw new RuntimeException(e.getMessage(), e.getCause());
208203
}

0 commit comments

Comments
 (0)