github-advanced-security[bot] commented on code in PR #14684:
URL: https://github.com/apache/grails-core/pull/14684#discussion_r2069707410


##########
grails-wrapper/src/main/java/grails/init/Start.java:
##########
@@ -0,0 +1,125 @@
+package grails.init;
+
+import grails.proxy.SystemPropertiesAuthenticator;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.net.Authenticator;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.file.Files;
+
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+
+//TODO: snapshot locations need supported
+public class Start {
+
+    private static final String PROJECT_NAME = "grails-wrapper-impl";
+    private static final String WRAPPER_PATH = "/org/apache/grails/" + 
PROJECT_NAME;
+    private static final String GRAILS_RELEASE_MAVEN_REPO_BASE_URL = 
"https://repo1.maven.org/maven2/";;
+    private static final File WRAPPER_DIR = new 
File(System.getProperty("user.home") + "/.grails/wrapper");
+    private static final File NO_VERSION_JAR = new File(WRAPPER_DIR, 
PROJECT_NAME + ".jar");
+
+    private static String getMavenBaseUrl() {
+        String baseUrl = System.getProperty("grails.maven.repo.baseUrl");
+        if (baseUrl != null) {
+            return baseUrl;
+        }
+        baseUrl = System.getenv("GRAILS_RELEASE_MAVEN_REPO_BASE_URL");
+        if (baseUrl != null) {
+            return baseUrl;
+        }
+        return GRAILS_RELEASE_MAVEN_REPO_BASE_URL;
+    }
+
+    private static String getVersion() {
+        try {
+            SAXParserFactory factory = SAXParserFactory.newInstance();
+            SAXParser saxParser = factory.newSAXParser();
+            FindReleaseHandler findReleaseHandler = new FindReleaseHandler();
+            final String mavenMetadataFileUrl = getMavenBaseUrl() + 
WRAPPER_PATH + "/maven-metadata.xml";
+            HttpURLConnection conn = 
createHttpURLConnection(mavenMetadataFileUrl);
+            saxParser.parse(conn.getInputStream(), findReleaseHandler);

Review Comment:
   ## Resolving XML external entity in user-controlled data
   
   XML parsing depends on a [user-provided value](1) without guarding against 
external entity expansion.
   
   [Show more 
details](https://github.com/apache/grails-core/security/code-scanning/20)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to