
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Enum field for use with Marshmallow.
pip install --user marshmallow_enum
If you're on a version before 3.4, you'll also need to install enum34
.
To make use of the field, you must have an existing Enum:
from enum import Enum
class StopLight(Enum):
green = 1
yellow = 2
red = 3
Then, declare it as a field in a schema:
from marshmallow import Schema
from marshmallow_enum import EnumField
class TrafficStop(Schema):
light_color = EnumField(StopLight)
By default, the field will load and dump based on the name given to an enum value.
schema = TrafficStop()
schema.dump({'light_color': EnumField.red}).data
# {'light_color': 'red'}
schema.load({'light_color': 'red'}).data
# {'light_color': StopLight.red}
To customize how an enum is serialized or deserialized, there are three options:
by_value=True
. This will cause both dumping and loading to use the value of the enum.load_by=EnumField.VALUE
. This will cause loading to use the value of the enum.dump_by=EnumField.VALUE
. This will cause dumping to use the value of the enum.If either load_by
or dump_by
are unset, they will follow from by_value
.
Additionally, there is EnumField.NAME
to be explicit about the load and dump behavior, this
is the same as leaving both by_value
and either load_by
and/or dump_by
unset.
A custom error message can be provided via the error
keyword argument. It can accept three
format values:
{input}
: The value provided to the schema field{names}
: The names of the individual enum members{values}
: The values of the individual enum membersPreviously, the following inputs were also available but are deprecated and will be removed in 1.6:
{name}
{value}
{choices}
Allow unicode enum values (sergeyzsg) Add support for Marshmallow 3 (svidela)
{choices}
, {name}
and {value}
format keys for custom error messagesFAQs
Enum field for Marshmallow
We found that marshmallow-enum demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.