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.
Sirop is a Ruby gem for manipulating Ruby source code. Sirop is very young, so the following information might be incomplete, out of date, or simply wrong!
Some of the use cases addressed by Sirop are:
eval
'd Ruby code, or in an IRB/Pry session.To get the AST of a proc or a method, use Sirop.to_ast
:
# for a proc
mul = ->(x, y) { x * y }
Sirop.to_ast(mul) #=> ...
# for a method
def foo; :bar; end
Sirop.to_ast(method(:foo)) #=> ...
To get the source of a proc or a method, use Sirop.to_source
:
mul = ->(x, y) { x * y }
Sirop.to_source(mul) #=> "->(x, y) { x * y }"
def foo; :bar; end
Sirop.to_source(method(:foo)) #=> "def foo; :bar; end"
You can consult the DSL compiler
example. This example intercepts method calls by defining a visit_call_node
method:
# Annotated with some explanations
def visit_call_node(node)
# don't rewrite if the call has a receiver
return super if node.receiver
# set HTML location start
@html_location_start ||= node.location
# get method arguments...
inner_text, attrs = tag_args(node)
# and block
block = node.block
# emit HTML tag according to given arguments
if inner_text
emit_tag_open(node, attrs)
emit_tag_inner_text(inner_text)
emit_tag_close(node)
elsif block
emit_tag_open(node, attrs)
visit(block.body)
emit_tag_close(node)
else
emit_tag_open_close(node, attrs)
end
# set HTML location end
@html_location_end = node.location
end
Implement a macro expander with support for quote
/unquote
:
trace_macro = Sirop.macro do |ast|
source = Sirop.to_source(ast)
quote do
result = unquote(ast)
puts "The result of #{source} is: #{result}"
result
end
end
def add(x, y)
trace(x + y)
end
Sirop.expand_macros(method(:add), trace: trace_macro)
Implement a DSL compiler with hooks for easier usage in DSL libraries.
We gladly welcome contributions from anyone! Some areas that need work currently are:
Please feel free to contribute PR's and issues
FAQs
Unknown package
We found that sirop 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.