From db6b358aaa1ac65ba51c2a2e2a0e2f33560cd9d2 Mon Sep 17 00:00:00 2001 From: Mr-Geekman <36005824+Mr-Geekman@users.noreply.github.com> Date: Tue, 8 Aug 2023 08:59:16 +0300 Subject: [PATCH] Add warning about using pickle during loading (#1346) --- CHANGELOG.md | 1 + docs/source/conf.py | 4 ++++ etna/auto/runner/local.py | 4 ++++ etna/core/mixins.py | 6 ++++++ etna/core/utils.py | 6 ++++++ etna/ensembles/mixins.py | 6 ++++++ etna/experimental/classification/base.py | 9 ++++++++- etna/pipeline/mixins.py | 6 ++++++ 8 files changed, 41 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ddacd587..7ebc71f7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Unify errors, warnings and checks in models ([#1312](https://github.com/tinkoff-ai/etna/pull/1312)) - Remove upper limitation on version of numba ([#1321](https://github.com/tinkoff-ai/etna/pull/1321)) - Optimize `TSDataset.describe` and `TSDataset.info` by vectorization ([#1344](https://github.com/tinkoff-ai/etna/pull/1344)) +- Add documentation warning about using dill during loading ([#1346](https://github.com/tinkoff-ai/etna/pull/1346)) ### Fixed - Pipeline ensembles fail in `etna forecast` CLI ([#1331](https://github.com/tinkoff-ai/etna/pull/1331)) diff --git a/docs/source/conf.py b/docs/source/conf.py index a0ade5cd5..e7fc2d5fe 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -80,6 +80,10 @@ autodoc_typehints_description_target = "all" add_module_names = False +autodoc_default_options = { + "inherited-members": True, +} + # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] diff --git a/etna/auto/runner/local.py b/etna/auto/runner/local.py index 8332ce128..1679d8796 100644 --- a/etna/auto/runner/local.py +++ b/etna/auto/runner/local.py @@ -29,6 +29,10 @@ class ParallelLocalRunner(AbstractRunner): Global objects behavior could be different while parallel usage because platform dependent new process start. Be sure that new process is started with ``fork`` via ``multiprocessing.set_start_method``. If it's not possible you should try define all globals before ``if __name__ == "__main__"`` scope. + + Warning + ------- + This class uses :py:mod:`dill` module during serialization which might be not secure. """ def __init__( diff --git a/etna/core/mixins.py b/etna/core/mixins.py index dca2c2064..dc3cd4797 100644 --- a/etna/core/mixins.py +++ b/etna/core/mixins.py @@ -276,6 +276,12 @@ def _load_state(cls, archive: zipfile.ZipFile) -> Self: def load(cls, path: pathlib.Path) -> Self: """Load an object. + Warning + ------- + This method uses :py:mod:`dill` module which is not secure. + It is possible to construct malicious data which will execute arbitrary code during loading. + Never load data that could have come from an untrusted source, or that could have been tampered with. + Parameters ---------- path: diff --git a/etna/core/utils.py b/etna/core/utils.py index 0dc2ee29b..a76ce004c 100644 --- a/etna/core/utils.py +++ b/etna/core/utils.py @@ -13,6 +13,12 @@ def load(path: pathlib.Path, **kwargs: Any) -> Any: """Load saved object by path. + Warning + ------- + This method uses :py:mod:`dill` module which is not secure. + It is possible to construct malicious data which will execute arbitrary code during loading. + Never load data that could have come from an untrusted source, or that could have been tampered with. + Parameters ---------- path: diff --git a/etna/ensembles/mixins.py b/etna/ensembles/mixins.py index 00fb4c9e7..2673c361e 100644 --- a/etna/ensembles/mixins.py +++ b/etna/ensembles/mixins.py @@ -116,6 +116,12 @@ def save(self, path: pathlib.Path): def load(cls, path: pathlib.Path, ts: Optional[TSDataset] = None) -> Self: """Load an object. + Warning + ------- + This method uses :py:mod:`dill` module which is not secure. + It is possible to construct malicious data which will execute arbitrary code during loading. + Never load data that could have come from an untrusted source, or that could have been tampered with. + Parameters ---------- path: diff --git a/etna/experimental/classification/base.py b/etna/experimental/classification/base.py index f613b3937..7762ad658 100644 --- a/etna/experimental/classification/base.py +++ b/etna/experimental/classification/base.py @@ -11,7 +11,14 @@ def dump(self, path: str, *args, **kwargs): @staticmethod def load(path: str, *args, **kwargs): - """Load the object.""" + """Load the object. + + Warning + ------- + This method uses :py:mod:`dill` module which is not secure. + It is possible to construct malicious data which will execute arbitrary code during loading. + Never load data that could have come from an untrusted source, or that could have been tampered with. + """ with open(path, "rb") as file: clf = pickle.load(file, *args, **kwargs) return clf diff --git a/etna/pipeline/mixins.py b/etna/pipeline/mixins.py index b9d33b613..eccba1b66 100644 --- a/etna/pipeline/mixins.py +++ b/etna/pipeline/mixins.py @@ -207,6 +207,12 @@ def save(self, path: pathlib.Path): def load(cls, path: pathlib.Path, ts: Optional[TSDataset] = None) -> Self: """Load an object. + Warning + ------- + This method uses :py:mod:`dill` module which is not secure. + It is possible to construct malicious data which will execute arbitrary code during loading. + Never load data that could have come from an untrusted source, or that could have been tampered with. + Parameters ---------- path: