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.
Trie-like, prefix-tree data structures. First, a prefix-tree based on Arrays, which differs from a traditional trie, which maps strings to values. Second, a more general prefix-tree data structure that works for any type of keys, provided those keys can be transformed to and from an array.
Both of these data structures are implemented in terms of hashes.
Add this line to your application's Gemfile:
gem 'array_trie'
And then execute:
$ bundle
Or install it yourself as:
$ gem install array_trie
Use the base ArrayTrie
class if you want to work with an array-keyed trie.
The more general ArrayTrie::PrefixTrie
class can be used with any sort of
ordered key.
require 'array_trie/prefix_trie'
# You can store any sort of ordered key in a PrefixTrie, provided you can
# convert to and from arrays in a stable way.
path_to_a = -> (path) { path.split('/') }
a_to_path = -> (array) { array.join('/') }
paths = ArrayTrie::PrefixTrie.new(path_to_a, a_to_path)
# Store some keys in the trie
paths['/usr/local/bin/ruby'] = 'executable'
paths['/usr/local/etc/nginx/nginx.cfg'] = 'config file'
paths['/bin/bash'] = 'executable'
# Tries have efficient prefix queries
paths.include_prefix?('/usr/local')
# => true
paths.count_prefix('/usr/local')
# => 2
# You can obtain a subtrie to operate on a subsection of your trie
usr_local = paths.subtrie('/usr/local')
usr_local['bin/ruby']
# => "executable"
usr_local['bin/fish'] = 'executable'
paths['/usr/local/bin/fish']
# => "executable"
# Use #breadth_first and #depth_first to enumarate your keys and values
paths.breadth_first do |k, v|
puts "Path #{k} is of type #{v}"
end
# STDOUT: Path /bin/bash is of type executable
# STDOUT: Path /usr/local/bin/ruby is of type executable
# STDOUT: Path /usr/local/etc/nginx/nginx.cfg is of type config file
# These methods return Enumerators, so you can use them with #map, etc.
enum = paths.depth_first
as_hash = Hash[enum.to_a]
# => {
# ... "/usr/local/bin/ruby"=>"executable",
# ... "/usr/local/etc/nginx/nginx.cfg"=>"config file",
# ... "/bin/bash"=>"executable"
# ... }
After checking out the repo, run bin/setup
to install dependencies. You can also run bin/console
for an interactive prompt that will allow you to experiment. Finally, use bin/test
to run the tests.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/justjake/array_trie.
FAQs
Unknown package
We found that array_trie 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.