Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
This package provides a function which can unpack a flat dictionary
into a structured dict
with nested sub-dicts and/or sub-lists.
Development takes place on github. The package is installable from PyPI.
Nested dicts:
>>> from unflatten import unflatten
>>> unflatten({'foo.bar': 'val'})
{'foo': {'bar': 'val'}}
Nested list:
>>> unflatten({'foo[0]': 'x', 'foo[1]': 'y'})
{'foo': ['x', 'y']}
Nested lists and dicts, intermixed:
>>> unflatten({
... 'foo[0][0]': 'a',
... 'foo[0][1]': 'b',
... 'foo[1].x': 'c',
... })
{'foo': [['a', 'b'], {'x': 'c'}]}
Unflatten
takes a single argument which should either be a dict
(or an object with a dict-like .items()
or .iteritems()
method) or a sequence of (key, value)
pairs.
All keys in the dict or sequence must be strings.
(Under python 2, keys must be instances of basestring
; under
python 3, keys just be instances of str
.)
Unflatten
always returns a dict
. By way of example:
>>> unflatten([('[0]', 'x')])
{'': ['x']}
For list-valued nodes, all indexes must be present in the input
(flattened) mapping, otherwise a ValueError
will be thrown:
>>> unflatten({'a[0]': 'x', 'a[2]': 'y'})
Traceback (most recent call last):
...
ValueError: missing key 'a[1]'
The morph and flattery packages purport to implement similar functions.
No substantive code changes from 0.1.1.
Test under python 3.10, 3.11, and 3.12.
Fix tox config to cope with the fact that recent tox/virtualenv does not support EOLed versions of python.
setuptools-scm
to maintain version numberslint
and coverage
environmentsNo code changes.
This package is now deemed "production ready" (though your mileage may vary.)
Initial release.
FAQs
Unflatten dict to dict with nested dict/arrays
We found that unflatten 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
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.