-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add options to restrict deserializers in ComputeSerializer
Also move some errors to SerdeErrors instead of SerializationError / DeserializationError, if those errors happen before anything is actually serialized or deserialized; and make the ComputeSerializer enforce that selectable serialization strategies are properly for_code or not.
- Loading branch information
1 parent
a3505a0
commit 389c33b
Showing
4 changed files
with
287 additions
and
19 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
changelog.d/20250113_150119_chris_restrict_serializers.rst
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
New Functionality | ||
^^^^^^^^^^^^^^^^^ | ||
|
||
- The ``ComputeSerializer`` can now be told to only deserialize payloads that were | ||
serialized with specific serialization strategies. For example: | ||
|
||
.. code-block:: python | ||
import os | ||
from globus_compute_sdk.serialize import ComputeSerializer, JSONData | ||
class MaliciousPayload(): | ||
def __reduce__(self): | ||
# this method returns a 2-tuple (callable, arguments) that dill calls to reconstruct the object | ||
return os.system, ("<your favorite arbitrary code execution script>",) | ||
evil_serializer = ComputeSerializer() # uses DillDataBase64 by default | ||
payload = evil_serializer.serialize(MaliciousPayload()) | ||
safe_deserializer = ComputeSerializer( | ||
allowed_data_deserializer_types=[JSONData] | ||
) | ||
safe_deserializer.deserialize(payload) | ||
# globus_compute_sdk.errors.error_types.DeserializationError: Deserialization failed: | ||
# | ||
# Data serializer DillDataBase64 is not allowed in this ComputeSerializer. | ||
# The only allowed data serializer is JSONData. | ||
# | ||
# (Hint: reserialize the arguments with JSONData and try again.) |
This file contains 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
This file contains 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
This file contains 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