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.
It's like a trie but with holes that get filled in when you look up a result. So, given the map
we get the trie
and those red parameters get filled in when we look up:
const ParamTrie = require('param-trie');
const {param, branch} = ParamTrie;
var t = ParamTrie.ofPath([
branch('a'),
branch('b'),
param('c')
], 'foo');
t.lookup(['a', 'b', 'x']); //⇒ [{value: 'foo', params: {c: 'x'}}]
var t2 = t.insertPath([
branch('a'),
param('d'),
branch('e')
], 'bar');
t2.lookup(['a', 'x', 'e']); //⇒ [{value: 'bar', params: {d: 'x'}}]
ParamTrie
ParamTrie
constructornew ParamTrie(values, {param, branch})
Takes single value or an array of values and an object listing the trie's children. The object should have keys param
and branch
, each being an object listing children of that type, with keys as names of params or text of branches and values as the ParamTrie
child.
empty
and of
ParamTrie.empty()
Returns a trie with no values and no children.
ParamTrie.of(value)
Returns a trie with a single value or array of values and no children.
ofPath
ParamTrie.ofPath(path, value)
Creates a nested trie with the heirarchy as given by path
. ParamTrie.ofPath([], x)
is equivalent to ParamTrie.of(x)
.
fromMap
ParamTrie.fromMap(map)
Given a Map
of paths to values, build an entire trie with the correct heirarchy.
trie.merge(other)
Combines two tries immutably; returns a new trie and leaves the originals unmodified. When paths collide, they're merged recursively. Values at the same path are concatenated.
trie.insertPath(path, value)
Special case of merge for a single path. Equivalent to trie.merge(ParamTrie.ofPath(path, value))
.
trie.lookup(path)
Returns all of the matches of a particular path. Since multiple parameterised paths can match a given lookup path and a trie can have multiple values, lookup
returns an array of results.
The values of the returned array are objects with keys value
and params
. value
is the value at the resolved point in the tree. params
is an object containing concrete values of params found in the heirarchy, filled in from the lookup path. If the lookup resolves to a trie with multiple values, returns one result for each value.
trie.indent(path)
Returns the trie nested under the path. ParamTrie.ofPath(p, v)
is equivalent to ParamTrie.of(v).indent(p)
.
MIT.
FAQs
A trie with holes for parameters
We found that param-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.