mlrun 1.10.0rc20__py3-none-any.whl → 1.10.0rc21__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mlrun might be problematic. Click here for more details.

mlrun/run.py CHANGED
@@ -141,7 +141,7 @@ def load_func_code(command="", workdir=None, secrets=None, name="name"):
141
141
  else:
142
142
  is_remote = "://" in command
143
143
  data = get_object(command, secrets)
144
- runtime = yaml.load(data, Loader=yaml.FullLoader)
144
+ runtime = yaml.safe_load(data)
145
145
  runtime = new_function(runtime=runtime)
146
146
 
147
147
  command = runtime.spec.command or ""
@@ -362,7 +362,10 @@ def import_function(url="", secrets=None, db="", project=None, new_name=None):
362
362
  return function
363
363
 
364
364
 
365
- def import_function_to_dict(url, secrets=None):
365
+ def import_function_to_dict(
366
+ url: str,
367
+ secrets: Optional[dict] = None,
368
+ ) -> dict:
366
369
  """Load function spec from local/remote YAML file"""
367
370
  obj = get_object(url, secrets)
368
371
  runtime = yaml.safe_load(obj)
@@ -388,6 +391,11 @@ def import_function_to_dict(url, secrets=None):
388
391
  raise ValueError("exec path (spec.command) must be relative")
389
392
  url = url[: url.rfind("/") + 1] + code_file
390
393
  code = get_object(url, secrets)
394
+ code_file = _ensure_path_confined_to_base_dir(
395
+ base_directory=".",
396
+ relative_path=code_file,
397
+ error_message_on_escape="Path traversal detected in spec.command",
398
+ )
391
399
  dir = path.dirname(code_file)
392
400
  if dir:
393
401
  makedirs(dir, exist_ok=True)
@@ -395,9 +403,16 @@ def import_function_to_dict(url, secrets=None):
395
403
  fp.write(code)
396
404
  elif cmd:
397
405
  if not path.isfile(code_file):
398
- # look for the file in a relative path to the yaml
399
- slash = url.rfind("/")
400
- if slash >= 0 and path.isfile(url[: url.rfind("/") + 1] + code_file):
406
+ slash_index = url.rfind("/")
407
+ if slash_index < 0:
408
+ raise ValueError(f"no file in exec path (spec.command={code_file})")
409
+ base_dir = os.path.normpath(url[: slash_index + 1])
410
+ candidate_path = _ensure_path_confined_to_base_dir(
411
+ base_directory=base_dir,
412
+ relative_path=code_file,
413
+ error_message_on_escape=f"exec file spec.command={code_file} is outside of allowed directory",
414
+ )
415
+ if path.isfile(candidate_path):
401
416
  raise ValueError(
402
417
  f"exec file spec.command={code_file} is relative, change working dir"
403
418
  )
@@ -1258,3 +1273,21 @@ def wait_for_runs_completion(
1258
1273
  runs = running
1259
1274
 
1260
1275
  return completed
1276
+
1277
+
1278
+ def _ensure_path_confined_to_base_dir(
1279
+ base_directory: str,
1280
+ relative_path: str,
1281
+ error_message_on_escape: str,
1282
+ ) -> str:
1283
+ """
1284
+ Join `user_supplied_relative_path` to `allowed_base_directory`, normalise the result,
1285
+ and guarantee it stays inside `allowed_base_directory`.
1286
+ """
1287
+ absolute_base_directory = path.abspath(base_directory)
1288
+ absolute_candidate_path = path.abspath(
1289
+ path.join(absolute_base_directory, relative_path)
1290
+ )
1291
+ if not absolute_candidate_path.startswith(absolute_base_directory + path.sep):
1292
+ raise ValueError(error_message_on_escape)
1293
+ return absolute_candidate_path
@@ -1,4 +1,4 @@
1
1
  {
2
- "git_commit": "bf47f85a95ed8a3d2d4143cb931b2f0b16b5cdbd",
3
- "version": "1.10.0-rc20"
2
+ "git_commit": "af3bd0907729d21274b7bb80cfbf8671016fb875",
3
+ "version": "1.10.0-rc21"
4
4
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mlrun
3
- Version: 1.10.0rc20
3
+ Version: 1.10.0rc21
4
4
  Summary: Tracking and config of machine learning runs
5
5
  Home-page: https://github.com/mlrun/mlrun
6
6
  Author: Yaron Haviv
@@ -21,7 +21,8 @@ Classifier: Topic :: Software Development :: Libraries
21
21
  Requires-Python: >=3.9, <3.12
22
22
  Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
- Requires-Dist: urllib3<1.27,>=1.26.9
24
+ Requires-Dist: urllib3>=1.26.20; python_version < "3.11"
25
+ Requires-Dist: urllib3>=2.5.0; python_version >= "3.11"
25
26
  Requires-Dist: GitPython>=3.1.41,~=3.1
26
27
  Requires-Dist: aiohttp~=3.11
27
28
  Requires-Dist: aiohttp-retry~=2.9
@@ -8,7 +8,7 @@ mlrun/k8s_utils.py,sha256=mMnGyouHoJC93ZD2KGf9neJM1pD7mR9IXLnHOEwYVTQ,21469
8
8
  mlrun/lists.py,sha256=OlaV2QIFUzmenad9kxNJ3k4whlDyxI3zFbGwr6vpC5Y,8561
9
9
  mlrun/model.py,sha256=wHtM8LylSOEFk6Hxl95CVm8DOPhofjsANYdIvKHH6dw,88956
10
10
  mlrun/render.py,sha256=5DlhD6JtzHgmj5RVlpaYiHGhX84Q7qdi4RCEUj2UMgw,13195
11
- mlrun/run.py,sha256=UqNL4qA8CZFEu9lrP5xVl_tfYn6_wiN7x0VVQYWH5_c,46932
11
+ mlrun/run.py,sha256=WwcAkbmfnT0Qslxte4xchl-B_UN5YkJIz6_gDGT9_mo,48208
12
12
  mlrun/secrets.py,sha256=dZPdkc_zzfscVQepOHUwmzFqnBavDCBXV9DQoH_eIYM,7800
13
13
  mlrun/alerts/__init__.py,sha256=0gtG1BG0DXxFrXegIkjbM1XEN4sP9ODo0ucXrNld1hU,601
14
14
  mlrun/alerts/alert.py,sha256=QQFZGydQbx9RvAaSiaH-ALQZVcDKQX5lgizqj_rXW2k,15948
@@ -347,11 +347,11 @@ mlrun/utils/notifications/notification/mail.py,sha256=ZyJ3eqd8simxffQmXzqd3bgbAq
347
347
  mlrun/utils/notifications/notification/slack.py,sha256=kfhogR5keR7Zjh0VCjJNK3NR5_yXT7Cv-x9GdOUW4Z8,7294
348
348
  mlrun/utils/notifications/notification/webhook.py,sha256=zxh8CAlbPnTazsk6r05X5TKwqUZVOH5KBU2fJbzQlG4,5330
349
349
  mlrun/utils/version/__init__.py,sha256=YnzE6tlf24uOQ8y7Z7l96QLAI6-QEii7-77g8ynmzy0,613
350
- mlrun/utils/version/version.json,sha256=jGLPW_bDwSwnMZQIJaVf33n7OzZJsZWP52SMz71BFMU,90
350
+ mlrun/utils/version/version.json,sha256=H7d1ELzXp0aH2jO3jaUw6eXsjA2R2GNc7FzvPs7pEqE,90
351
351
  mlrun/utils/version/version.py,sha256=M2hVhRrgkN3SxacZHs3ZqaOsqAA7B6a22ne324IQ1HE,1877
352
- mlrun-1.10.0rc20.dist-info/licenses/LICENSE,sha256=zTiv1CxWNkOk1q8eJS1G_8oD4gWpWLwWxj_Agcsi8Os,11337
353
- mlrun-1.10.0rc20.dist-info/METADATA,sha256=w7awwnxAikehkD4Xg0MRsNM20NqAynzmZm6XnnYPj00,26196
354
- mlrun-1.10.0rc20.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
355
- mlrun-1.10.0rc20.dist-info/entry_points.txt,sha256=1Owd16eAclD5pfRCoJpYC2ZJSyGNTtUr0nCELMioMmU,46
356
- mlrun-1.10.0rc20.dist-info/top_level.txt,sha256=NObLzw3maSF9wVrgSeYBv-fgnHkAJ1kEkh12DLdd5KM,6
357
- mlrun-1.10.0rc20.dist-info/RECORD,,
352
+ mlrun-1.10.0rc21.dist-info/licenses/LICENSE,sha256=zTiv1CxWNkOk1q8eJS1G_8oD4gWpWLwWxj_Agcsi8Os,11337
353
+ mlrun-1.10.0rc21.dist-info/METADATA,sha256=OLYNzVbE0RffYFwXIORP4OpDCJKQaDZbvFlhli3-Qs0,26272
354
+ mlrun-1.10.0rc21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
355
+ mlrun-1.10.0rc21.dist-info/entry_points.txt,sha256=1Owd16eAclD5pfRCoJpYC2ZJSyGNTtUr0nCELMioMmU,46
356
+ mlrun-1.10.0rc21.dist-info/top_level.txt,sha256=NObLzw3maSF9wVrgSeYBv-fgnHkAJ1kEkh12DLdd5KM,6
357
+ mlrun-1.10.0rc21.dist-info/RECORD,,