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.
A limited expression evaluator
A little more suited for dynamic usage than ast.literal_eval()
while remaining as safe as the functions you pass in.
Under the hood, it uses the ast
module to parse the expression,
then walks the AST in Python to evaluate the result. You can
also specify a depth limit for the complexity of the expression,
as well as a time limit for the evaluation.
For many use cases, the simple_eval()
function is sufficient.
You can specify a depth limit and a time limit, and optional mappings
of variables and functions.
The values
mapping can also be keyed by a tuple of strings, which
is what attribute accesses are folded to.
Operations are generally limited to numbers only in the simple API.
from leval.simple import simple_eval
assert simple_eval('1 + 2') == 3
assert simple_eval('x < -80 or x > 125 or x == 85', values={'x': 85})
assert simple_eval('abs(x) > 80', values={'x': -85}, functions={'abs': abs})
assert simple_eval('x.y.z + 8', values={('x', 'y', 'z'): 34}) == 42
Under the hood, simple_eval
simply
Both of these classes are designed to be easily subclassable. There are examples
in the test_leval.py
file.
FAQs
Limited evaluator
We found that leval demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.