Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
= easy_diff
Easy Diff enhances the functionality of Hash, allowing recursive diff, merge, and unmerge of arbitrarily constructed hashes. This is perfect for people who need to do diffs on not only plain text files but also data as Hash or JSON objects. Unmerge is included with diff and merge to more easily allow versioning of arbitrary data.
There are a few caveats when using this gem:
== Quick Start Example
old_data = { :id => 1, :name => "Foo", :tags => [ "pretend", "i", "am", "good", "at", "examples" ], :config => { :awesome => true, :go_fast => false, :actually_work => false } }
new_data = { :id => 1, :name => "Bar", :description => "An awesome thingy I made." :tags => [ "i", "am", "really", "good" ] :config => { :awesome => true, :go_fast => true, :actually_work => true } }
removed, added = old_data.easy_diff(new_data)
transformed_old_data = old_data.easy_unmerge(added).easy_merge(removed) transformed_new_data = new_data.easy_unmerge(removed).easy_merge(added)
transformed_old_data.easy_diff(new_data)
transformed_new_data.easy_diff(old_data)
== Install
gem install easy_diff
== Methods
=== Hash#easy_diff
Takes another hash and recursively determines the differences between self and the other hash. This method returns two hashes. The first contains what has to be removed from self to create the second hash. The second contains what has to be added. When diffing arrays, the order of the arrays is ignored and only the contents are compared.
original = { :tags => ['a', 'b', 'c'], :pos => {:x => '1', :y => '2'}, :some_str => "bla", :some_int => 1, :some_bool => false, :extra_removed => "bye" }
modified = { :tags => ['b', 'c', 'd'], :pos => {:x => '3', :y => '2'}, :some_str => "bla", :some_int => 2, :some_bool => true, :extra_added => "hi" }
removed, added = original.easy_diff modified
=== Hash#easy_merge
Takes a hash and recursively merges it with self. Arrays are merged by concatenation.
Using Hash#easy_merge! will modify self instead of returning a new hash.
original = { :tags => ['a', 'b', 'c'], :pos => {:x => '1', :y => '2'}, :some_str => "bla", :some_int => 1, :some_bool => false, :extra_removed => "bye" }
extra = { :tags => ['d'], :pos => {:x => '3'}, :some_int => 2, :some_bool => true, :extra_added => "hi" }
merged = original.easy_merge extra
=== Hash#easy_unmerge
Takes a hash and recursively unmerges it with self. Unmerging means it will remove all matching values from the hash. Arrays will be unmerged by removing matching values in a non-greedy manner (i.e. [1, 1, 1] unmerged with [1] is [1, 1] instead of []).
Using Hash#easy_unmerge! will modify self instead of returning a new hash.
original = { :tags => ['b', 'c', 'd'], :pos => {:x => '3', :y => '2'}, :some_str => "bla", :some_int => 2, :some_bool => true, :extra_added => "hi" }
extra = { :tags => ['d'], :pos => {:x => '3'}, :some_int => 2, :some_bool => true, :extra_added => "hi" }
unmerged = original.easy_unmerge extra
=== Hash#easy_clone
Performs a deep clone on a hash
original = { :tags => ['b', 'c', 'd'], :pos => {:x => '3', :y => '2'} }
new = original.easy_clone
new[:tags] << 'e' new[:pos][:y] = '1'
== Contributing to easy_diff
== Copyright
Copyright (c) 2011 Abner Qian. See LICENSE.txt for further details.
FAQs
Unknown package
We found that easy_diff demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.