forked from loafle/openapi-generator-original
[maven plugin] fix security issues (#8795)
* use Files.createTempFile in maven plugin to avoid security issues * error check when creating a folder
This commit is contained in:
parent
c31e6e79d0
commit
91805936e6
@ -758,7 +758,10 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
|
|
||||||
if (storedInputSpecHashFile.getParent() != null && !new File(storedInputSpecHashFile.getParent()).exists()) {
|
if (storedInputSpecHashFile.getParent() != null && !new File(storedInputSpecHashFile.getParent()).exists()) {
|
||||||
File parent = new File(storedInputSpecHashFile.getParent());
|
File parent = new File(storedInputSpecHashFile.getParent());
|
||||||
parent.mkdirs();
|
if (!parent.mkdirs()) {
|
||||||
|
throw new RuntimeException("Failed to create the folder " + parent.getAbsolutePath() +
|
||||||
|
" to store the checksum of the input spec.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Files.asCharSink(storedInputSpecHashFile, StandardCharsets.UTF_8).write(inputSpecHash);
|
Files.asCharSink(storedInputSpecHashFile, StandardCharsets.UTF_8).write(inputSpecHash);
|
||||||
|
|
||||||
@ -790,7 +793,7 @@ public class CodeGenMojo extends AbstractMojo {
|
|||||||
File inputSpecTempFile = inputSpecFile;
|
File inputSpecTempFile = inputSpecFile;
|
||||||
|
|
||||||
if (inputSpecRemoteUrl != null) {
|
if (inputSpecRemoteUrl != null) {
|
||||||
inputSpecTempFile = File.createTempFile("openapi-spec", ".tmp");
|
inputSpecTempFile = java.nio.file.Files.createTempFile("openapi-spec", ".tmp").toFile();
|
||||||
|
|
||||||
URLConnection conn = inputSpecRemoteUrl.openConnection();
|
URLConnection conn = inputSpecRemoteUrl.openConnection();
|
||||||
if (isNotEmpty(auth)) {
|
if (isNotEmpty(auth)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user