diff --git a/backend/windmill-api/src/scripts.rs b/backend/windmill-api/src/scripts.rs index 65c8612dd9..35ebee7d57 100644 --- a/backend/windmill-api/src/scripts.rs +++ b/backend/windmill-api/src/scripts.rs @@ -600,7 +600,22 @@ async fn raw_script_by_path( Extension(user_db): Extension, Path((w_id, path)): Path<(String, StripPath)>, ) -> Result { - let path = path.to_path().split(".").next().unwrap_or_default(); + let path = path.to_path(); + if !path.ends_with(".py") + && !path.ends_with(".ts") + && !path.ends_with(".go") + && !path.ends_with(".sh") + { + return Err(Error::BadRequest(format!( + "Path must ends with a .py, .ts, .go. or .sh extension: {}", + path + ))); + } + let path = path + .trim_end_matches(".py") + .trim_end_matches(".ts") + .trim_end_matches(".go") + .trim_end_matches(".sh"); let mut tx = user_db.begin(&authed).await?; let content_o = sqlx::query_scalar!( diff --git a/backend/windmill-worker/loader.py b/backend/windmill-worker/loader.py index dda3776b98..a09de68770 100644 --- a/backend/windmill-worker/loader.py +++ b/backend/windmill-worker/loader.py @@ -30,7 +30,7 @@ class WindmillFinder(MetaPathFinder): script_path = "/".join(splitted) import requests - url = f"{os.environ.get('BASE_INTERNAL_URL')}/api/w/{os.environ.get('WM_WORKSPACE')}/scripts/raw/p/{script_path}" + url = f"{os.environ.get('BASE_INTERNAL_URL')}/api/w/{os.environ.get('WM_WORKSPACE')}/scripts/raw/p/{script_path}.py" r = requests.get( url, headers={"Authorization": f"Bearer {os.environ.get('WM_TOKEN')}"}