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.
connection-paths
Advanced tools
Determine if two things are connected (e.g. network nodes) and generate a list of possible paths
Determine if two things are connected (e.g. network nodes) and generate a list of possible paths. For example, if A connects to B and C, B connects to C and D, and C connects to D and A, then A can connect to D via an infinite number of paths, assuming a thing is allowed to reconnect to previous things in the path.
opt
)Instantiate Connections
opt
- An options object
source
- An array of arrays of two strings or URL or file system path to a CSV file that maps sources to destinationshasHeader
- (Optional) Whether or not source
has a header. If true
, the first row will be removed. Defaults to false
.Example
var Connections = require('node-connection-paths'),
connections = Connections(
{
hasHeader: true,
source: [['A','B'], ['A','C'], ['B','C'], ['B','D'], ['C','D'], ['C','A']]
}
);
source
, cb
)Get the destinations of a source
opt
- A sourceerr
, array destinations
) cb
- A function to be executed after the destinations are collectedExample
connections.getDestinations('A', function(err, destinations) {
if (err){ throw err; }
console.log(destinations); //[ 'B', 'C' ]
});
opt
, cb
)Generate possible paths between a source and destination
opt
- An options object
source
- A sourcedestination
- A destinationreverse
- Whether or not a node is allowed to connect to the previous node. Defaults to false
.revisit
- Whether or not a node is allowed to connect to any previous nodes. Defaults to false
.format
- (Optional) If "string", paths
will be an array of strings. If "array", paths
will be an array of arrays of strings. Defaults to "array".max
- (Optional) The maximum number of paths to generate. Defaults to 100.depth
queue
- (Optional) Concurrency limit for recursive operations. Defaults to 500.recursion
- (Optional) Maximum path recursion. Defaults to 5.err
, array{string} | array{array{string}} paths
) cb
- A function to be executed after the paths are generatedExample
connections.getPaths(
{
source: 'A',
destination: 'D',
reverse: true,
revisit: true,
format: 'string',
max: 2,
depth: {
queue: 10,
recursion: 3
}
}, function(err, paths) {
if (err) { throw err; }
console.log(paths); //[ 'A,B,D', 'A,C,D' ]
}
);
opt
, cb
)Determine if a source and destination are connected. Note that it is much faster to use a directed graph. There are several directed graph libraries available on NPM, including graph.js and directed-graph.
opt
- An options object
source
- A sourcedestination
- A destinationdepth
queue
- (Optional) Concurrency limit for recursive operations. Defaults to 100.recursion
- (Optional) Maximum path recursion. Defaults to 5.err
, boolean areConnected
) cb
- A function to be executed after the check is completedExample
connections.areConnected(
{
source: 'A',
destination: 'D',
depth: {
queue: 100,
recursion: 10
}
}, function(err, areConnected) {
if (err) { throw err; }
console.log(areConnected); //true
}
);
err
))If the connection source / destination CSV data is loaded via URL or file system path, the API methods cannot be called until this event is emitted
Example
var path = require('path'),
connections = Connections({source: path.join(__dirname, 'test.csv')});
connections.events.on('ready', function(err) {
if (err) { throw err; }
connections.areConnected(
{
source: 'A',
destination: 'D',
depth: {
queue: 100,
recursion: 10
}
}, function(err, areConnected) {
if (err) { throw err; }
console.log(areConnected); //true
}
);
});
npm install connection-paths --save
FAQs
Determine if two things are connected (e.g. network nodes) and generate a list of possible paths
The npm package connection-paths receives a total of 1 weekly downloads. As such, connection-paths popularity was classified as not popular.
We found that connection-paths 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.