Copilot commented on code in PR #779:
URL: https://github.com/apache/airavata/pull/779#discussion_r4592885241


##########
internal/server/dashboard.go:
##########
@@ -60,6 +67,23 @@ func registerDashboard(mux *http.ServeMux, dir string) {
        mux.HandleFunc("GET /{$}", func(w http.ResponseWriter, r *http.Request) 
{
                http.Redirect(w, r, dashboardPrefix+"/", http.StatusFound)
        })
+       registerLanding(mux, landingDir)
+}
+
+// registerLanding serves dir under landingPrefix, shadowing the landing page 
in the
+// export. A directory without an index.html is ignored, so a mistyped path 
leaves the
+// standard page in place rather than a broken one.
+func registerLanding(mux *http.ServeMux, dir string) {
+       if dir == "" {
+               return
+       }
+       if _, err := os.Stat(path.Join(dir, "index.html")); err != nil {
+               slog.Warn("landing page directory has no index.html; serving 
the standard landing page",
+                       "dir", dir, "variable", "AIRAVATA_LANDING_DIR")
+               return
+       }
+       slog.Info("serving landing page", "path", landingPrefix+"/", "dir", dir)
+       mux.Handle("GET "+landingPrefix+"/", http.StripPrefix(landingPrefix, 
dashboardHandler(os.DirFS(dir))))

Review Comment:
   When `AIRAVATA_LANDING_DIR` points to a Git clone as documented in 
`INSTALL.md:398–399`, unauthenticated requests to 
`/dashboard/landing/.git/config` and `.git/HEAD` are served. This exposes 
repository configuration, potentially including credentials, and can make 
private history retrievable. Reject `.git` path segments before serving the 
landing directory.



-- 
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