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.
... which tools?
Let us speculate about that:
All the goodies of OpenStruct
without the badies:
fetch
, merge
, slice
...)Given an instance of MyStruct
constructed from a Hash
require 'ex_aequo/my_struct'
let(:from_hash) { MyStruct.new(a: 1, b: 2) }
And an instance constructed by a reducer
let(:incremented) { MyStruct.from_reduce(%i[a b c d e], 0) { _1.succ } }
Then they can be accessed like a Hash
or OpenStruct
expect(from_hash[:a]).to eq(1)
expect(from_hash.fetch(:b)).to eq(2)
expect(incremented[:e]).to eq(5)
And they are immutable
expect { from_hash[:c] = 3 }
.to raise_error(MyStruct::ImmutableError, 'cannot change values with []= in immutable instance of MyStruct')
And mutable operations just create new objects
expect(from_hash.merge(c: 3)).to eq(MyStruct.new(a: 1, b: 2, c: 3))
expect(from_hash.to_h).to eq(a: 1, b: 2)
And the hashy methods observer the same interface
expect { from_hash.fetch(:c) }
.to raise_error(KeyError, 'key :c not found in #<MyStruct a=1, b=2> and no default given to #fetch')
expect(from_hash.fetch(:c, 42)).to eq(42)
expect(from_hash.fetch(:c) { 43 }).to eq(43)
expect(incremented.slice(:a, :c, :e)).to eq(MyStruct.new(a: 1, c: 3, e: 5))
An expressive, yet simple argument parser that takes full advantage of Ruby 3 and returns a modern Args struct (with modern I mean MyStruct) as a result.
Given a simple example like this on
let(:simple_parser) do
ExAequo::ArgsParser.new(
allowed: %w[alpha: beta: :help :verbose],
aliases: {h: :help, v: :verbose, a: :alpha}
)
end
Then, as northing is required we can successfully parse empty arguments
result = simple_parser.parse([])
expect(result).to be_ok
expect(result.missing).to be_empty
expect(result.superflous).to be_empty
expect(result.positionals).to be_empty
expect(result.keywords).to eq(MyStruct.new)
And, we can also provide allowed values (N.B. ruby sytnax is default)
result = simple_parser.parse(%w[alpha: 42 43])
expect(result).to be_ok
expect(result.missing).to be_empty
expect(result.superflous).to be_empty
expect(result.positionals).to eq(%w[43])
expect(result.keywords).to eq(MyStruct.new(alpha: '42'))
Copyright 202[2,3] Robert Dober robert.dober@gmail.com
Apache-2.0 c.f LICENSE
FAQs
Unknown package
We found that ex_aequo 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.