Repository navigation
Decode stored parameter sets without importing modules named by files - #408
Merged
Merged
Conversation
… named by files (#407) Parameters stored with objects, analysis results, creation metadata and History actions were decoded with guidata's permissive json_to_dataset, which imports the module named in the file and calls the object it names. A modified workspace could thus make DataLab import any installed module and call any zero-argument callable when an object was selected. decode_dataset_json only builds guidata DataSet subclasses from modules already loaded (DataLab, Sigima, guidata, installed plugins) or from public modules of DataLab's own packages; nothing else is imported or called. Fields are still read tolerantly, so parameters saved by earlier versions stay readable. Assisted-by: Claude Opus 5.5
Crafted payloads are refused at every call site without importing or calling anything, legitimate and plugin parameters are decoded as before, and a guard fails if json_to_dataset is used again in the datalab package. Assisted-by: Claude Opus 5.5
English entry and its French translation; only this entry is added to the French catalogue. Assisted-by: Claude Opus 5.5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #407.
Problem
DataLab decoded the parameter sets stored in workspaces with guidata's permissive
json_to_dataset. This concerns object processing parameters, analysis-result parameters, creation parameters and History arguments. That decoder imports the module named by the storedclass_moduleand calls the object named byclass_name, so a modified workspace could make DataLab import any installed module and call any zero-argument callable, for example to make it quit. Selecting an object of such a workspace was enough.Fix
datalab.utils.datasetjson.decode_dataset_json, used by the 9 former call sites:ProcessingParameters.set_param_from_jsonBaseResultAdapter.get_paramextract_creation_parametersandconvert_legacy_creation_parametersdecode_kwargsandcopy_history_valueDataSetsubclass, defined either in a module already loaded by DataLab (DataLab, Sigima, guidata, installed plugins) or in a public module ofdatalab,guidata,sigimaorsigimax, which is then imported.__main__) and test modules are never imported for a file. Nothing else is imported or called.ParameterClassError(aValueError), so every caller reports it as it already reported unreadable parameters.BaseResultAdapter.get_paramnow warns and returnsNoneinstead of raising, so the Properties panel still shows the object.json_to_dataset(strict=True)) would not guarantee when parameter classes evolve.Behaviour change
The parameters of a plugin that is not loaded (removed or disabled) are now reported as unreadable instead of importing the plugin module.
Tests
New
datalab/tests/features/common/stored_parameters_unit_test.py(24 tests):json_to_datasetis used again anywhere in thedatalabpackage outside tests.Regression:
datalab/tests/features/commonanddatalab/tests/features/hdf5. Ruff format and check, Pylint 10/10 on the changed modules (no new message inprocessor/base.py).Translations and documentation
load_from_files/load_from_directoryintermittently ignored #398 is left to its own change.Out of scope
NativeH5Readercallable references: they are restricted to packages nameddatalab*, and are returned, not called.Follow-up once merged: DataLab-Capsule
doc/security.mdlists this as a residual risk of DataLab Desktop and can then state that it is fixed in DataLab 1.4.0.