Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Sweetener is a Python library for quickly prototyping compilers and interpreters. Extra care has been taken to make the algorithms as flexible as possible to fit as many use cases. If you're still missing something, do not hesitate to file an issue! In particular, this library contains the following goodies:
clone
, equal
and lte
that work on most
types in the standard library and you can specialize for your own types.Here's an example of using the Record
type to define a record that holds two
fields and visualizes tham using GraphViz:
from sweetener import Record, equal, visualize
class MySimpleRecord(Record):
field_1: int
field_2: str
r1 = MySimpleRecord('foo', 42)
r2 = MySimpleRecod(field_1='foo', field_2=42)
assert(equal(r1, r2))
visualize(r1)
Running this program will open a new window with the following content:
from sweetener import BaseNode, visualize
class CalcNode(BaseNode):
pass
class Expr(CalcNode):
pass
class Add(Expr):
left: Expr
right: Expr
class Sub(Expr):
left: Expr
right: Expr
class Var(Expr):
name: str
class Lit(Expr):
value: int
def eval(node: Expr, vars = {}) -> int:
if isinstance(node, Add):
return eval(node.left, vars) + eval(node.right, vars)
if isinstance(node, Sub):
return eval(node.left, vars) - eval(node.right, vars)
if isinstance(node, Lit):
return node.value
if isinstance(node, Var):
return vars[node.name]
raise RuntimeError('Could not evaluate a node: unrecognised node type')
prog = Sub(
Add(
Lit(1),
Lit(2)
),
Var('x')
)
visualize(prog, format='png')
assert(eval(prog, { 'x': 3 }) == 0)
Running this example will open a new window with the following content:
Sweetener is generously licensed under the MIT license, in the hope that it inspires people to build new and cool software.
FAQs
A base library for writing compilers and interpreters
We found that sweetener 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.