
Security News
Opengrep Adds Apex Support and New Rule Controls in Latest Updates
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Convert unsanitized user input into SymPy expression.
This does not prevent all possible attacks. However, this is much safer than using eval()
, which SymPy still does.
See SymPy PR12524 for more details: https://github.com/sympy/sympy/pull/12524
Create a SymPy expression from user input.
This uses pure Python syntax.
Whitelisted operators and functions only are allowed.
>>> expr = SaferSympify().str2sympy('-sqrt(1 + a**b*b)/((a**b)*b+1)')
>>> expr
-1/sqrt(a**b*b + 1)
Get free symbols:
>>> sorted(expr.free_symbols, key=lambda x: str(x))
[a, b]
Evaluate expression:
>>> expr.evalf(subs={'a': 1, 'b': 3, 'c': 5}) # Note extra values can be passed too
-0.500000000000000
Simplify expression:
>>> expr.simplify()
-1/sqrt(a**b*b + 1)
Pretty-print expression as Latex (could be displayed in browser with MathJax)
>>> sympy.latex(expr)
'- \\frac{1}{\\sqrt{a^{b} b + 1}}'
FAQs
Safer way to sympify unsanitized input
We found that safersympify 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.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.